Skip to content

Commit ed16813

Browse files
Merge pull request NREL#123 from softwareengineerprogrammer/main
Increase Maximum Temperature max value to 500℃ (v3.4.3)
2 parents 619e6e4 + 4aaeb38 commit ed16813

File tree

11 files changed

+78
-64
lines changed

11 files changed

+78
-64
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.4.2
2+
current_version = 3.4.3
33
commit = True
44
tag = True
55

.cookiecutterrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ default_context:
5454
sphinx_doctest: "no"
5555
sphinx_theme: "sphinx-py3doc-enhanced-theme"
5656
test_matrix_separate_coverage: "no"
57-
version: 3.4.2
57+
version: 3.4.3
5858
version_manager: "bump2version"
5959
website: "https://github.com/NREL"
6060
year_from: "2023"

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ Free software: `MIT license <LICENSE>`__
4747
:alt: Supported implementations
4848
:target: https://pypi.org/project/geophires-x
4949

50-
.. |commits-since| image:: https://img.shields.io/github/commits-since/NREL/GEOPHIRES-X/v3.4.2.svg
50+
.. |commits-since| image:: https://img.shields.io/github/commits-since/NREL/GEOPHIRES-X/v3.4.3.svg
5151
:alt: Commits since latest release
52-
:target: https://github.com/NREL/GEOPHIRES-X/compare/v3.4.2...main
52+
:target: https://github.com/NREL/GEOPHIRES-X/compare/v3.4.3...main
5353

5454
.. |docs| image:: https://readthedocs.org/projects/GEOPHIRES-X/badge/?style=flat
5555
:target: https://nrel.github.io/GEOPHIRES-X
@@ -150,7 +150,6 @@ Example usage in Python:
150150
"Reservoir Depth": 3,
151151
"Number of Segments": 1,
152152
"Gradient 1": 50,
153-
"Maximum Temperature": 400,
154153
"Number of Production Wells": 2,
155154
"Number of Injection Wells": 2,
156155
"Production Well Diameter": 7,

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
year = '2023'
1919
author = 'NREL'
2020
copyright = f'{year}, {author}'
21-
version = release = '3.4.2'
21+
version = release = '3.4.3'
2222

2323
pygments_style = 'trac'
2424
templates_path = ['./templates']

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def read(*names, **kwargs):
1313

