Skip to content

Commit

Permalink
No longer setting CurrentUnits = PreferredUnits (issue 95)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbourdier committed Nov 10, 2024
1 parent 5d0cd69 commit 79b3b67
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 51 deletions.
4 changes: 1 addition & 3 deletions src/geophires_x/Economics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1822,9 +1822,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
9 changes: 6 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
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
6 changes: 3 additions & 3 deletions tests/examples/Fervo_Norbeck_Latimer_2023.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Reservoir Model, 1
Reservoir Volume Option, 1,
Reservoir Density, 2800, per the paper phyllite + quartzite + diorite + granodiorite,
Reservoir Depth, 7700 feet, per the paper
Reservoir Depth, 7700 ft, per the paper
Reservoir Heat Capacity, 1000
Reservoir Thermal Conductivity, 2.7
Number of Fractures, 100, per the paper
Expand All @@ -31,13 +31,13 @@ Well Geometry Configuration, 4
Has Nonvertical Section, True
Multilaterals Cased, True
Number of Multilateral Sections, 2, Two parallel horizontal sections
Nonvertical Length per Multilateral Section, 3250 feet, per the paper
Nonvertical Length per Multilateral Section, 3250 ft, per the paper
Well Drilling Cost Correlation, 10, per the drill cost paper - works out to $400/ft
Horizontal Well Drilling Cost Correlation, 10, per the drill cost paper - works out to $400/ft
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
Expand Down
6 changes: 3 additions & 3 deletions tests/examples/Fervo_Project_Cape-2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Reservoir Model, 1
Reservoir Volume Option, 1
Reservoir Density, 2800
Reservoir Depth, 8500 feet, -- https://pangea.stanford.edu/ERE/db/GeoConf/papers/SGW/2024/Fercho.pdf
Reservoir Depth, 8500 ft, -- https://pangea.stanford.edu/ERE/db/GeoConf/papers/SGW/2024/Fercho.pdf
Reservoir Heat Capacity, 790
Reservoir Thermal Conductivity, 3.05
Reservoir Porosity, 0.0118
Expand All @@ -27,7 +27,7 @@ Number of Production Wells, 1
Production Flow Rate per Well, 93
Production Well Diameter, 7
Injection Well Diameter, 7
Well Separation, 365 feet
Well Separation, 365 ft
Injection Temperature, 60 degC
Injection Wellbore Temperature Gain, 3
Plant Outlet Pressure, 1000 psi
Expand Down Expand Up @@ -69,4 +69,4 @@ Well Geometry Configuration, 4
Has Nonvertical Section, True
Multilaterals Cased, True
Number of Multilateral Sections, 3
Nonvertical Length per Multilateral Section, 4700 feet
Nonvertical Length per Multilateral Section, 4700 ft
6 changes: 3 additions & 3 deletions tests/examples/Fervo_Project_Cape-3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Reservoir Model, 1
Reservoir Volume Option, 1
Reservoir Density, 2800
Reservoir Depth, 8500 feet, -- https://pangea.stanford.edu/ERE/db/GeoConf/papers/SGW/2024/Fercho.pdf
Reservoir Depth, 8500 ft, -- https://pangea.stanford.edu/ERE/db/GeoConf/papers/SGW/2024/Fercho.pdf
Reservoir Heat Capacity, 790
Reservoir Thermal Conductivity, 3.05
Reservoir Porosity, 0.0118
Expand All @@ -28,7 +28,7 @@ Number of Production Wells, 39
Production Flow Rate per Well, 120, -- peak flow reported in paper
Production Well Diameter, 7
Injection Well Diameter, 7
Well Separation, 365 feet
Well Separation, 365 ft
Injection Temperature, 60 degC
Injection Wellbore Temperature Gain, 3
Plant Outlet Pressure, 1000 psi
Expand Down Expand Up @@ -69,4 +69,4 @@ Well Geometry Configuration, 4
Has Nonvertical Section, True
Multilaterals Cased, True
Number of Multilateral Sections, 3
Nonvertical Length per Multilateral Section, 4700 feet
Nonvertical Length per Multilateral Section, 4700 ft
6 changes: 3 additions & 3 deletions tests/examples/Fervo_Project_Cape.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Reservoir Model, 1
Reservoir Volume Option, 1
Reservoir Density, 2800
Reservoir Depth, 8500 feet, -- https://pangea.stanford.edu/ERE/db/GeoConf/papers/SGW/2024/Fercho.pdf
Reservoir Depth, 8500 ft, -- https://pangea.stanford.edu/ERE/db/GeoConf/papers/SGW/2024/Fercho.pdf
Reservoir Heat Capacity, 1000
Reservoir Thermal Conductivity, 2.7
Number of Fractures, 100
Expand All @@ -21,11 +21,11 @@ Well Geometry Configuration, 4
Has Nonvertical Section, True
Multilaterals Cased, True
Number of Multilateral Sections, 2
Nonvertical Length per Multilateral Section, 5000 feet
Nonvertical Length per Multilateral Section, 5000 ft
Production Flow Rate per Well, 98
Production Well Diameter, 8
Injection Well Diameter, 8
Well Separation, 365 feet
Well Separation, 365 ft
Injection Temperature, 60 degC
Injection Wellbore Temperature Gain, 3
Reservoir Impedance, 0.01
Expand Down

0 comments on commit 79b3b67

Please sign in to comment.