Skip to content

Commit 3571f07

Browse files
authored
Merge pull request NREL#310 from jeffbourdier/fix-pump-efficiency-units
Fix pump efficiency units
2 parents b3b682d + 9029e02 commit 3571f07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+448
-395
lines changed

src/geophires_x/Economics.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,9 +1826,7 @@ def read_parameters(self, model: Model) -> None:
18261826
key = ParameterToModify.Name.strip()
18271827
if key in model.InputParameters:
18281828
ParameterReadIn = model.InputParameters[key]
1829-
# Before we change the parameter, let's assume that the unit preferences will match
1830-
# - if they don't, the later code will fix this.
1831-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
1829+
18321830
# this should handle all the non-special cases
18331831
ReadParameter(ParameterReadIn, ParameterToModify, model)
18341832

src/geophires_x/EconomicsS_DAC_GT.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,7 @@ def read_parameters(self, model: Model) -> None:
366366
key = ParameterToModify.Name.strip()
367367
if key in model.InputParameters:
368368
ParameterReadIn = model.InputParameters[key]
369-
# Before we change the paremater, let's assume that the unit preferences will match -
370-
# if they don't, the later code will fix this.
371-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
369+
372370
# this should handle all the non-special cases
373371
ReadParameter(ParameterReadIn, ParameterToModify, model)
374372

src/geophires_x/Outputs.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,6 @@ def read_parameters(self, model: Model, default_output_path: Path = None) -> Non
721721
model.logger.info(f'Adjusted {key} path to {ParameterReadIn.sValue} because original value '
722722
f'({original_val}) was not an absolute path.')
723723

724-
# Before we change the parameter, let's assume that the unit preferences will match
725-
# - if they don't, the later code will fix this.
726-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
727724
# this should handle all the non-special cases
728725
ReadParameter(ParameterReadIn, ParameterToModify, model)
729726

@@ -1674,7 +1671,7 @@ def PrintOutputs(self, model: Model):
16741671
f.write(f' Number of Injection Wells: {model.wellbores.ninj.value:10.0f}' + NL)
16751672
f.write(f' Well depth (or total length, if not vertical): {model.reserv.depth.value:10.1f} ' + model.reserv.depth.CurrentUnits.value + NL)
16761673
f.write(f' Water loss rate: {model.reserv.waterloss.value*100:10.1f} ' + model.reserv.waterloss.CurrentUnits.value + NL)
1677-
f.write(f' Pump efficiency: {model.surfaceplant.pump_efficiency.value * 100:10.1f} ' + model.surfaceplant.pump_efficiency.CurrentUnits.value + NL)
1674+
f.write(f' Pump efficiency: {model.surfaceplant.pump_efficiency.value:10.1f} ' + model.surfaceplant.pump_efficiency.CurrentUnits.value + NL)
16781675
f.write(f' Injection temperature: {model.wellbores.Tinj.value:10.1f} ' + model.wellbores.Tinj.CurrentUnits.value + NL)
16791676
if model.wellbores.rameyoptionprod.value:
16801677
f.write(' Production Wellbore heat transmission calculated with Ramey\'s model\n')

src/geophires_x/Parameter.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,12 @@ def ReadParameter(ParameterReadIn: ParameterEntry, ParamToModify, model):
289289
new_str = ConvertUnits(ParamToModify, ParameterReadIn.sValue, model)
290290
if len(new_str) > 0:
291291
ParameterReadIn.sValue = new_str
292-
else:
293-
# The value came in without any units, so it must be using the default PreferredUnits
294-
ParamToModify.CurrentUnits = ParamToModify.PreferredUnits
292+
#else:
293+
# The value came in without any units
294+
# TODO: determine the proper action in this case
295+
# (previously, it was assumed that the value must be
296+
# using the default PreferredUnits, which was not always
297+
# valid and led to incorrect units in the output)
295298

