From 3ead530c0a1123cae711beb908f313f953bb9f8a Mon Sep 17 00:00:00 2001 From: Jeff Bourdier Date: Thu, 1 Aug 2024 17:02:13 -0500 Subject: [PATCH 1/2] Output SUTRA pump efficiency as percentage (issue 95) --- src/geophires_x/SUTRAOutputs.py | 2 +- src/geophires_x/SurfacePlant.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/geophires_x/SUTRAOutputs.py b/src/geophires_x/SUTRAOutputs.py index 023adea3..46e70359 100644 --- a/src/geophires_x/SUTRAOutputs.py +++ b/src/geophires_x/SUTRAOutputs.py @@ -156,7 +156,7 @@ def PrintOutputs(self, model: Model): f.write(f" Well Depth: {model.reserv.depth.value:10.1f} " + model.reserv.depth.CurrentUnits.value + NL) pump_efficiency_display_unit = model.surfaceplant.pump_efficiency.CurrentUnits.value - pump_efficiency_display = f'{model.surfaceplant.pump_efficiency.value:10.1f} {pump_efficiency_display_unit}' + pump_efficiency_display = f'{model.surfaceplant.pump_efficiency.value * 100:10.1f} {pump_efficiency_display_unit}' f.write(f' Pump efficiency: {pump_efficiency_display}{NL}') f.write(f" Lifetime Average Well Flow Rate: {np.average(abs(model.wellbores.ProductionWellFlowRates.value)):10.1f} " + model.wellbores.ProductionWellFlowRates.CurrentUnits.value + NL) diff --git a/src/geophires_x/SurfacePlant.py b/src/geophires_x/SurfacePlant.py index c5e7936b..db8eef68 100644 --- a/src/geophires_x/SurfacePlant.py +++ b/src/geophires_x/SurfacePlant.py @@ -255,7 +255,7 @@ def __init__(self, model: Model): Min=0.1, Max=1.0, UnitType=Units.PERCENT, - PreferredUnits=PercentUnit.TENTH, + PreferredUnits=PercentUnit.PERCENT, CurrentUnits=PercentUnit.TENTH, Required=True, ErrMessage="assume default circulation pump efficiency (0.75)", From bab3d1d0c702ad8c899ad37e3e76b64819e9a380 Mon Sep 17 00:00:00 2001 From: Jeff Bourdier Date: Mon, 23 Sep 2024 16:51:29 -0500 Subject: [PATCH 2/2] No longer setting CurrentUnits = PreferredUnits (issue 95) --- src/geophires_x/Economics.py | 3 --- src/geophires_x/Outputs.py | 2 +- src/geophires_x/Parameter.py | 5 ++-- src/geophires_x/SUTRAOutputs.py | 27 ++++++++++--------- src/geophires_x/SurfacePlant.py | 4 --- src/geophires_x/WellBores.py | 3 --- tests/examples/Fervo_Norbeck_Latimer_2023.txt | 2 +- 7 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/geophires_x/Economics.py b/src/geophires_x/Economics.py index 562c7ac6..5bedc888 100644 --- a/src/geophires_x/Economics.py +++ b/src/geophires_x/Economics.py @@ -1847,9 +1847,6 @@ def read_parameters(self, model: Model) -> None: key = ParameterToModify.Name.strip() if key in model.InputParameters: ParameterReadIn = model.InputParameters[key] - # Before we change the parameter, let's assume that the unit preferences will match - # - if they don't, the later code will fix this. - ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits # this should handle all the non-special cases ReadParameter(ParameterReadIn, ParameterToModify, model) diff --git a/src/geophires_x/Outputs.py b/src/geophires_x/Outputs.py index 80a1f547..5d033a76 100644 --- a/src/geophires_x/Outputs.py +++ b/src/geophires_x/Outputs.py @@ -1653,7 +1653,7 @@ def PrintOutputs(self, model: Model): f.write(f' Number of Injection Wells: {model.wellbores.ninj.value:10.0f}' + NL) f.write(f' Well depth (or total length, if not vertical): {model.reserv.depth.value:10.1f} ' + model.reserv.depth.CurrentUnits.value + NL) f.write(f' Water loss rate: {model.reserv.waterloss.value*100:10.1f} ' + model.reserv.waterloss.CurrentUnits.value + NL) - f.write(f' Pump efficiency: {model.surfaceplant.pump_efficiency.value * 100:10.1f} ' + model.surfaceplant.pump_efficiency.CurrentUnits.value + NL) + f.write(f' Pump efficiency: {model.surfaceplant.pump_efficiency.value:10.1f} ' + model.surfaceplant.pump_efficiency.CurrentUnits.value + NL) f.write(f' Injection temperature: {model.wellbores.Tinj.value:10.1f} ' + model.wellbores.Tinj.CurrentUnits.value + NL) if model.wellbores.rameyoptionprod.value: f.write(' Production Wellbore heat transmission calculated with Ramey\'s model\n') diff --git a/src/geophires_x/Parameter.py b/src/geophires_x/Parameter.py index ded67d61..85c417f0 100644 --- a/src/geophires_x/Parameter.py +++ b/src/geophires_x/Parameter.py @@ -288,8 +288,9 @@ def ReadParameter(ParameterReadIn: ParameterEntry, ParamToModify, model): if len(new_str) > 0: ParameterReadIn.sValue = new_str else: - # The value came in without any units, so it must be using the default PreferredUnits - ParamToModify.CurrentUnits = ParamToModify.PreferredUnits + # TODO: determine proper action in this case (previously assumed value + # must be using default PreferredUnits, but this led to problems) + model.logger.info('value came in without any units') def default_parameter_value_message(new_val: Any, param_to_modify_name: str, default_value: Any) -> str: return ( diff --git a/src/geophires_x/SUTRAOutputs.py b/src/geophires_x/SUTRAOutputs.py index 46e70359..d7cb8544 100644 --- a/src/geophires_x/SUTRAOutputs.py +++ b/src/geophires_x/SUTRAOutputs.py @@ -5,7 +5,7 @@ import geophires_x import numpy as np import geophires_x.Model as Model -from .Parameter import LookupUnits +from .Parameter import ConvertUnitsBack, ConvertOutputUnits, LookupUnits from .OptionList import EconomicModel NL="\n" @@ -89,10 +89,10 @@ def PrintOutputs(self, model: Model): # to the units that the user entered the data in # We do this because the value may be displayed in the output, and we want the user to recognize their value, # not some converted value - # for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]: - # for key in obj.ParameterDict: - # param = obj.ParameterDict[key] - # if not param.UnitsMatch: ConvertUnitsBack(param, model) + for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]: + for key in obj.ParameterDict: + param = obj.ParameterDict[key] + if not param.UnitsMatch: ConvertUnitsBack(param, model) # now we need to loop through all thw output parameters to update their units to # whatever units the user has specified. @@ -100,11 +100,14 @@ def PrintOutputs(self, model: Model): # from whatever LENGTH unit they are to feet. # same for all the other classes of units (TEMPERATURE, DENSITY, etc). - #for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]: - # for key in obj.OutputParameterDict: - # if key in self.ParameterDict: - # if self.ParameterDict[key] != obj.OutputParameterDict[key].CurrentUnits: - # ConvertOutputUnits(obj.OutputParameterDict[key], self.ParameterDict[key], model) + for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]: + for key in obj.OutputParameterDict: + output_param:OutputParameter = obj.OutputParameterDict[key] + if key in self.ParameterDict: + if self.ParameterDict[key] != output_param.CurrentUnits: + ConvertOutputUnits(output_param, self.ParameterDict[key], model) + elif not output_param.UnitsMatch: + obj.OutputParameterDict[key] = output_param.with_preferred_units() # write results to output file and screen @@ -142,7 +145,7 @@ def PrintOutputs(self, model: Model): f.write(f" Fixed Charge Rate (FCR): {model.economics.FCR.value*100.0:10.2f} " + model.economics.FCR.CurrentUnits.value + NL) elif model.economics.econmodel.value == EconomicModel.STANDARDIZED_LEVELIZED_COST: f.write(" Economic Model = " + model.economics.econmodel.value.value + NL) - f.write(f" Interest Rate: {model.economics.discountrate.value*100.0:10.2f} " + model.economics.discountrate.PreferredUnits.value + NL) + f.write(f" Interest Rate: {model.economics.discountrate.value:10.2f} " + model.economics.discountrate.PreferredUnits.value + NL) elif model.economics.econmodel.value == EconomicModel.BICYCLE: f.write(" Economic Model = " + model.economics.econmodel.value.value + NL) f.write(f" Accrued financing during construction: {model.economics.inflrateconstruction.value*100:10.2f} " + model.economics.inflrateconstruction.PreferredUnits.value + NL) @@ -156,7 +159,7 @@ def PrintOutputs(self, model: Model): f.write(f" Well Depth: {model.reserv.depth.value:10.1f} " + model.reserv.depth.CurrentUnits.value + NL) pump_efficiency_display_unit = model.surfaceplant.pump_efficiency.CurrentUnits.value - pump_efficiency_display = f'{model.surfaceplant.pump_efficiency.value * 100:10.1f} {pump_efficiency_display_unit}' + pump_efficiency_display = f'{model.surfaceplant.pump_efficiency.value:10.1f} {pump_efficiency_display_unit}' f.write(f' Pump efficiency: {pump_efficiency_display}{NL}') f.write(f" Lifetime Average Well Flow Rate: {np.average(abs(model.wellbores.ProductionWellFlowRates.value)):10.1f} " + model.wellbores.ProductionWellFlowRates.CurrentUnits.value + NL) diff --git a/src/geophires_x/SurfacePlant.py b/src/geophires_x/SurfacePlant.py index 0888f5ee..ea5ed0d8 100644 --- a/src/geophires_x/SurfacePlant.py +++ b/src/geophires_x/SurfacePlant.py @@ -507,9 +507,6 @@ def read_parameters(self, model:Model) -> None: key = ParameterToModify.Name.strip() if key in model.InputParameters: ParameterReadIn = model.InputParameters[key] - # Before we change the parameter, let's assume that the unit preferences will match - - # if they don't, the later code will fix this. - ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits # this should handle all the non-special cases ReadParameter(ParameterReadIn, ParameterToModify, model) @@ -519,7 +516,6 @@ def read_parameters(self, model:Model) -> None: ParameterToModify.value = end_use_option if end_use_option == EndUseOptions.HEAT: self.plant_type.value = PlantType.INDUSTRIAL - elif ParameterToModify.Name == 'Power Plant Type': ParameterToModify.value = PlantType.from_input_string(ParameterReadIn.sValue) if self.enduse_option.value == EndUseOptions.ELECTRICITY: diff --git a/src/geophires_x/WellBores.py b/src/geophires_x/WellBores.py index 80f9b928..1053bc35 100644 --- a/src/geophires_x/WellBores.py +++ b/src/geophires_x/WellBores.py @@ -1136,9 +1136,6 @@ def read_parameters(self, model: Model) -> None: key = ParameterToModify.Name.strip() if key in model.InputParameters: ParameterReadIn = model.InputParameters[key] - # Before we change the parameter, let's assume that the unit preferences will match - # - if they don't, the later code will fix this. - ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits ReadParameter(ParameterReadIn, ParameterToModify, model) # this should handle all non-special cases # handle special cases diff --git a/tests/examples/Fervo_Norbeck_Latimer_2023.txt b/tests/examples/Fervo_Norbeck_Latimer_2023.txt index 2b0309f0..41ca1fd3 100644 --- a/tests/examples/Fervo_Norbeck_Latimer_2023.txt +++ b/tests/examples/Fervo_Norbeck_Latimer_2023.txt @@ -37,7 +37,7 @@ Horizontal Well Drilling Cost Correlation, 10, per the drill cost paper - works Production Flow Rate per Well, 41.02, =650 gpm per the paper - per the paper the maximum flow rate was 63 L/s but the range was 550-750 gpm Production Well Diameter, 7, per the paper Injection Well Diameter, 7, per the paper -Well Separation, 365 feet, per the paper +Well Separation, 365 ft, per the paper Injection Temperature, 38 degC, per the paper 75 to 125 degF Injection Wellbore Temperature Gain, 3 Reservoir Impedance, 0.33, per paper, matching pumping power report 500-1000 kW