TNO Intern

Commit 76d9f597 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Merge branch '4-add-in-the-extra-tests' into 'main'

Resolve "Add in the extra tests"

Closes #4

See merge request AGS/pythermogis!8
parents fad64165 0936ea42
Loading
Loading
Loading
Loading
+24 −14
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ from jpype import JClass

from pythermogis.physics.temperature_grid_calculation import calculate_temperature_from_gradient
from pythermogis.statistics.calculate_pvalues import generate_thickness_permeability_transmissivity_for_pvalue
from pythermogis.thermogis_classes.java_start import start_jvm
from pythermogis.thermogis_classes.java_start import start_jvm, close_jvm


def calculate_performance_of_single_location(hydrocarbons: float, depth: float, thickness: float, porosity: float, ntg: float, temperature: float, transmissivity: float, transmissivity_with_ntg: float, doublet=None,
@@ -69,8 +69,9 @@ def calculate_performance_across_dimensions(input_data: xr.Dataset,
    """
    if p_values is None:
        p_values = [50.0]
    if input_params is None:    # If input parameters is none; then setup the BaseCase parameters
        input_params = {"hp_minimum_injection_temperature": 15,

    # Input parameters
    input_params_basecase = {"hp_minimum_injection_temperature": 15,
                    "return_temperature": 30,
                    "surface_temperature": 10,
                    "degrees_per_km": 31,
@@ -81,6 +82,12 @@ def calculate_performance_across_dimensions(input_data: xr.Dataset,
                    "utc_cutoff_shallow": 5.1,
                    "utc_cutoff_deep": 6.5,
                    "utc_cutoff_depth": 4000.0}

    if input_params is None:    # If no input_params provided, use the basecase
        input_params = input_params_basecase
    else:
        input_params = {key: input_params.get(key, input_params_basecase[key]) for key in input_params_basecase}

    if "temperature" not in input_data:
        input_data["temperature"] = calculate_temperature_from_gradient(input_data.depth, input_data.thickness_mean, input_params["degrees_per_km"], input_params["surface_temperature"])

@@ -96,7 +103,7 @@ def calculate_performance_across_dimensions(input_data: xr.Dataset,

    # Instantiate the UTC properties class
    propsBuilder = UTCPropertiesBuilder()
    utc_properties = propsBuilder.build()
    utc_properties = propsBuilder.setUseHeatPump(input_params["use_heat_pump"]).setUseStimulation(input_params["use_stimulation"]).build()

    # Instantiate random number generator:
    if rng_seed is None:
@@ -179,6 +186,9 @@ def calculate_performance_across_dimensions(input_data: xr.Dataset,
        flow_rate_data.append(output_data_arrays[10])
        welld_data.append(output_data_arrays[11])

    # close the jvm
    close_jvm()

    output_data["power"] = (output_data.coords, power_data)
    output_data["heat_pump_power"] = (output_data.coords, heat_pump_power_data)
    output_data["capex"] = (output_data.coords, capex_data)
+9 −0
Original line number Diff line number Diff line
@@ -25,6 +25,15 @@ def start_jvm():
    if not jpype.isJVMStarted():
        jpype.startJVM(get_jvm_path(), classpath=[get_thermogis_jar_path()])

def close_jvm():
    """
    To use the JPype package a java .jar file has to be instantiated with a java virtual machine (jvm)
    This method ensures a clean startup of the jvm packaged with this repo
    :return:
    """
    if jpype.isJVMStarted():
        jpype.shutdownJVM()


if __name__ == "__main__":
    start_jvm()
 No newline at end of file
(2.31 KiB)

File moved.

(2.31 KiB)

File changed and moved.

No diff preview for this file type.

(2.31 KiB)

File moved.

Loading