Skip to content

Commit bab3d1d

Browse files
committed
No longer setting CurrentUnits = PreferredUnits (issue 95)
1 parent 9076e2f commit bab3d1d

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed

src/geophires_x/Economics.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,9 +1847,6 @@ def read_parameters(self, model: Model) -> None:
18471847
key = ParameterToModify.Name.strip()
18481848
if key in model.InputParameters:
18491849
ParameterReadIn = model.InputParameters[key]
1850-
# Before we change the parameter, let's assume that the unit preferences will match
1851-
# - if they don't, the later code will fix this.
1852-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
18531850
# this should handle all the non-special cases
18541851
ReadParameter(ParameterReadIn, ParameterToModify, model)
18551852

src/geophires_x/Outputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ def PrintOutputs(self, model: Model):
16531653
f.write(f' Number of Injection Wells: {model.wellbores.ninj.value:10.0f}' + NL)
16541654
f.write(f' Well depth (or total length, if not vertical): {model.reserv.depth.value:10.1f} ' + model.reserv.depth.CurrentUnits.value + NL)
16551655
f.write(f' Water loss rate: {model.reserv.waterloss.value*100:10.1f} ' + model.reserv.waterloss.CurrentUnits.value + NL)
1656-
f.write(f' Pump efficiency: {model.surfaceplant.pump_efficiency.value * 100:10.1f} ' + model.surfaceplant.pump_efficiency.CurrentUnits.value + NL)
1656+
f.write(f' Pump efficiency: {model.surfaceplant.pump_efficiency.value:10.1f} ' + model.surfaceplant.pump_efficiency.CurrentUnits.value + NL)
16571657
f.write(f' Injection temperature: {model.wellbores.Tinj.value:10.1f} ' + model.wellbores.Tinj.CurrentUnits.value + NL)
16581658
if model.wellbores.rameyoptionprod.value:
16591659
f.write(' Production Wellbore heat transmission calculated with Ramey\'s model\n')

src/geophires_x/Parameter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ def ReadParameter(ParameterReadIn: ParameterEntry, ParamToModify, model):
288288
if len(new_str) > 0:
289289
ParameterReadIn.sValue = new_str
290290
else:
291-
# The value came in without any units, so it must be using the default PreferredUnits
292-
ParamToModify.CurrentUnits = ParamToModify.PreferredUnits
291+
# TODO: determine proper action in this case (previously assumed value
292+
# must be using default PreferredUnits, but this led to problems)
293+
model.logger.info('value came in without any units')
293294

294295
def default_parameter_value_message(new_val: Any, param_to_modify_name: str, default_value: Any) -> str:
295296
return (

src/geophires_x/SUTRAOutputs.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import geophires_x
66
import numpy as np
77
import geophires_x.Model as Model
8-
from .Parameter import LookupUnits
8+
from .Parameter import ConvertUnitsBack, ConvertOutputUnits, LookupUnits
99
from .OptionList import EconomicModel
1010

1111
NL="\n"
@@ -89,22 +89,25 @@ def PrintOutputs(self, model: Model):
8989
# to the units that the user entered the data in
9090
# We do this because the value may be displayed in the output, and we want the user to recognize their value,
9191
# not some converted value
92-
# for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]:
93-
# for key in obj.ParameterDict:
94-
# param = obj.ParameterDict[key]
95-
# if not param.UnitsMatch: ConvertUnitsBack(param, model)
92+
for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]:
93+
for key in obj.ParameterDict:
94+
param = obj.ParameterDict[key]
95+
if not param.UnitsMatch: ConvertUnitsBack(param, model)
9696

9797
# now we need to loop through all thw output parameters to update their units to
9898
# whatever units the user has specified.
9999
# i.e., they may have specified that all LENGTH results must be in feet, so we need to convert those
100100
# from whatever LENGTH unit they are to feet.
101101
# same for all the other classes of units (TEMPERATURE, DENSITY, etc).
102102

103-
#for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]:
104-
# for key in obj.OutputParameterDict:
105-
# if key in self.ParameterDict:
106-
# if self.ParameterDict[key] != obj.OutputParameterDict[key].CurrentUnits:
107-
# ConvertOutputUnits(obj.OutputParameterDict[key], self.ParameterDict[key], model)
103+
for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]:
104+
for key in obj.OutputParameterDict:
105+
output_param:OutputParameter = obj.OutputParameterDict[key]
106+
if key in self.ParameterDict:
107+
if self.ParameterDict[key] != output_param.CurrentUnits:
108+
ConvertOutputUnits(output_param, self.ParameterDict[key], model)
109+
elif not output_param.UnitsMatch:
110+
obj.OutputParameterDict[key] = output_param.with_preferred_units()
108111

