Skip to content

Commit

Permalink
Merge branch 'NREL:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
softwareengineerprogrammer authored Nov 19, 2024
2 parents 4125bd0 + 3571f07 commit e49c020
Show file tree
Hide file tree
Showing 43 changed files with 448 additions and 395 deletions.
4 changes: 1 addition & 3 deletions src/geophires_x/Economics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1826,9 +1826,7 @@ 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)

Expand Down
4 changes: 1 addition & 3 deletions src/geophires_x/EconomicsS_DAC_GT.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ def read_parameters(self, model: Model) -> None:
key = ParameterToModify.Name.strip()
if key in model.InputParameters:
ParameterReadIn = model.InputParameters[key]
# Before we change the paremater, 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)

Expand Down
5 changes: 1 addition & 4 deletions src/geophires_x/Outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,6 @@ def read_parameters(self, model: Model, default_output_path: Path = None) -> Non
model.logger.info(f'Adjusted {key} path to {ParameterReadIn.sValue} because original value '
f'({original_val}) was not an absolute path.')

# 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)

Expand Down Expand Up @@ -1674,7 +1671,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')
Expand Down
13 changes: 10 additions & 3 deletions src/geophires_x/Parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,12 @@ def ReadParameter(ParameterReadIn: ParameterEntry, ParamToModify, model):
new_str = ConvertUnits(ParamToModify, ParameterReadIn.sValue, 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
#else:
# The value came in without any units
# TODO: determine the proper action in this case
# (previously, it was assumed that the value must be
# using the default PreferredUnits, which was not always
# valid and led to incorrect units in the output)

def default_parameter_value_message(new_val: Any, param_to_modify_name: str, default_value: Any) -> str:
return (
Expand Down Expand Up @@ -831,6 +834,10 @@ def LookupUnits(sUnitText: str):
for item in MyEnum:
if item.value == sUnitText:
return item, uType

# No match was found with the unit text string, so try with the canonical symbol (if different).
symbol = _ureg.get_symbol(sUnitText)
if symbol != sUnitText: return LookupUnits(symbol)
return None, None


Expand Down
3 changes: 0 additions & 3 deletions src/geophires_x/Reservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,9 @@ def read_parameters(self, model: Model) -> None:
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.
# TODO: refactor GEOPHIRES such that parameters are read in immutably and only accessed with
# explicit units, with conversion only occurring in the getter as necessary

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

# handle special cases
Expand Down
3 changes: 0 additions & 3 deletions src/geophires_x/SBTReservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,9 @@ def read_parameters(self, model: Model) -> None:
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.
# TODO: refactor GEOPHIRES such that parameters are read in immutably and only accessed with
# explicit units, with conversion only occurring in the getter as necessary

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

# handle special cases
Expand Down
4 changes: 1 addition & 3 deletions src/geophires_x/SUTRAEconomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,7 @@ 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)

Expand Down
3 changes: 0 additions & 3 deletions src/geophires_x/SUTRAWellBores.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,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
Expand Down
7 changes: 2 additions & 5 deletions src/geophires_x/SurfacePlant.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,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)",
Expand Down Expand Up @@ -551,9 +551,7 @@ 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)

