diff --git a/.gitignore b/.gitignore index 7a70f184040782f700ec07a80fbe975046271d77..37905002381e4d47e31fcc450d81bf593ee71a2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea __pycache__ +.env # pixi environments .pixi @@ -7,4 +8,5 @@ __pycache__ build dist -tests/resources/test_output \ No newline at end of file +tests/resources/test_output + diff --git a/README.md b/README.md index 2a4079bceeced310500de4a3e9265b7a3ef73663..9153aea91330a90c9bb7ca77092d0a1a2903874e 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,17 @@ This package requires a Java 17 VM (we recommend using [Amazon Corretto 17](http ### 2. Create Required Environment Variables +Create a file called ``.env`` in your project root folder. +This file should contain the following variables: + - `JAVA_HOME`: Path to the Java 17 installation *(e.g., on Windows: `C:\Program Files\Amazon Corretto\jdk17.0.0_0`)* - `THERMOGIS_JAR`: Path to the ThermoGIS `.jar` file; __including__ the name of the jar file *(e.g. `/path/to/the/thermogis-1.7.0-shaded.jar`)* +Example: +![img.png](docs/images/dotenv_file_example.png) ### 3. Import pyThermoGIS into your own python projects diff --git a/docs/images/dotenv_file_example.png b/docs/images/dotenv_file_example.png new file mode 100644 index 0000000000000000000000000000000000000000..d7f4c88118e53388ff95e66e0dd4298d51fe4c3e Binary files /dev/null and b/docs/images/dotenv_file_example.png differ diff --git a/docs/install/install.md b/docs/install/install.md index 2fd033180852c6e0dc42c40c4d97bfdf25480a5f..8bb1faa75e1c660526f6b76739572b834b627453 100644 --- a/docs/install/install.md +++ b/docs/install/install.md @@ -12,12 +12,18 @@ This package requires a Java 17 VM (we recommend using [Amazon Corretto 17](http ### 2. Create Required Environment Variables +Create a file called ``.env`` in your project root folder. +This file should contain the following variables: + - `JAVA_HOME`: Path to the Java 17 installation *(e.g., on Windows: `C:\Program Files\Amazon Corretto\jdk17.0.0_0`)* - `THERMOGIS_JAR`: Path to the ThermoGIS `.jar` file; __including__ the name of the jar file *(e.g. `/path/to/the/thermogis-1.7.0-shaded.jar`)* +Example: +![img.png](docs/images/dotenv_file_example.png) + ### 3. Import pyThermoGIS into your own python projects diff --git a/pixi.lock b/pixi.lock index dcf440a2f63fb3134ff5aa57c4eebe7853dcc75d..07eb60ceb7c703fe67e627320f8e751dd8e0d0b7 100644 --- a/pixi.lock +++ b/pixi.lock @@ -190,6 +190,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-8.3.5-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.13.3-hf636f53_101_cp313.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhff2d567_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.2.1-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.13.3-h4df99d1_101.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-tzdata-2025.2-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.13-7_cp313.conda @@ -417,6 +418,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-8.3.5-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/python-3.13.3-h261c0b1_101_cp313.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhff2d567_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.2.1-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.13.3-h4df99d1_101.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python-tzdata-2025.2-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.13-7_cp313.conda @@ -4828,7 +4830,7 @@ packages: - pypi: ./ name: pythermogis version: 1.1.2 - sha256: 47088f620c807fe8afea448a35ad74be7a39bc6f02a1fecb7ad93f21c02de4ff + sha256: 6c2c51bb843ce5d8e0fb17a271a6425a468bc6da8718c96355b2132adc2a0c4d requires_dist: - jpype1>=1.5.2,<2 - xarray==2024.9.0.* @@ -4901,6 +4903,18 @@ packages: - pkg:pypi/python-dateutil?source=hash-mapping size: 222505 timestamp: 1733215763718 +- conda: https://conda.anaconda.org/conda-forge/noarch/python-dotenv-1.2.1-pyhcf101f3_0.conda + sha256: aa98e0b1f5472161318f93224f1cfec1355ff69d2f79f896c0b9e033e4a6caf9 + md5: 083725d6cd3dc007f06d04bcf1e613a2 + depends: + - python >=3.10 + - python + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/python-dotenv?source=hash-mapping + size: 26922 + timestamp: 1761503229008 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.13.3-h4df99d1_101.conda sha256: 54a19e0ed3be0c3397301482b44008fc8d21058ebb9d17ed7046b14bda0e16f4 md5: 82c2641f2f0f513f7d2d1b847a2588e3 diff --git a/pyproject.toml b/pyproject.toml index c2839a4ad385f9ee493064e53c1a6ee5c04e4cdc..13e899d2b8b97a8310aaaa7aae09fc996ebfc025 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,7 @@ mkdocstrings-python = ">=1.16.12,<2" dask = ">=2025.5.1,<2026" narwhals = ">=1.43.1,<2" pre-commit = ">=4.3.0,<5" +python-dotenv = ">=1.2.1,<2" [tool.ruff] line-length = 88 diff --git a/resources/thermogis_jar/thermogis-1.7.0-shaded.jar b/resources/thermogis_jar/thermogis-1.7.0-shaded.jar index 131c95d396e6574f46da8081b641553277f712ee..2c274aa1c6f077bcc55c5f71a355227e06136743 100644 --- a/resources/thermogis_jar/thermogis-1.7.0-shaded.jar +++ b/resources/thermogis_jar/thermogis-1.7.0-shaded.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4eba994664c590c1ad026c1544c00bde3b6cdcb7e498b3968ff7b203d3170ac0 -size 131514517 +oid sha256:7991ac4e8853db7f863de4c809f0d8035ea8c9ca5a90707e2e93799d6d6f39d6 +size 173317904 diff --git a/src/pythermogis/thermogis_classes/doublet.py b/src/pythermogis/thermogis_classes/doublet.py index 5c1e8d7a4afb4762120d45bbf01eb5a2b2ba8985..013be70b9d68aece17610664f23a8eab2fa1b579 100644 --- a/src/pythermogis/thermogis_classes/doublet.py +++ b/src/pythermogis/thermogis_classes/doublet.py @@ -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": results.injectionTemp(), + "prd_temp": results.productionTemp(), } # 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()])) diff --git a/src/pythermogis/thermogis_classes/jvm_start.py b/src/pythermogis/thermogis_classes/jvm_start.py index 57a02c90256fca82f18b36690b1256e35f9c89c7..a4f72f3e4991bd6d68f1a43f12ff9842f0da126f 100644 --- a/src/pythermogis/thermogis_classes/jvm_start.py +++ b/src/pythermogis/thermogis_classes/jvm_start.py @@ -3,14 +3,20 @@ from pathlib import Path import jpype import faulthandler +from dotenv import load_dotenv + +load_dotenv() + def get_thermogis_jar_path() -> str: """ From the resources directory, return the path to the ThermoGIS Jar """ - if os.getenv("THERMOGIS_JAR") is None: - raise ValueError("THERMOGIS_JAR environment variable is not set") + tg_jar = os.getenv("THERMOGIS_JAR") + + if tg_jar is None: + raise ValueError("THERMOGIS_JAR environment variable is not set in the .env file.") - thermogis_jar_path = Path(os.getenv("THERMOGIS_JAR")) + thermogis_jar_path = Path(tg_jar) if not thermogis_jar_path.exists(): raise FileNotFoundError(f"Jar file not found at {thermogis_jar_path}, check that you have downloaded the ThermoGIS Jar and set the THERMOGIS_JAR environment variable.") return str(thermogis_jar_path) @@ -22,8 +28,10 @@ def start_jvm(): This method ensures a clean startup of the jvm packaged with this repo :return: """ - if os.getenv("JAVA_HOME") is None: - raise ValueError("JAVA_HOME environment variable is not set") + java_home = os.getenv("JAVA_HOME") + + if java_home is None: + raise ValueError("JAVA_HOME environment variable is not set in the .env file.") if not jpype.isJVMStarted(): # when running pytest with jpype a "Windows fatal exception" is thrown which in reality has no affect on the outcome or performance. diff --git a/tests/test_ThermoGISDoublet_Benchmark.py b/tests/test_ThermoGISDoublet_Benchmark.py index 37b586c1793db5b8f63b281ea3502d47cf81e8f1..dca7e23a34e282f4b6e2ab958c331985a984b898 100644 --- a/tests/test_ThermoGISDoublet_Benchmark.py +++ b/tests/test_ThermoGISDoublet_Benchmark.py @@ -14,44 +14,50 @@ class ThermoGISDoubletBenchmark(TestCase): returns the same values. """ # Arrange - # Import Java Classes start_jvm() 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") + DoubletInput = JClass("thermogis.calc.utc.doublet.records.DoubletInput") UTCPropertiesBuilder = JClass("thermogis.properties.builders.UTCPropertiesBuilder") ViscosityMode = JClass("tno.geoenergy.ViscosityMode") - # Instantiate the UTC properties class utc_properties = (UTCPropertiesBuilder() .setViscosityMode(ViscosityMode.KESTIN) + .setDhReturnTemp(40) .build()) + permeability = 175 + thickness = 100 + transmissivity = thickness * permeability + temperature = 76 + + input = DoubletInput( + -999.0, # unknowninput + thickness, + transmissivity, + 0.0, # transmissivityWithNtg + 1.0, # ntg + 2000.0, # depth + 0.0,# porosity + temperature, + None, # ates input + ) - # Create an instance of a ThermoGISDoublet doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) - # Setting input values - thickness = 100 - permeability = 175 - transmissivity = thickness * permeability - doublet.setReservoirTemp(76) - doublet.setDepth(2000) - doublet.setInjectionTemp(40) - doublet.setNtg(1.0) - doublet.setNoStimulation() # Act - doublet.calculateDoubletPerformance(-999, thickness, transmissivity, False) + results = doublet.calculateDoubletPerformance(input) # Assert self.assertTrue(np.isclose(17500, transmissivity, 0.001)) - self.assertTrue(np.isclose(227.2757568359375, doublet.getFlowrate(), 1)) - self.assertTrue(np.isclose(60, doublet.getDrawdownPressure() / 1e5, 0.001)) - self.assertTrue(np.isclose(6.616096470753937, doublet.getUtcPeurctkWh(), 0.001)) - self.assertTrue(np.isclose(1159.17968, doublet.getWellDistance(), 0.001)) - self.assertTrue(np.isclose(8.636903762817383, doublet.getHeatPowerPerDoublet(), 0.001)) - self.assertTrue(np.isclose(13.627557754516602, doublet.getCop(), 0.001)) + self.assertTrue(np.isclose(227.2757568359375, results.flow(), 1)) + self.assertTrue(np.isclose(60, results.pres(), 0.001)) + self.assertTrue(np.isclose(6.616096470753937, results.utc(), 0.001)) + self.assertTrue(np.isclose(1159.17968, results.welld(), 0.001)) + self.assertTrue(np.isclose(8.636903762817383, results.power(), 0.001)) + self.assertTrue(np.isclose(13.627557754516602, results.cop(), 0.001)) def test_calculateDoubletPerformance_directHeat(self): """ @@ -63,40 +69,47 @@ class ThermoGISDoubletBenchmark(TestCase): 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") + DoubletInput = JClass("thermogis.calc.utc.doublet.records.DoubletInput") ViscosityMode = JClass("tno.geoenergy.ViscosityMode") - # Instantiate the UTC properties class utc_properties = (self.setup_template_utc_properties_builder() .setOpexBase(0) + .setDhReturnTemp(40) .setViscosityMode(ViscosityMode.KESTIN) + .setUseStimulation(False) .build()) - # Create an instance of a ThermoGISDoublet - doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) - - # Setting input values thickness = 100 permeability = 175 transmissivity = thickness * permeability - doublet.setReservoirTemp(76) - doublet.setDepth(2000) - doublet.setInjectionTemp(40) - doublet.setNtg(1.0) - doublet.setNoStimulation() + temperature = 76 + + input = DoubletInput( + -999.0, # unknowninput + thickness, + transmissivity, + 0.0, # transmissivityWithNtg + 1.0, # ntg + 2000.0, # depth + 0.0,# porosity + temperature, + None, # ates input + ) + doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) # Act - doublet.calculateDoubletPerformance(-999, thickness, transmissivity, False) + results = doublet.calculateDoubletPerformance(input) # Assert self.assertTrue(np.isclose(17500, transmissivity, 0.001)) - self.assertTrue(np.isclose(227.2757568359375, doublet.getFlowrate(), 1)) - self.assertTrue(np.isclose(60, doublet.getDrawdownPressure() / 1e5, 0.001)) - self.assertTrue(np.isclose(1159.1796, doublet.getWellDistance(), 0.001)) - self.assertTrue(np.isclose(13.623167037963867, doublet.getCop(), 0.001)) - self.assertTrue(np.isclose(5.229816400909403, doublet.getUtcPeurctkWh(), 0.001)) - self.assertTrue(np.isclose(16.439682499211536, doublet.getSumcapex(), 0.001)) - self.assertTrue(np.isclose(8.624696731567383, doublet.getHeatPowerPerDoublet(), 0.001)) + self.assertTrue(np.isclose(227.2757568359375, results.flow(), 1)) + self.assertTrue(np.isclose(60, results.pres(), 0.001)) + self.assertTrue(np.isclose(1159.1796, results.welld(), 0.001)) + self.assertTrue(np.isclose(13.623167037963867, results.cop(), 0.001)) + self.assertTrue(np.isclose(5.229816400909403, results.utc(), 0.001)) + self.assertTrue(np.isclose(16.439682499211536, results.capex(), 0.001)) + self.assertTrue(np.isclose(8.624696731567383, results.power(), 0.001)) def test_calculateDoubletPerformance_chiller(self): """ @@ -108,42 +121,49 @@ class ThermoGISDoubletBenchmark(TestCase): 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") + DoubletInput = JClass("thermogis.calc.utc.doublet.records.DoubletInput") ViscosityMode = JClass("tno.geoenergy.ViscosityMode") - # Instantiate the UTC properties class - utc_properties = (self.setup_template_utc_properties_builder().setCapexConst(0.5) + utc_properties = (self.setup_template_utc_properties_builder() + .setCapexConst(0.5) .setCapexVariable(1100) .setHeatExchangerEfficiency(0.4) .setHeatExchangerParasitic(0.1) + .setDhReturnTemp(60) .setViscosityMode(ViscosityMode.KESTIN) .build()) - # Create an instance of a ThermoGISDoublet - doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) - - # Setting input values thickness = 100 permeability = 175 transmissivity = thickness * permeability - doublet.setReservoirTemp(76) - doublet.setDepth(2000) - doublet.setInjectionTemp(60) - doublet.setNtg(1.0) - doublet.setNoStimulation() + temperature = 76 + + input = DoubletInput( + -999.0, # unknowninput + thickness, + transmissivity, + 0.0, # transmissivityWithNtg + 1.0, # ntg + 2000.0, # depth + 0.0,# porosity + temperature, + None, # ates input + ) + doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) # Act - doublet.calculateDoubletPerformance(-999, thickness, transmissivity, False) + results = doublet.calculateDoubletPerformance(input) # Assert self.assertTrue(np.isclose(17500, transmissivity, 0.001)) - self.assertTrue(np.isclose(256.59625244140625, doublet.getFlowrate(), 1)) - self.assertTrue(np.isclose(60, doublet.getDrawdownPressure() / 1e5, 0.001)) - self.assertTrue(np.isclose(20.470115103822685, doublet.getUtcPeurctkWh(), 0.001)) - self.assertTrue(np.isclose(1227.1484375, doublet.getWellDistance(), 0.001)) - self.assertTrue(np.isclose(1.8887300754346803, doublet.getCop(), 0.001)) - self.assertTrue(np.isclose(1.6594701766967774, doublet.getHeatPowerPerDoublet(), 0.001)) - self.assertTrue(np.isclose(12.748051248109613, doublet.getSumcapex(), 0.001)) + self.assertTrue(np.isclose(256.59625244140625, results.flow(), 1)) + self.assertTrue(np.isclose(60, results.pres(), 0.001)) + self.assertTrue(np.isclose(20.470115103822685, results.utc(), 0.001)) + self.assertTrue(np.isclose(1227.1484375, results.welld(), 0.001)) + self.assertTrue(np.isclose(1.8887300754346803, results.cop(), 0.001)) + self.assertTrue(np.isclose(1.6594701766967774, results.power(), 0.001)) + self.assertTrue(np.isclose(12.748051248109613, results.capex(), 0.001)) def test_calculateDoubletPerformance_directheatHP(self): """ @@ -155,44 +175,49 @@ class ThermoGISDoubletBenchmark(TestCase): 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") + DoubletInput = JClass("thermogis.calc.utc.doublet.records.DoubletInput") ViscosityMode = JClass("tno.geoenergy.ViscosityMode") - # Instantiate the UTC properties class utc_properties = (self.setup_template_utc_properties_builder() .setOpexPerPower(100) .setOpexBase(0) + .setHpDirectHeatInputTemp(70) .setUseHeatPump(True) - .setHpApplicationMode(True) - .setHpDirectHeatInputTemp(80) + .setDhReturnTemp(35) .setViscosityMode(ViscosityMode.KESTIN) .build()) - # Create an instance of a ThermoGISDoublet - doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) - # Setting input values thickness = 100 permeability = 175 transmissivity = thickness * permeability - doublet.setReservoirTemp(50) - doublet.setDepth(2000) - doublet.setDhReturnTemp(35) - doublet.setInjectionTemp(15) - doublet.setNtg(1.0) - doublet.setNoStimulation() + temperature = 50 + + input = DoubletInput( + -999.0, # unknowninput + thickness, + transmissivity, + 0.0, # transmissivityWithNtg + 1.0, # ntg + 2000.0, # depth + 0.0,# porosity + temperature, + None, # ates input + ) + doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) # Act - doublet.calculateDoubletPerformance(-999, thickness, transmissivity, False) + results = doublet.calculateDoubletPerformance(input) # Assert self.assertTrue(np.isclose(17499.99940, transmissivity, 0.001)) - self.assertTrue(np.isclose(163.99771118164062, doublet.getFlowrate(), 1)) - self.assertTrue(np.isclose(60, doublet.getDrawdownPressure() / 1e5, 0.001)) - self.assertTrue(np.isclose(5.67, doublet.getHeatPowerPerDoublet(), 0.001)) - self.assertTrue(np.isclose(955.27, doublet.getWellDistance(), 0.001)) - self.assertTrue(np.isclose(3.51, doublet.getCop(), 0.001)) - self.assertTrue(np.isclose(10.9, doublet.getUtcPeurctkWh(), 0.001)) - self.assertTrue(np.isclose(17.56, doublet.getSumcapex(), 0.001)) + self.assertTrue(np.isclose(163.99771118164062, results.flow(), 1)) + self.assertTrue(np.isclose(60, results.pres(), 0.001)) + self.assertTrue(np.isclose(4.97566556930542, results.power(), 0.001)) + self.assertTrue(np.isclose(989.2578125, results.welld(), 0.001)) + self.assertTrue(np.isclose(4.383212200392486, results.cop(), 0.001)) + self.assertTrue(np.isclose(10.401010755009017, results.utc(), 0.001)) + self.assertTrue(np.isclose(16.50359210062243, results.capex(), 0.001)) def test_calculateDoubletPerformance_ORC(self): @@ -205,42 +230,49 @@ class ThermoGISDoubletBenchmark(TestCase): 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") + DoubletInput = JClass("thermogis.calc.utc.doublet.records.DoubletInput") ViscosityMode = JClass("tno.geoenergy.ViscosityMode") - # Instantiate the UTC properties class - utc_properties = (self.setup_template_utc_properties_builder().setCapexConst(0) + utc_properties = (self.setup_template_utc_properties_builder() + .setCapexConst(0) .setCapexVariable(2300) .setHeatExchangerEfficiency(0.6) .setUseORC(True) .setViscosityMode(ViscosityMode.KESTIN) + .setDhReturnTemp(60) .setHeatExchangerBasetemp(20).build()) - # Create an instance of a ThermoGISDoublet - doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) - - # Setting input values thickness = 100 permeability = 175 transmissivity = thickness * permeability - doublet.setReservoirTemp(100) - doublet.setDepth(2000) - doublet.setInjectionTemp(60) - doublet.setNtg(1.0) - doublet.setNoStimulation() + temperature = 100 + + input = DoubletInput( + -999.0, # unknowninput + thickness, + transmissivity, + 0.0, # transmissivityWithNtg + 1.0, # ntg + 2000.0, # depth + 0.0,# porosity + temperature, + None, # ates input + ) + doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(0), utc_properties) # Act - doublet.calculateDoubletPerformance(-999, thickness, transmissivity, False) + results = doublet.calculateDoubletPerformance(input) # Assert self.assertTrue(np.isclose(17499.99940, transmissivity, 0.001)) - self.assertTrue(np.isclose(293.6246643066406, doublet.getFlowrate(), 1)) - self.assertTrue(np.isclose(60, doublet.getDrawdownPressure() / 1e5, 0.001)) - self.assertTrue(np.isclose(36.98296076530068, doublet.getUtcPeurctkWh(), 0.001)) - self.assertTrue(np.isclose(0.05274631495788107, doublet.getHeatPowerPerDoublet(), 0.01)) - self.assertTrue(np.isclose(1306.4453125, doublet.getWellDistance(), 0.001)) - self.assertTrue(np.isclose(0.06459403120103477, doublet.getCop(), 0.001)) - self.assertTrue(np.isclose(12.44409167482118, doublet.getSumcapex(), 0.001)) + self.assertTrue(np.isclose(293.6246643066406, results.flow(), 1)) + self.assertTrue(np.isclose(60, results.pres(), 0.001)) + self.assertTrue(np.isclose(36.98296076530068, results.utc(), 0.001)) + self.assertTrue(np.isclose(0.05274631495788107, results.power(), 0.01)) + self.assertTrue(np.isclose(1306.4453125, results.welld(), 0.001)) + self.assertTrue(np.isclose(0.06459403120103477, results.cop(), 0.001)) + self.assertTrue(np.isclose(12.44409167482118, results.capex(), 0.001)) def setup_template_utc_properties_builder(self): return (instantiate_utc_properties_builder()