TNO Intern

Commit f8453d2f authored by Florian Knappers's avatar Florian Knappers
Browse files

fixed all other tests

parent b0d74286
Loading
Loading
Loading
Loading
Loading
+30 −65
Original line number Diff line number Diff line
@@ -106,13 +106,25 @@ def calculate_performance_of_single_location(mask: float, depth: float, thicknes

    # Instantiate ThermoGIS doublet
    doublet = instantiate_thermogis_doublet(utc_properties, rng_seed)
    set_doublet_parameters(doublet, transmissivity_with_ntg, depth, porosity, ntg, temperature, utc_properties)

    DoubletInput = JClass("thermogis.calc.utc.doublet.records.DoubletInput")
    input = DoubletInput(
            -9999.0, # unknowninput
            thickness,
            transmissivity,
            transmissivity_with_ntg,
            ntg,
            depth,
            porosity,
            temperature,
            None, # ates input
        )

    # The Java routine which calculates DoubletPerformance, for more detail on the simulation inspect the Java source code
    doublet.calculateDoubletPerformance(-9999.0, thickness, transmissivity, False)
    results = doublet.calculateDoubletPerformance(input)

    # If calculation was not successful, return mask value
    if doublet.getUtcPeurctkWh() == -9999.0:
    if results.utc() == -9999.0:
        return (mask_value,) * 14

    # calculate net-present-value using the utc-cutoffs
@@ -121,28 +133,27 @@ def calculate_performance_of_single_location(mask: float, depth: float, thicknes
    else:
        utc_cut = utc_properties.utcCutoff()

    hprod = doublet.getDiscountedHeatProducedP()
    npv = 1e-6 * (utc_cut - doublet.getUtcPeurctkWh()) * 3.6 * hprod * (1 - utc_properties.taxRate())
    hprod = results.hprod()
    npv = 1e-6 * (utc_cut - results.utc()) * 3.6 * hprod * (1 - utc_properties.taxRate())

    # get values from doublet
    output_values = {"power": doublet.getHpP(),
                     "heat_pump_power": doublet.getHeatPowerPerDoublet(),
                     "capex": doublet.getSumcapex(),
                     "opex": doublet.getOpexFirstProdYear(),
                     "utc": doublet.getUtcPeurctkWh(),
    output_values = {"power": results.power(),
                     "heat_pump_power": results.hppower(),
                     "capex": results.capex(),
                     "opex": results.opex(),
                     "utc": results.utc(),
                     "npv": npv,
                     "hprod": hprod,
                     "cop": doublet.getCop(),
                     "cophp": doublet.getCopHpP(),
                     "pres": doublet.getPresP() / 1e5,
                     "flow_rate": doublet.getFlowrate(),
                     "welld": doublet.getWellDistP(),
                     "inj_temp": doublet.getInjectionTemp(),
                     "prd_temp": doublet.getProductionTemp()
                     "cop": results.cop(),
                     "cophp": results.cophp(),
                     "pres": results.pres(),
                     "flow_rate": results.flow(),
                     "welld": results.welld(),
                     "inj_temp": 0, #TODO: this is ATES output. Is ATES supported in pytg?
                     "prd_temp": 0 #TODO: this is ATES output. Is ATES supported in pytg?
                     }

    # Reset doublet variables for next calculation
    doublet.setProjectVariables(False, 0.0)
    return output_values["power"], output_values["heat_pump_power"], output_values["capex"], output_values["opex"], output_values["utc"], output_values["npv"], output_values["hprod"], output_values["cop"], output_values[
        "cophp"], output_values["pres"], output_values["flow_rate"], output_values["welld"], output_values["inj_temp"], output_values["prd_temp"]

@@ -186,7 +197,7 @@ def instantiate_thermogis_doublet(utc_properties, rng_seed: int = None) -> JClas
    Logger = JClass("logging.Logger")
    Mockito = JClass("org.mockito.Mockito")
    RNG = JClass("tno.geoenergy.stochastic.RandomNumberGenerator")
    ThermoGISDoublet = JClass("thermogis.calc.doublet.ThermoGisDoublet")
    ThermoGISDoublet = JClass("thermogis.calc.utc.doublet.ThermoGisDoublet")

    # Create an instance of a ThermoGISDoublet
    if rng_seed is not None:
@@ -196,50 +207,4 @@ def instantiate_thermogis_doublet(utc_properties, rng_seed: int = None) -> JClas

    doublet = ThermoGISDoublet(Mockito.mock(Logger), rng, utc_properties)

    # Set parameters that do not change across simulations
    doublet.setSurfaceTemperature(utc_properties.surfaceTemperature())
    doublet.setDhReturnTemp(utc_properties.dhReturnTemp())

    return doublet

def set_doublet_parameters(doublet, transmissivity_with_ntg: float, depth: float, porosity: float, ntg: float, temperature: float, utc_properties: JClass):
    """
    Set necessary data on the doublet class for a single location prior to simulation.

    Parameters
    ----------
    utc_properties : dict
        Dictionary containing UTC properties.
    doublet : object
        An instance of the ThermoGIS doublet class.
    transmissivity_with_ntg : float
        Product of transmissivity and net-to-gross.
    depth : float
        Depth of the aquifer in meters.
    porosity : float
        Porosity of the aquifer (fraction).
    ntg : float
        Net-to-gross ratio of the aquifer (fraction).
    temperature : float
        Temperature of the aquifer in degrees Celsius.

    Returns
    -------
    None
    """

    if not utc_properties.useStimulation() or transmissivity_with_ntg > utc_properties.stimKhMax():
        doublet.setNoStimulation()

    doublet.setDepth(depth)
    doublet.setPorosity(porosity)
    doublet.setNtg(ntg)
    doublet.setReservoirTemp(temperature)

    if utc_properties.useHeatPump():
        if utc_properties.calculateCop() and not utc_properties.hpApplicationMode():
            doublet.setInjectionTemp(doublet.calculateInjectionTempWithHeatPump(temperature, utc_properties.hpDirectHeatInputTemp()))
        else:
            doublet.setInjectionTemp(np.max([temperature - utc_properties.maxCoolingTempRange(), utc_properties.hpMinimumInjectionTemperature()]))
    else:
        doublet.setInjectionTemp(np.max([temperature - utc_properties.maxCoolingTempRange(), utc_properties.dhReturnTemp()]))