Loading src/pythermogis/utils/__init__.py 0 → 100644 +0 −0 Empty file added. src/pythermogis/utils/timer.py 0 → 100644 +28 −0 Original line number Diff line number Diff line import sys import timeit def print_time(start, message: str = "", verbose: bool = True): if not verbose: return time_taken_seconds = timeit.default_timer() - start time_taken_message = format_time(time_taken_seconds) print(f"{message}{time_taken_message}", flush=True, file=sys.stdout) return timeit.default_timer() def format_time(seconds: float) -> str: hours = seconds // 3600 minutes = (seconds % 3600) // 60 seconds = seconds % 60 if hours > 0: return f"{hours:.0f}h {minutes:.0f}m {seconds:.0f}s" elif minutes > 0: return f"{minutes:.0f}m {seconds:.0f}s" elif seconds > 10: return f"{seconds:.1f}s" else: return f"{seconds:.3f}s" src/pythermogis/workflow/utc/doublet.py +12 −2 Original line number Diff line number Diff line from dataclasses import dataclass import timeit from pythermogis.workflow.utc.utc_properties import UTCConfiguration from pythermogis.workflow.utc.doublet_utils import calculate_injection_temp_with_heat_pump, \ calc_lifetime from pythermogis.workflow.utc.pressure import calculate_max_pressure, optimize_pressure from pythermogis.workflow.utc.cooling_temp import calculate_cooling_temperature from pythermogis.workflow.utc.well_distance import optimize_well_distance from utils.timer import print_time EUR_PER_CT_PER_KWH = 0.36 NPV_SCALE = 1e-6 Loading Loading @@ -48,11 +49,14 @@ class DoubletOutput: injection_temp: float def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) -> DoubletOutput | None: timer = timeit.default_timer() well_distance = ( (props.optim_dist_well_dist_min + props.optim_dist_well_dist_max) / 2 if props.optim_well_dist else props.default_well_distance ) timer = print_time(timer, "\tinitial well distance: ") injection_temperature = ( max(input.temperature - props.max_cooling_temp_range, Loading @@ -69,8 +73,9 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) props.dh_return_temp, input.temperature, props.max_cooling_temp_range, props.hp_minimum_injection_temperature props.hp_minimum_injection_temperature, ) timer = print_time(timer, "\tinjection temperature: ") drawdown_pressure = calculate_max_pressure( props, Loading @@ -79,6 +84,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) well_distance, injection_temperature, ) timer = print_time(timer, "\tmax pressure: ") if drawdown_pressure == 0: return None Loading @@ -104,6 +110,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) drawdown_pressure, injection_temperature, ) timer = print_time(timer, "\twell distance optimizer: ") stimulation_capex = ( 0.0 Loading @@ -119,6 +126,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) injection_temp=injection_temperature, stimulation_capex=stimulation_capex, ) timer = print_time(timer, "\tpressure optimizer: ") if pressure_results is None: return None Loading Loading @@ -166,6 +174,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) props.optim_dist_cp_rock, props.optim_dist_rho_rock ) timer = print_time(timer, "\tlifetime calculation:") utc_cutoff = ( props.utc_cutoff_deep if input.depth > props.utc_deep_depth else props.utc_cutoff Loading @@ -180,6 +189,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) ) opex_first_prod_year = total_opex_ts[props.drilling_time] hp_cop = 3.0 timer = print_time(timer, "\tutc & npv calculation: ") return DoubletOutput( power=heat_power_per_doublet, Loading src/pythermogis/workflow/utc/doubletcalc.py +2 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ def doubletcalc( )], aquifer_top_depth=input.depth, pipe_scaling=0, target_segment_length=props.segment_length, # target_segment_length=props.segment_length, outer_diameter=props.outer_diameter * INCH_SI, skin=get_total_skin_injection(props, input), pump_present=False, Loading @@ -72,7 +72,7 @@ def doubletcalc( )], aquifer_top_depth=input.depth, pipe_scaling=0, target_segment_length=props.segment_length, # target_segment_length=props.segment_length, outer_diameter=props.outer_diameter * INCH_SI, skin=get_total_skin_production(props, input), pump_present=True, Loading src/pythermogis/workflow/utc/pressure.py +5 −1 Original line number Diff line number Diff line import timeit from dataclasses import dataclass from pythermogis.workflow.utc.flow import calculate_volumetric_flow from pythermogis.workflow.utc.economics import calculate_economics from utils.timer import print_time def calculate_max_pressure( props, Loading @@ -10,7 +13,7 @@ def calculate_max_pressure( well_distance: float, injection_temp: float ) -> float: start = timeit.default_timer() if use_olsthoorn_max_pressure: max_pres = 0.2 * 0.1 * input_data.depth * 100000 else: Loading @@ -21,6 +24,7 @@ def calculate_max_pressure( results = calculate_volumetric_flow( props, input_data, pres, well_distance, injection_temp ) print_time(start, "\t\tcalculate volumetric flow: ") if results is None: pres_tol = 1e3 Loading Loading
src/pythermogis/utils/timer.py 0 → 100644 +28 −0 Original line number Diff line number Diff line import sys import timeit def print_time(start, message: str = "", verbose: bool = True): if not verbose: return time_taken_seconds = timeit.default_timer() - start time_taken_message = format_time(time_taken_seconds) print(f"{message}{time_taken_message}", flush=True, file=sys.stdout) return timeit.default_timer() def format_time(seconds: float) -> str: hours = seconds // 3600 minutes = (seconds % 3600) // 60 seconds = seconds % 60 if hours > 0: return f"{hours:.0f}h {minutes:.0f}m {seconds:.0f}s" elif minutes > 0: return f"{minutes:.0f}m {seconds:.0f}s" elif seconds > 10: return f"{seconds:.1f}s" else: return f"{seconds:.3f}s"
src/pythermogis/workflow/utc/doublet.py +12 −2 Original line number Diff line number Diff line from dataclasses import dataclass import timeit from pythermogis.workflow.utc.utc_properties import UTCConfiguration from pythermogis.workflow.utc.doublet_utils import calculate_injection_temp_with_heat_pump, \ calc_lifetime from pythermogis.workflow.utc.pressure import calculate_max_pressure, optimize_pressure from pythermogis.workflow.utc.cooling_temp import calculate_cooling_temperature from pythermogis.workflow.utc.well_distance import optimize_well_distance from utils.timer import print_time EUR_PER_CT_PER_KWH = 0.36 NPV_SCALE = 1e-6 Loading Loading @@ -48,11 +49,14 @@ class DoubletOutput: injection_temp: float def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) -> DoubletOutput | None: timer = timeit.default_timer() well_distance = ( (props.optim_dist_well_dist_min + props.optim_dist_well_dist_max) / 2 if props.optim_well_dist else props.default_well_distance ) timer = print_time(timer, "\tinitial well distance: ") injection_temperature = ( max(input.temperature - props.max_cooling_temp_range, Loading @@ -69,8 +73,9 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) props.dh_return_temp, input.temperature, props.max_cooling_temp_range, props.hp_minimum_injection_temperature props.hp_minimum_injection_temperature, ) timer = print_time(timer, "\tinjection temperature: ") drawdown_pressure = calculate_max_pressure( props, Loading @@ -79,6 +84,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) well_distance, injection_temperature, ) timer = print_time(timer, "\tmax pressure: ") if drawdown_pressure == 0: return None Loading @@ -104,6 +110,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) drawdown_pressure, injection_temperature, ) timer = print_time(timer, "\twell distance optimizer: ") stimulation_capex = ( 0.0 Loading @@ -119,6 +126,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) injection_temp=injection_temperature, stimulation_capex=stimulation_capex, ) timer = print_time(timer, "\tpressure optimizer: ") if pressure_results is None: return None Loading Loading @@ -166,6 +174,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) props.optim_dist_cp_rock, props.optim_dist_rho_rock ) timer = print_time(timer, "\tlifetime calculation:") utc_cutoff = ( props.utc_cutoff_deep if input.depth > props.utc_deep_depth else props.utc_cutoff Loading @@ -180,6 +189,7 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput) ) opex_first_prod_year = total_opex_ts[props.drilling_time] hp_cop = 3.0 timer = print_time(timer, "\tutc & npv calculation: ") return DoubletOutput( power=heat_power_per_doublet, Loading
src/pythermogis/workflow/utc/doubletcalc.py +2 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ def doubletcalc( )], aquifer_top_depth=input.depth, pipe_scaling=0, target_segment_length=props.segment_length, # target_segment_length=props.segment_length, outer_diameter=props.outer_diameter * INCH_SI, skin=get_total_skin_injection(props, input), pump_present=False, Loading @@ -72,7 +72,7 @@ def doubletcalc( )], aquifer_top_depth=input.depth, pipe_scaling=0, target_segment_length=props.segment_length, # target_segment_length=props.segment_length, outer_diameter=props.outer_diameter * INCH_SI, skin=get_total_skin_production(props, input), pump_present=True, Loading
src/pythermogis/workflow/utc/pressure.py +5 −1 Original line number Diff line number Diff line import timeit from dataclasses import dataclass from pythermogis.workflow.utc.flow import calculate_volumetric_flow from pythermogis.workflow.utc.economics import calculate_economics from utils.timer import print_time def calculate_max_pressure( props, Loading @@ -10,7 +13,7 @@ def calculate_max_pressure( well_distance: float, injection_temp: float ) -> float: start = timeit.default_timer() if use_olsthoorn_max_pressure: max_pres = 0.2 * 0.1 * input_data.depth * 100000 else: Loading @@ -21,6 +24,7 @@ def calculate_max_pressure( results = calculate_volumetric_flow( props, input_data, pres, well_distance, injection_temp ) print_time(start, "\t\tcalculate volumetric flow: ") if results is None: pres_tol = 1e3 Loading