Loading tests/tests/test_jpyp.py +65 −3 Original line number Diff line number Diff line Loading @@ -67,6 +67,48 @@ class PyThermoGIS(TestCase): # Assert self.checkOutputGridValues() def test_doublet(self): if jpype.isJVMStarted(): jpype.shutdownJVM() jpype.startJVM(str(self.jvm_path), classpath=[self.thermogis_jar_path]) # Arrange # Import Java Classes Logger = JClass("logging.Logger") Mockito = JClass("org.mockito.Mockito") RNG = JClass("tno.geoenergy.stochastic.RandomNumberGenerator") ThermoGISDoublet = JClass("thermogis.calc.doublet.ThermoGisDoublet") # Instantiate ThermoGISProperties ThermoGISProperties = JClass("thermogis.gui.ThermoGISProperties") ThermoGISProperties.instantiateProperties() ThermoGISProperties.instantiateRunProperties() self.setupDefaultProperties(ThermoGISProperties) # Create instances of loggerMock, progressTrackerMock, taskExecutor and utc doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(123)) # Set parameters to be simulated thickness = 199.0 ntg = 0.95 tres = 74.774506 porosity = 0.27 depth = 1990.0 khPvalue = 700.0 hp_minimum_injection_temperature = 15 return_temperature = 30 surface_temperature = 10 max_cooling_temperature_range = 100 stimKhMax = 20 kHQuantile = 139742.39 set_doublet_parameters(doublet, False, stimKhMax, khPvalue, depth, porosity, ntg, tres, surface_temperature, return_temperature, False, max_cooling_temperature_range, hp_minimum_injection_temperature) # Act doublet.calculateDoubletPerformance(-99999.0, thickness, kHQuantile) # Assert self.assertTrue(np.isclose(doublet.doubletCalc1DData.getFlowrate(), 499.975007564939,1e-5)) def checkOutputGridValues(self): flowRateGrid = read_grid(self.model_path / "Results" / "simplified" / "BaseCase" / "simplified__flowr_P50.zmap") Loading Loading @@ -162,7 +204,6 @@ class PyThermoGIS(TestCase): self.assertTrue(np.isclose(1193.16406250, wellDepthGrid.max(), tolerance)) self.assertTrue(np.isclose(1019.05383301, wellDepthGrid.mean(), tolerance)) def setupDefaultProperties(self, ThermoGISProperties): PropertyFactory = JClass("tno.geoenergy.properties.PropertyFactory") GuiProperty = JClass("tno.geoenergy.properties.guicomponents.GuiProperty") Loading @@ -183,3 +224,24 @@ class PyThermoGIS(TestCase): PropertyFactory.setGuiProperty(tempFromVoxet, GuiProperty("0", "", False, "", "")) PropertyFactory.setGuiProperty(nCores, 1) PropertyFactory.setGuiProperty(copyAquiferFiles, 0) def set_doublet_parameters(doublet, useStimulation, stimKhMax, khPvalue, depth, porosity, ntg, tres, surface_temperature, return_temperature, use_heat_pump, max_cooling_temperature_range, hp_minimum_injection_temperature): if not useStimulation or khPvalue > stimKhMax: doublet.setNoStimulation() doublet.doubletCalc1DData.setDepth(depth) doublet.doubletCalc1DData.setPorosity(porosity) doublet.doubletCalc1DData.setNtg(ntg) doublet.doubletCalc1DData.setSurfaceTemperature(surface_temperature) doublet.doubletCalc1DData.setReservoirTemp(tres) doublet.doubletCalc1DData.setUseHeatPump(use_heat_pump) if use_heat_pump: injectionTemp = np.max([tres - max_cooling_temperature_range, hp_minimum_injection_temperature]) else: injectionTemp = np.max([tres - max_cooling_temperature_range, return_temperature]) doublet.doubletCalc1DData.setInjectionTemp(injectionTemp) doublet.doubletCalc1DData.setDhReturnTemp(return_temperature) Loading
tests/tests/test_jpyp.py +65 −3 Original line number Diff line number Diff line Loading @@ -67,6 +67,48 @@ class PyThermoGIS(TestCase): # Assert self.checkOutputGridValues() def test_doublet(self): if jpype.isJVMStarted(): jpype.shutdownJVM() jpype.startJVM(str(self.jvm_path), classpath=[self.thermogis_jar_path]) # Arrange # Import Java Classes Logger = JClass("logging.Logger") Mockito = JClass("org.mockito.Mockito") RNG = JClass("tno.geoenergy.stochastic.RandomNumberGenerator") ThermoGISDoublet = JClass("thermogis.calc.doublet.ThermoGisDoublet") # Instantiate ThermoGISProperties ThermoGISProperties = JClass("thermogis.gui.ThermoGISProperties") ThermoGISProperties.instantiateProperties() ThermoGISProperties.instantiateRunProperties() self.setupDefaultProperties(ThermoGISProperties) # Create instances of loggerMock, progressTrackerMock, taskExecutor and utc doublet = ThermoGISDoublet(Mockito.mock(Logger), RNG(123)) # Set parameters to be simulated thickness = 199.0 ntg = 0.95 tres = 74.774506 porosity = 0.27 depth = 1990.0 khPvalue = 700.0 hp_minimum_injection_temperature = 15 return_temperature = 30 surface_temperature = 10 max_cooling_temperature_range = 100 stimKhMax = 20 kHQuantile = 139742.39 set_doublet_parameters(doublet, False, stimKhMax, khPvalue, depth, porosity, ntg, tres, surface_temperature, return_temperature, False, max_cooling_temperature_range, hp_minimum_injection_temperature) # Act doublet.calculateDoubletPerformance(-99999.0, thickness, kHQuantile) # Assert self.assertTrue(np.isclose(doublet.doubletCalc1DData.getFlowrate(), 499.975007564939,1e-5)) def checkOutputGridValues(self): flowRateGrid = read_grid(self.model_path / "Results" / "simplified" / "BaseCase" / "simplified__flowr_P50.zmap") Loading Loading @@ -162,7 +204,6 @@ class PyThermoGIS(TestCase): self.assertTrue(np.isclose(1193.16406250, wellDepthGrid.max(), tolerance)) self.assertTrue(np.isclose(1019.05383301, wellDepthGrid.mean(), tolerance)) def setupDefaultProperties(self, ThermoGISProperties): PropertyFactory = JClass("tno.geoenergy.properties.PropertyFactory") GuiProperty = JClass("tno.geoenergy.properties.guicomponents.GuiProperty") Loading @@ -183,3 +224,24 @@ class PyThermoGIS(TestCase): PropertyFactory.setGuiProperty(tempFromVoxet, GuiProperty("0", "", False, "", "")) PropertyFactory.setGuiProperty(nCores, 1) PropertyFactory.setGuiProperty(copyAquiferFiles, 0) def set_doublet_parameters(doublet, useStimulation, stimKhMax, khPvalue, depth, porosity, ntg, tres, surface_temperature, return_temperature, use_heat_pump, max_cooling_temperature_range, hp_minimum_injection_temperature): if not useStimulation or khPvalue > stimKhMax: doublet.setNoStimulation() doublet.doubletCalc1DData.setDepth(depth) doublet.doubletCalc1DData.setPorosity(porosity) doublet.doubletCalc1DData.setNtg(ntg) doublet.doubletCalc1DData.setSurfaceTemperature(surface_temperature) doublet.doubletCalc1DData.setReservoirTemp(tres) doublet.doubletCalc1DData.setUseHeatPump(use_heat_pump) if use_heat_pump: injectionTemp = np.max([tres - max_cooling_temperature_range, hp_minimum_injection_temperature]) else: injectionTemp = np.max([tres - max_cooling_temperature_range, return_temperature]) doublet.doubletCalc1DData.setInjectionTemp(injectionTemp) doublet.doubletCalc1DData.setDhReturnTemp(return_temperature)