Loading pythermogis/doublet.py +4 −9 Original line number Diff line number Diff line Loading @@ -100,7 +100,6 @@ def calculate_doublet_performance( - "transmissivity" - "transmissivity_with_ntg" """ if print_execution_duration: start = timeit.default_timer() validate_input_deterministic(reservoir_properties) Loading Loading @@ -219,7 +218,6 @@ def validate_input_deterministic(reservoir_properties: xr.Dataset): def calculate_doublet_performance_stochastic( reservoir_properties: xr.Dataset, utc_properties=None, rng_seed=None, p_values: list[float] | None = None, chunk_size: int = None, print_execution_duration=False, Loading Loading @@ -264,8 +262,6 @@ def calculate_doublet_performance_stochastic( utc_properties : JClass A Java class specifying the properties of the doublet being simulated rng_seed : int Random seed used for stochastic components of the simulation. p_values : list of float, optional List of probability values (e.g., [0.1, 0.5, 0.9]) for the performance Loading Loading @@ -317,7 +313,6 @@ def calculate_doublet_performance_stochastic( - transmissivity - transmissivity_with_ntg """ if print_execution_duration: start = timeit.default_timer() if p_values is None: Loading Loading @@ -564,7 +559,7 @@ def calculate_performance_of_single_location( doublet = instantiate_thermogis_doublet(utc_properties) DoubletInput = JClass("thermogis.calc.utc.doublet.Doublet.DoubletInput") input = DoubletInput( doublet_input = DoubletInput( -9999.0, # unknowninput thickness, transmissivity, Loading @@ -579,7 +574,7 @@ def calculate_performance_of_single_location( # The Java routine which calculates DoubletPerformance, # for more detail on the simulation inspect the Java source code try: results = doublet.calculateDoubletPerformance(input) results = doublet.calculateDoubletPerformance(doublet_input) except Exception: return (mask_value,) * 14 Loading pythermogis/transmissivity.py +6 −6 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ def generate_thickness_permeability_transmissivity_for_pvalues( ln_permeability_mean: float, ln_permeability_sd: float, p_values: xr.DataArray, nSamples: int = 10000, nsamples: int = 10000, ) -> float: """ Given thickness provided as a normal distribution and ln(permeability) Loading @@ -30,7 +30,7 @@ def generate_thickness_permeability_transmissivity_for_pvalues( :param ln_permeability_mean: :param ln_permeability_sd: :param p_values: :param nSamples: :param nsamples: :return: thickness, permeability, transmissivity """ Loading Loading @@ -67,11 +67,11 @@ def generate_thickness_permeability_transmissivity_for_pvalues( if thickness_sd == 0: thickness_pvalues = np.full(len(p_value_fractions), thickness_mean) thickness_samples = np.full(nSamples, thickness_mean) thickness_samples = np.full(nsamples, thickness_mean) else: thickness_dist = stats.norm(loc=thickness_mean, scale=thickness_sd) thickness_pvalues = thickness_dist.ppf(p_value_fractions) thickness_samples = thickness_dist.rvs(nSamples) thickness_samples = thickness_dist.rvs(nsamples) thickness_samples = np.clip(thickness_samples, a_min=0.01, a_max=None) ln_permeability_dist = stats.norm( Loading @@ -81,10 +81,10 @@ def generate_thickness_permeability_transmissivity_for_pvalues( # Sampling method for transmissivity transmissivity_samples = np.sort( np.exp(ln_permeability_dist.rvs(nSamples) + np.log(thickness_samples)) np.exp(ln_permeability_dist.rvs(nsamples) + np.log(thickness_samples)) ) sample_indexes = np.array(p_value_fractions * (nSamples - 1)) sample_indexes = np.array(p_value_fractions * (nsamples - 1)) transmissivity_pvalues_sampled = transmissivity_samples[sample_indexes.astype(int)] return thickness_pvalues, permeability_pvalues, transmissivity_pvalues_sampled tests/test_benchmarks.py +5 −5 Original line number Diff line number Diff line Loading @@ -372,7 +372,7 @@ class PythermoGISDoubletBenchmark(TestCase): ) results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties ) # Assert Loading Loading @@ -412,7 +412,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) # Assert Loading Loading @@ -456,7 +456,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) # Assert Loading Loading @@ -501,7 +501,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) # Assert Loading Loading @@ -545,7 +545,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) power_hpelec = results.heat_pump_power / (results.cophp - 1) power_ratio = results.power / (results.power + power_hpelec) Loading tests/test_doublet.py +2 −4 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ class PyThermoGISSpeedTest(TestCase): # 43 seconds in the Java code start = timeit.default_timer() calculate_doublet_performance_stochastic( input_grids, chunk_size=5, rng_seed=123, p_values=p_values input_grids, chunk_size=5, p_values=p_values ) time_elapsed = timeit.default_timer() - start print(f"Python calculation took {time_elapsed:.1f} seconds.") Loading Loading @@ -248,7 +248,7 @@ class PyThermoGISScenarios(TestCase): # scenario. Run calculation across all dimensions of input_grids, # and all provided P_values output_grids = calculate_doublet_performance_stochastic( self.input_grids, rng_seed=123, p_values=self.p_values self.input_grids, p_values=self.p_values ) # Assert values are the same as the benchmark grids generated by the Java code Loading @@ -272,7 +272,6 @@ class PyThermoGISScenarios(TestCase): output_grids = calculate_doublet_performance_stochastic( self.input_grids, utc_properties=utc_properties, rng_seed=123, p_values=self.p_values, ) Loading @@ -297,7 +296,6 @@ class PyThermoGISScenarios(TestCase): output_grids = calculate_doublet_performance_stochastic( self.input_grids, utc_properties=utc_properties, rng_seed=123, p_values=self.p_values, ) Loading Loading
pythermogis/doublet.py +4 −9 Original line number Diff line number Diff line Loading @@ -100,7 +100,6 @@ def calculate_doublet_performance( - "transmissivity" - "transmissivity_with_ntg" """ if print_execution_duration: start = timeit.default_timer() validate_input_deterministic(reservoir_properties) Loading Loading @@ -219,7 +218,6 @@ def validate_input_deterministic(reservoir_properties: xr.Dataset): def calculate_doublet_performance_stochastic( reservoir_properties: xr.Dataset, utc_properties=None, rng_seed=None, p_values: list[float] | None = None, chunk_size: int = None, print_execution_duration=False, Loading Loading @@ -264,8 +262,6 @@ def calculate_doublet_performance_stochastic( utc_properties : JClass A Java class specifying the properties of the doublet being simulated rng_seed : int Random seed used for stochastic components of the simulation. p_values : list of float, optional List of probability values (e.g., [0.1, 0.5, 0.9]) for the performance Loading Loading @@ -317,7 +313,6 @@ def calculate_doublet_performance_stochastic( - transmissivity - transmissivity_with_ntg """ if print_execution_duration: start = timeit.default_timer() if p_values is None: Loading Loading @@ -564,7 +559,7 @@ def calculate_performance_of_single_location( doublet = instantiate_thermogis_doublet(utc_properties) DoubletInput = JClass("thermogis.calc.utc.doublet.Doublet.DoubletInput") input = DoubletInput( doublet_input = DoubletInput( -9999.0, # unknowninput thickness, transmissivity, Loading @@ -579,7 +574,7 @@ def calculate_performance_of_single_location( # The Java routine which calculates DoubletPerformance, # for more detail on the simulation inspect the Java source code try: results = doublet.calculateDoubletPerformance(input) results = doublet.calculateDoubletPerformance(doublet_input) except Exception: return (mask_value,) * 14 Loading
pythermogis/transmissivity.py +6 −6 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ def generate_thickness_permeability_transmissivity_for_pvalues( ln_permeability_mean: float, ln_permeability_sd: float, p_values: xr.DataArray, nSamples: int = 10000, nsamples: int = 10000, ) -> float: """ Given thickness provided as a normal distribution and ln(permeability) Loading @@ -30,7 +30,7 @@ def generate_thickness_permeability_transmissivity_for_pvalues( :param ln_permeability_mean: :param ln_permeability_sd: :param p_values: :param nSamples: :param nsamples: :return: thickness, permeability, transmissivity """ Loading Loading @@ -67,11 +67,11 @@ def generate_thickness_permeability_transmissivity_for_pvalues( if thickness_sd == 0: thickness_pvalues = np.full(len(p_value_fractions), thickness_mean) thickness_samples = np.full(nSamples, thickness_mean) thickness_samples = np.full(nsamples, thickness_mean) else: thickness_dist = stats.norm(loc=thickness_mean, scale=thickness_sd) thickness_pvalues = thickness_dist.ppf(p_value_fractions) thickness_samples = thickness_dist.rvs(nSamples) thickness_samples = thickness_dist.rvs(nsamples) thickness_samples = np.clip(thickness_samples, a_min=0.01, a_max=None) ln_permeability_dist = stats.norm( Loading @@ -81,10 +81,10 @@ def generate_thickness_permeability_transmissivity_for_pvalues( # Sampling method for transmissivity transmissivity_samples = np.sort( np.exp(ln_permeability_dist.rvs(nSamples) + np.log(thickness_samples)) np.exp(ln_permeability_dist.rvs(nsamples) + np.log(thickness_samples)) ) sample_indexes = np.array(p_value_fractions * (nSamples - 1)) sample_indexes = np.array(p_value_fractions * (nsamples - 1)) transmissivity_pvalues_sampled = transmissivity_samples[sample_indexes.astype(int)] return thickness_pvalues, permeability_pvalues, transmissivity_pvalues_sampled
tests/test_benchmarks.py +5 −5 Original line number Diff line number Diff line Loading @@ -372,7 +372,7 @@ class PythermoGISDoubletBenchmark(TestCase): ) results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties ) # Assert Loading Loading @@ -412,7 +412,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) # Assert Loading Loading @@ -456,7 +456,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) # Assert Loading Loading @@ -501,7 +501,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) # Assert Loading Loading @@ -545,7 +545,7 @@ class PythermoGISDoubletBenchmark(TestCase): # Act results = calculate_doublet_performance_stochastic( input_data, utc_properties=utc_properties, rng_seed=0 input_data, utc_properties=utc_properties, ) power_hpelec = results.heat_pump_power / (results.cophp - 1) power_ratio = results.power / (results.power + power_hpelec) Loading
tests/test_doublet.py +2 −4 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ class PyThermoGISSpeedTest(TestCase): # 43 seconds in the Java code start = timeit.default_timer() calculate_doublet_performance_stochastic( input_grids, chunk_size=5, rng_seed=123, p_values=p_values input_grids, chunk_size=5, p_values=p_values ) time_elapsed = timeit.default_timer() - start print(f"Python calculation took {time_elapsed:.1f} seconds.") Loading Loading @@ -248,7 +248,7 @@ class PyThermoGISScenarios(TestCase): # scenario. Run calculation across all dimensions of input_grids, # and all provided P_values output_grids = calculate_doublet_performance_stochastic( self.input_grids, rng_seed=123, p_values=self.p_values self.input_grids, p_values=self.p_values ) # Assert values are the same as the benchmark grids generated by the Java code Loading @@ -272,7 +272,6 @@ class PyThermoGISScenarios(TestCase): output_grids = calculate_doublet_performance_stochastic( self.input_grids, utc_properties=utc_properties, rng_seed=123, p_values=self.p_values, ) Loading @@ -297,7 +296,6 @@ class PyThermoGISScenarios(TestCase): output_grids = calculate_doublet_performance_stochastic( self.input_grids, utc_properties=utc_properties, rng_seed=123, p_values=self.p_values, ) Loading