109112
# write results to output file and screen
110113

@@ -142,7 +145,7 @@ def PrintOutputs(self, model: Model):
142145
f.write(f" Fixed Charge Rate (FCR): {model.economics.FCR.value*100.0:10.2f} " + model.economics.FCR.CurrentUnits.value + NL)
143146
elif model.economics.econmodel.value == EconomicModel.STANDARDIZED_LEVELIZED_COST:
144147
f.write(" Economic Model = " + model.economics.econmodel.value.value + NL)
145-
f.write(f" Interest Rate: {model.economics.discountrate.value*100.0:10.2f} " + model.economics.discountrate.PreferredUnits.value + NL)
148+
f.write(f" Interest Rate: {model.economics.discountrate.value:10.2f} " + model.economics.discountrate.PreferredUnits.value + NL)
146149
elif model.economics.econmodel.value == EconomicModel.BICYCLE:
147150
f.write(" Economic Model = " + model.economics.econmodel.value.value + NL)
148151
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):
156159
f.write(f" Well Depth: {model.reserv.depth.value:10.1f} " + model.reserv.depth.CurrentUnits.value + NL)
157160

158161
pump_efficiency_display_unit = model.surfaceplant.pump_efficiency.CurrentUnits.value
159-
pump_efficiency_display = f'{model.surfaceplant.pump_efficiency.value * 100:10.1f} {pump_efficiency_display_unit}'
162+
pump_efficiency_display = f'{model.surfaceplant.pump_efficiency.value:10.1f} {pump_efficiency_display_unit}'
160163
f.write(f' Pump efficiency: {pump_efficiency_display}{NL}')
161164

162165
f.write(f" Lifetime Average Well Flow Rate: {np.average(abs(model.wellbores.ProductionWellFlowRates.value)):10.1f} " + model.wellbores.ProductionWellFlowRates.CurrentUnits.value + NL)

src/geophires_x/SurfacePlant.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,6 @@ def read_parameters(self, model:Model) -> None:
507507
key = ParameterToModify.Name.strip()
508508
if key in model.InputParameters:
509509
ParameterReadIn = model.InputParameters[key]
510-
# Before we change the parameter, let's assume that the unit preferences will match -
511-
# if they don't, the later code will fix this.
512-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
513510
# this should handle all the non-special cases
514511
ReadParameter(ParameterReadIn, ParameterToModify, model)
515512

@@ -519,7 +516,6 @@ def read_parameters(self, model:Model) -> None:
519516
ParameterToModify.value = end_use_option
520517
if end_use_option == EndUseOptions.HEAT:
521518
self.plant_type.value = PlantType.INDUSTRIAL
522-
523519
elif ParameterToModify.Name == 'Power Plant Type':
524520
ParameterToModify.value = PlantType.from_input_string(ParameterReadIn.sValue)
525521
if self.enduse_option.value == EndUseOptions.ELECTRICITY:

src/geophires_x/WellBores.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,9 +1136,6 @@ def read_parameters(self, model: Model) -> None:
11361136
key = ParameterToModify.Name.strip()
11371137
if key in model.InputParameters:
11381138
ParameterReadIn = model.InputParameters[key]
1139-
# Before we change the parameter, let's assume that the unit preferences will match
1140-
# - if they don't, the later code will fix this.
1141-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
11421139
ReadParameter(ParameterReadIn, ParameterToModify, model) # this should handle all non-special cases
11431140

11441141
# handle special cases

tests/examples/Fervo_Norbeck_Latimer_2023.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Horizontal Well Drilling Cost Correlation, 10, per the drill cost paper - works
3737
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
3838
Production Well Diameter, 7, per the paper
3939
Injection Well Diameter, 7, per the paper
40-
Well Separation, 365 feet, per the paper
40+
Well Separation, 365 ft, per the paper
4141
Injection Temperature, 38 degC, per the paper 75 to 125 degF
4242
Injection Wellbore Temperature Gain, 3
4343
Reservoir Impedance, 0.33, per paper, matching pumping power report 500-1000 kW

0 commit comments

Comments
 (0)