296299
def default_parameter_value_message(new_val: Any, param_to_modify_name: str, default_value: Any) -> str:
297300
return (
@@ -831,6 +834,10 @@ def LookupUnits(sUnitText: str):
831834
for item in MyEnum:
832835
if item.value == sUnitText:
833836
return item, uType
837+
838+
# No match was found with the unit text string, so try with the canonical symbol (if different).
839+
symbol = _ureg.get_symbol(sUnitText)
840+
if symbol != sUnitText: return LookupUnits(symbol)
834841
return None, None
835842

836843

src/geophires_x/Reservoir.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,9 @@ def read_parameters(self, model: Model) -> None:
549549
if key in model.InputParameters:
550550
ParameterReadIn = model.InputParameters[key]
551551

552-
# Before we change the parameter, let's assume that the unit preferences will match -
553-
# if they don't, the later code will fix this.
554552
# TODO: refactor GEOPHIRES such that parameters are read in immutably and only accessed with
555553
# explicit units, with conversion only occurring in the getter as necessary
556554

557-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
558555
ReadParameter(ParameterReadIn, ParameterToModify, model) # this handles all non-special cases
559556

560557
# handle special cases

src/geophires_x/SBTReservoir.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,9 @@ def read_parameters(self, model: Model) -> None:
326326
if key in model.InputParameters:
327327
ParameterReadIn = model.InputParameters[key]
328328

329-
# Before we change the parameter, let's assume that the unit preferences will match -
330-
# if they don't, the later code will fix this.
331329
# TODO: refactor GEOPHIRES such that parameters are read in immutably and only accessed with
332330
# explicit units, with conversion only occurring in the getter as necessary
333331

334-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
335332
ReadParameter(ParameterReadIn, ParameterToModify, model) # this handles all non-special cases
336333

337334
# handle special cases

src/geophires_x/SUTRAEconomics.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,7 @@ def read_parameters(self, model: Model) -> None:
316316
key = ParameterToModify.Name.strip()
317317
if key in model.InputParameters:
318318
ParameterReadIn = model.InputParameters[key]
319-
# Before we change the parameter, let's assume that the unit preferences will match
320-
# - if they don't, the later code will fix this.
321-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
319+
322320
# this should handle all the non-special cases
323321
ReadParameter(ParameterReadIn, ParameterToModify, model)
324322

src/geophires_x/SUTRAWellBores.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,6 @@ def read_parameters(self, model: Model) -> None:
215215
key = ParameterToModify.Name.strip()
216216
if key in model.InputParameters:
217217
ParameterReadIn = model.InputParameters[key]
218-
# Before we change the parameter, let's assume that the unit preferences will match
219-
# - if they don't, the later code will fix this.
220-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
221218
ReadParameter(ParameterReadIn, ParameterToModify, model) # this should handle all non-special cases
222219

223220
# handle special cases

src/geophires_x/SurfacePlant.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def __init__(self, model: Model):
258258
Min=0.1,
259259
Max=1.0,
260260
UnitType=Units.PERCENT,
261-
PreferredUnits=PercentUnit.TENTH,
261+
PreferredUnits=PercentUnit.PERCENT,
262262
CurrentUnits=PercentUnit.TENTH,
263263
Required=True,
264264
ErrMessage="assume default circulation pump efficiency (0.75)",
@@ -551,9 +551,7 @@ def read_parameters(self, model:Model) -> None:
551551
key = ParameterToModify.Name.strip()
552552
if key in model.InputParameters:
553553
ParameterReadIn = model.InputParameters[key]
554-
# Before we change the parameter, let's assume that the unit preferences will match -
555-
# if they don't, the later code will fix this.
556-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
554+
557555
# this should handle all the non-special cases
558556
ReadParameter(ParameterReadIn, ParameterToModify, model)
559557

@@ -563,7 +561,6 @@ def read_parameters(self, model:Model) -> None:
563561
ParameterToModify.value = end_use_option
564562
if end_use_option == EndUseOptions.HEAT:
565563
self.plant_type.value = PlantType.INDUSTRIAL
566-
567564
elif ParameterToModify.Name == 'Power Plant Type':
568565
ParameterToModify.value = PlantType.from_input_string(ParameterReadIn.sValue)
569566
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
@@ -1254,9 +1254,6 @@ def read_parameters(self, model: Model) -> None:
12541254
key = ParameterToModify.Name.strip()
12551255
if key in model.InputParameters:
12561256
ParameterReadIn = model.InputParameters[key]
1257-
# Before we change the parameter, let's assume that the unit preferences will match
1258-
# - if they don't, the later code will fix this.
1259-
ParameterToModify.CurrentUnits = ParameterToModify.PreferredUnits
12601257
ReadParameter(ParameterReadIn, ParameterToModify, model) # this should handle all non-special cases
12611258

12621259
# handle special cases

0 commit comments

Comments
 (0)