1414
setup(
1515
name='geophires-x',
16-
version='3.4.2',
16+
version='3.4.3',
1717
license='MIT',
1818
description='GEOPHIRES is a free and open-source geothermal techno-economic simulator.',
1919
long_description='{}\n{}'.format(

src/geophires_x/AGSWellBores.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -926,16 +926,15 @@ def Calculate(self, model: Model) -> None:
926926
:type model: :class:`~geophires_x.Model.Model`
927927
:return: None
928928
"""
929-
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)
929+
model.logger.info(f'Init {__class__!s}: {sys._getframe().f_code.co_name}')
930930

931931
self.Tini = model.reserv.Trock.value # initialize the temperature to be the initial temperature of the reservoir
932932
if self.Tini > 375.0 or self.numnonverticalsections.value > 1:
933933
# must be a multilateral setup or too hot for CLGS, so must try to use wanju code.
934934
if self.Tini > 375.0:
935-
model.logger.warning("In AGS, but forced to use Wanju code because initial reservoir temperature \
936-
is too high for CLGS")
937-
print("In AGS, but forced to use Wanju code because initial reservoir temperature \
938-
is too high for CLGS")
935+
msg = 'In AGS, but forced to use Wanju code because initial reservoir temperature is too high for CLGS'
936+
model.logger.warning(msg)
937+
print(f'Warning: {msg}')
939938

940939
# handle special cases for the multilateral calc parameters you added
941940
if self.nonverticalwellborediameter.value > 2.0:
@@ -1104,7 +1103,12 @@ def Calculate(self, model: Model) -> None:
11041103
tot_length, vert_length, horizontal_lengths = self.calculatedrillinglengths(model)
11051104

11061105
# in this case, reserv.depth is just the vertical drill depth
1107-
# FIXME earlier calculations use depth before this value is set, meaning they're using the wrong value
1106+
# TODO earlier calculations use reserv.depth before it is recalculated here; this should be refactored to avoid
1107+
# potential for mix-ups. As of 2024-02-16, calculations correctly account for this on-the-fly change of
1108+
# reserv.depth - see https://github.com/NREL/GEOPHIRES-X/issues/122#issuecomment-194869313 - but this
1109+
# implementation is fragile and prone to introducing bugs in future changes. Ideally, parameters should
1110+
# not be changed once their value has been calculated, and especially not after the first calculated
1111+
# value has been used as an input for other calculations.
11081112
model.reserv.depth.value = model.reserv.InputDepth.quantity().to(model.reserv.depth.CurrentUnits).magnitude
11091113

11101114
# getTandP results must be rejiggered to match wellbores expected output. Once done,

src/geophires_x/Parameter.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ class boolParameter(Parameter):
120120
DefaultValue (bool, True): The default value of that parameter
121121
"""
122122

123-
value: bool = True # FIXME set from DefaultValue
123+
def __post_init__(self):
124+
if self.value is None:
125+
self.value:bool = self.DefaultValue
126+
127+
value: bool = None
124128
DefaultValue: bool = value
125129
json_parameter_type: str = 'boolean'
126130

@@ -137,7 +141,11 @@ class intParameter(Parameter):
137141
AllowableRange (list): A list of the valid values
138142
"""
139143

140-
value: int = 0 # FIXME set from DefaultValue
144+
def __post_init__(self):
145+
if self.value is None:
146+
self.value:int = self.DefaultValue
147+
148+
value: int = None
141149
DefaultValue: int = value
142150
AllowableRange: List[int] = field(default_factory=list)
143151
json_parameter_type: str = 'integer'
@@ -180,8 +188,11 @@ class strParameter(Parameter):
180188
value (str): The value of that parameter
181189
DefaultValue (str, ""): The default value of that parameter
182190
"""
191+
def __post_init__(self):
192+
if self.value is None:
193+
self.value:str = self.DefaultValue
183194

184-
value: str = "" # FIXME set from DefaultValue
195+
value: str = None
185196
DefaultValue: str = value
186197
json_parameter_type: str = 'string'
187198

src/geophires_x/Reservoir.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ def __init__(self, model: Model):
7474

7575
self.Tmax = self.ParameterDict[self.Tmax.Name] = floatParameter(
7676
"Maximum Temperature",
77-
value=400.0,
7877
DefaultValue=400.0,
7978
Min=50,
80-
Max=400,
79+
Max=500,
8180
UnitType=Units.TEMPERATURE,
8281
PreferredUnits=TemperatureUnit.CELSIUS,
8382
CurrentUnits=TemperatureUnit.CELSIUS,

src/geophires_x/SurfacePlant.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ def reinjection_temperature(self, model: Model, ambient_temperature: float, Tent
8989
# check if reinjectemp (model calculated) >= Tinj (user provided)
9090
if np.min(ReinjTemp) < Tinj:
9191
Tinj = np.min(ReinjTemp)
92-
print("Warning: injection temperature lowered")
93-
model.logger.warning("injection temperature lowered")
92+
msg = 'injection temperature lowered'
93+
print(f'Warning: {msg}')
94+
model.logger.warning(msg)
9495
return Tinj, ReinjTemp, etau
9596

9697
def electricity_heat_production(self, enduse_option: EndUseOptions, availability: np.ndarray, etau: np.ndarray, nprod: int,
@@ -205,7 +206,8 @@ def __init__(self, model: Model):
205206
:type model: :class:`~geophires_x.Model.Model`
206207
:return: None
207208
"""
208-
model.logger.info(f"Init {self.__class__.__name__}: {__name__}")
209+
model.logger.info(f'Init {self.__class__.__name__}: {__name__}')
210+
209211
self.Tinj = 0.0
210212

211213
# Set up all the Parameters that will be predefined by this class using the different types of parameter classes.
@@ -475,10 +477,10 @@ def __init__(self, model: Model):
475477
CurrentUnits=PowerUnit.MW
476478
)
477479

478-
model.logger.info(f"Complete {self.__class__.__name__}: {__name__}")
480+
model.logger.info(f'Complete {self.__class__.__name__}: {__name__}')
479481

480482
def __str__(self):
481-
return "SurfacePlant"
483+
return 'SurfacePlant'
482484

483485
def read_parameters(self, model:Model) -> None:
484486
"""
@@ -488,7 +490,7 @@ def read_parameters(self, model:Model) -> None:
488490
:param model: The container class of the application, giving access to everything else, including the logger
489491
:return: None
490492
"""
491-
model.logger.info(f"Init {self.__class__.__name__}: {__name__}")
493+
model.logger.info(f'Init {self.__class__.__name__}: {__name__}')
492494

493495
# Deal with all the parameter values that the user has provided. They should really only provide values that
494496
# they want to change from the default values, but they can provide a value that is already set because it is a
@@ -514,7 +516,7 @@ def read_parameters(self, model:Model) -> None:
514516
ReadParameter(ParameterReadIn, ParameterToModify, model)
515517

516518
# handle special cases
517-
if ParameterToModify.Name == "End-Use Option":
519+
if ParameterToModify.Name == 'End-Use Option':
518520
if ParameterReadIn.sValue == str(1):
519521
ParameterToModify.value = EndUseOptions.ELECTRICITY
520522
elif ParameterReadIn.sValue == str(2):
@@ -533,7 +535,7 @@ def read_parameters(self, model:Model) -> None:
533535
elif ParameterReadIn.sValue == str(52):
534536
ParameterToModify.value = EndUseOptions.COGENERATION_PARALLEL_EXTRA_ELECTRICITY
535537

536-
elif ParameterToModify.Name == "Power Plant Type":
538+
elif ParameterToModify.Name == 'Power Plant Type':
537539
if ParameterReadIn.sValue == str(1):
538540
ParameterToModify.value = PlantType.SUB_CRITICAL_ORC
539541
elif ParameterReadIn.sValue == str(2):
@@ -579,40 +581,38 @@ def read_parameters(self, model:Model) -> None:
579581
if ParameterToModify.value in [PlantType.SINGLE_FLASH, PlantType.DOUBLE_FLASH]:
580582
model.wellbores.impedancemodelallowed.value = False
581583
self.setinjectionpressurefixed = True
582-
elif ParameterToModify.Name == "Plant Outlet Pressure":
584+
elif ParameterToModify.Name == 'Plant Outlet Pressure':
583585
if ParameterToModify.value < 0 or ParameterToModify.value > 10000:
584586
if self.setinjectionpressurefixed:
585587
ParameterToModify.value = 100
586-
print("Warning: Provided plant outlet pressure outside of range 0-10000." +
587-
" GEOPHIRES will assume default plant outlet pressure (100 kPa)")
588-
model.logger.warning("Provided plant outlet pressure outside of range 0-10000." +
589-
" GEOPHIRES will assume default plant outlet pressure (100 kPa)")
588+
msg = f'Provided plant outlet pressure outside of range 0-10000. GEOPHIRES will assume default plant outlet pressure ({ParameterToModify.value} kPa)'
589+
print(f'Warning: {msg}')
590+
model.logger.warning(msg)
590591
else:
591592
self.usebuiltinoutletplantcorrelation.value = True
592-
print("Warning: Provided plant outlet pressure outside of range 0-10000 kPa." +
593-
" GEOPHIRES will calculate plant outlet pressure based on" +
594-
" production wellhead pressure and surface equipment pressure drop of 10 psi")
595-
model.logger.warning("Provided plant outlet pressure outside of range 0-10000 kPa." +
596-
" GEOPHIRES will calculate plant outlet pressure based on" +
597-
" production wellhead pressure and surface equipment pressure drop of 10 psi")
593+
msg = ('Provided plant outlet pressure outside of range 0-10000 kPa. '
594+
'GEOPHIRES will calculate plant outlet pressure based on production '
595+
'wellhead pressure and surface equipment pressure drop of 10 psi')
596+
print(f'Warning: {msg}')
597+
model.logger.warning(msg)
598598
if "Plant Outlet Pressure" not in model.InputParameters:
599599
if self.setinjectionpressurefixed:
600600
self.usebuiltinoutletplantcorrelation.value = False
601601
self.plant_outlet_pressure.value = 100
602-
print("Warning: No valid plant outlet pressure provided." +
603-
" GEOPHIRES will assume default plant outlet pressure (100 kPa)")
604-
model.logger.warning("No valid plant outlet pressure provided." +
605-
" GEOPHIRES will assume default plant outlet pressure (100 kPa)")
602+
msg = (f'No valid plant outlet pressure provided. '
603+
f'GEOPHIRES will assume default plant outlet pressure ({self.plant_outlet_pressure.value} kPa)')
604+
print(f'Warning: {msg}')
605+
model.logger.warning(msg)
606606
else:
607607
self.usebuiltinoutletplantcorrelation.value = True
608-
print("Warning: No valid plant outlet pressure provided. GEOPHIRES will calculate plant outlet" +
609-
" pressure based on production wellhead pressure and surface equipment pressure drop of 10 psi")
610-
model.logger.warning("No valid plant outlet pressure provided. GEOPHIRES will calculate plant outlet" +
611-
" pressure based on production wellhead pressure and surface equipment pressure drop of 10 psi")
608+
msg = (f'No valid plant outlet pressure provided. GEOPHIRES will calculate plant outlet pressure '
609+
f'based on production wellhead pressure and surface equipment pressure drop of 10 psi')
610+
print(f'Warning: {msg}')
611+
model.logger.warning(msg)
612612
else:
613-
model.logger.info("No parameters read because no content provided")
613+
model.logger.info('No parameters read because no content provided')
614614

615-
model.logger.info(f"Complete {self.__class__.__name__}: {__name__}")
615+
model.logger.info(f'Complete {self.__class__.__name__}: {__name__}')
616616

617617
def Calculate(self, model: Model) -> None:
618618
"""
@@ -622,8 +622,8 @@ def Calculate(self, model: Model) -> None:
622622
:type model: :class:`~geophires_x.Model.Model`
623623
:return: Nothing, but it does make calculations and set values in the model
624624
"""
625-
model.logger.info(f"Init {self.__class__.__name__}: {__name__}")
625+
model.logger.info(f'Init {self.__class__.__name__}: {__name__}')
626626

627627
# All calculations are handled in subclasses of this class, so this function is empty.
628628

629-
model.logger.info(f"Complete {self.__class__.__name__}: {__name__}")
629+
model.logger.info(f'Complete {self.__class__.__name__}: {__name__}')

src/geophires_x/WellBores.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -373,32 +373,33 @@ def ProdPressureDropAndPumpingPowerUsingIndexes(
373373
Pprodwellhead = ppwellhead
374374
if Pprodwellhead < Pminimum_kPa:
375375
Pprodwellhead = Pminimum_kPa
376-
msg = ('Provided production wellhead pressure under minimum pressure. '
377-
'GEOPHIRES will assume minimum wellhead pressure')
376+
msg = (f'Provided production wellhead pressure ({Pprodwellhead}kPa) '
377+
f'under minimum pressure ({Pminimum_kPa}kPa). '
378+
f'GEOPHIRES will assume minimum wellhead pressure')
378379

379380
print(f'Warning: {msg}')
380381
model.logger.warning(msg)
381382

382-
PIkPa = PI / 100.0 # convert PI from kg/s/bar to kg/s/kPa
383+
PI_kPa = PI / 100.0 # convert PI from kg/s/bar to kg/s/kPa
383384

384385
# calculate pumping depth
385-
pumpdepth = depth_m + (Pminimum_kPa - Phydrostaticcalc_kPa + wellflowrate / PIkPa) / (
386+
pumpdepth_m = depth_m + (Pminimum_kPa - Phydrostaticcalc_kPa + wellflowrate / PI_kPa) / (
386387
f3 * (rhowaterprod * vprod ** 2 / 2.) * (1 / prodwelldiam) / 1E3 + rhowaterprod * 9.81 / 1E3)
387-
pumpdepthfinal = np.max(pumpdepth)
388-
if pumpdepthfinal < 0.0:
389-
pumpdepthfinal = 0.0
390-
msg = ('GEOPHIRES calculates negative production well pumping depth. '
391-
'No production well pumps will be assumed')
388+
pumpdepthfinal_m = np.max(pumpdepth_m)
389+
if pumpdepthfinal_m < 0.0:
390+
pumpdepthfinal_m = 0.0
391+
msg = (f'GEOPHIRES calculates negative production well pumping depth. ({pumpdepthfinal_m}m)'
392+
f'No production well pumps will be assumed')
392393
print(f'Warning: {msg}')
393394
model.logger.warning(msg)
394-
elif pumpdepthfinal > 600.0:
395-
msg = ('GEOPHIRES calculates production pump depth to be deeper than 600 m. '
396-
'Verify reservoir pressure, production well flow rate and production well dimensions')
395+
elif pumpdepthfinal_m > 600.0:
396+
msg = (f'GEOPHIRES calculates production pump depth to be deeper than 600m ({pumpdepthfinal_m}m). '
397+
f'Verify reservoir pressure, production well flow rate and production well dimensions')
397398
print(f'Warning: {msg}')
398399
model.logger.warning(msg)
399400

400401
# calculate production well pumping pressure [kPa]
401-
DPProdWell = Pprodwellhead - (Phydrostaticcalc_kPa - wellflowrate / PIkPa - rhowaterprod * 9.81 * depth_m / 1E3 - f3 *
402+
DPProdWell = Pprodwellhead - (Phydrostaticcalc_kPa - wellflowrate / PI_kPa - rhowaterprod * 9.81 * depth_m / 1E3 - f3 *
402403
(rhowaterprod * vprod ** 2 / 2.) * (depth_m / prodwelldiam) / 1E3)
403404
# [MWe] total pumping power for production wells
404405
PumpingPowerProd = DPProdWell * nprod * wellflowrate / rhowaterprod / pumpeff / 1E3
@@ -549,7 +550,7 @@ def __init__(self, model: Model):
549550
:type model: :class:`~geophires_x.Model.Model`
550551
:return: Nothing, and is used to initialize the class
551552
"""
552-
model.logger.info(f"Init {self.__class__.__name__}: {__name__}")
553+
model.logger.info(f'Init {self.__class__.__name__}: {__name__}')
553554
self.rhowaterprod = self.rhowaterinj = 0.0
554555

555556
# Set up all the Parameters that will be predefined by this class using the different types of parameter classes.

0 commit comments

Comments
 (0)