Expand All @@ -563,7 +561,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:
Expand Down
3 changes: 0 additions & 3 deletions src/geophires_x/WellBores.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,9 +1254,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
Expand Down
3 changes: 0 additions & 3 deletions src/hip_ra/HIP_RA.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,6 @@ def read_parameters(self) -> None:
key = ParameterToModify.Name.strip()
if key in self.InputParameters:
ParameterReadIn = self.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, self
) # this should handle all the non-special cases
Expand Down
4 changes: 1 addition & 3 deletions src/hip_ra_x/hip_ra_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,7 @@ def read_parameters(self) -> None:
key = ParameterToModify.Name.strip()
if key in self.InputParameters:
ParameterReadIn = self.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, self)
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/example1_addons.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ENGINEERING PARAMETERS,Number of Production Wells,,2,count
ENGINEERING PARAMETERS,Number of Injection Wells,,2,count
ENGINEERING PARAMETERS,"Well depth (or total length\, if not vertical)",,3.0,kilometer
ENGINEERING PARAMETERS,Water loss rate,,2.0,
ENGINEERING PARAMETERS,Pump efficiency,,80.0,
ENGINEERING PARAMETERS,Pump efficiency,,80.0,%
ENGINEERING PARAMETERS,Injection temperature,,50.0,degC
ENGINEERING PARAMETERS,Average production well temperature drop,,3.0,degC
ENGINEERING PARAMETERS,Flowrate per production well,,55.0,kg/sec
Expand Down Expand Up @@ -97,7 +97,7 @@ SURFACE EQUIPMENT SIMULATION RESULTS,Average Annual Total Electricity Generation
SURFACE EQUIPMENT SIMULATION RESULTS,Average Annual Net Electricity Generation,,42.3,GWh
SURFACE EQUIPMENT SIMULATION RESULTS,Average Pumping Power,,0.2,MW
SURFACE EQUIPMENT SIMULATION RESULTS,Initial pumping power/net installed power,,3.82,%
Simulation Metadata,GEOPHIRES Version,,3.6.0,
Simulation Metadata,GEOPHIRES Version,,3.6.3,
POWER GENERATION PROFILE,THERMAL DRAWDOWN,1,1.0,
POWER GENERATION PROFILE,THERMAL DRAWDOWN,2,1.0056,
POWER GENERATION PROFILE,THERMAL DRAWDOWN,3,1.0073,
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/Fervo_Norbeck_Latimer_2023.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
Simulation Date: 2024-10-15
Simulation Time: 13:08
Calculation Time: 0.447 sec
GEOPHIRES Version: 3.6.3
Simulation Date: 2024-11-18
Simulation Time: 16:48
Calculation Time: 1.672 sec

***SUMMARY OF RESULTS***

Expand Down Expand Up @@ -40,7 +40,7 @@ Simulation Metadata
Number of Injection Wells: 1
Well depth (or total length, if not vertical): 2.3 kilometer
Water loss rate: 10.0
Pump efficiency: 80.0
Pump efficiency: 80.0 %
Injection temperature: 41.0 degC
Production Wellbore heat transmission calculated with Ramey's model
Average production well temperature drop: 4.1 degC
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/Fervo_Project_Cape-2.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
Simulation Date: 2024-10-15
Simulation Time: 13:08
Calculation Time: 0.662 sec
GEOPHIRES Version: 3.6.3
Simulation Date: 2024-11-18
Simulation Time: 16:56
Calculation Time: 2.730 sec

***SUMMARY OF RESULTS***

Expand Down Expand Up @@ -40,7 +40,7 @@ Simulation Metadata
Number of Injection Wells: 2
Well depth (or total length, if not vertical): 2.6 kilometer
Water loss rate: 2.0
Pump efficiency: 80.0
Pump efficiency: 80.0 %
Injection temperature: 56.7 degC
Production Wellbore heat transmission calculated with Ramey's model
Average production well temperature drop: 2.3 degC
Expand Down
8 changes: 4 additions & 4 deletions tests/examples/Fervo_Project_Cape-3.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.4
Simulation Date: 2024-11-13
Simulation Time: 10:52
Calculation Time: 0.863 sec
Simulation Date: 2024-11-18
Simulation Time: 19:49
Calculation Time: 3.484 sec

***SUMMARY OF RESULTS***

Expand Down Expand Up @@ -40,7 +40,7 @@ Simulation Metadata
Number of Injection Wells: 39
Well depth (or total length, if not vertical): 2.6 kilometer
Water loss rate: 5.0
Pump efficiency: 80.0
Pump efficiency: 80.0 %
Injection temperature: 56.7 degC
Production Wellbore heat transmission calculated with Ramey's model
Average production well temperature drop: 1.7 degC
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/Fervo_Project_Cape.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Simulation Metadata
----------------------
GEOPHIRES Version: 3.6.0
Simulation Date: 2024-10-15
Simulation Time: 13:08
Calculation Time: 0.657 sec
GEOPHIRES Version: 3.6.3
Simulation Date: 2024-11-18
Simulation Time: 16:54
Calculation Time: 3.061 sec

***SUMMARY OF RESULTS***

Expand Down Expand Up @@ -40,7 +40,7 @@ Simulation Metadata
Number of Injection Wells: 12
Well depth (or total length, if not vertical): 2.6 kilometer
Water loss rate: 2.0
Pump efficiency: 80.0
Pump efficiency: 80.0 %
Injection temperature: 56.2 degC
Production Wellbore heat transmission calculated with Ramey's model
Average production well temperature drop: 1.9 degC
Expand Down
Loading

0 comments on commit e49c020

Please sign in to comment.