Skip to content

Commit cb29e6f

Browse files
Merge pull request NREL#193 from softwareengineerprogrammer/main
PR 185 Cleanup
2 parents 650c53c + 90cb501 commit cb29e6f

16 files changed

+196
-153
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.25
2+
current_version = 3.4.26
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.25
57+
version: 3.4.26
5858
version_manager: "bump2version"
5959
website: "https://github.com/NREL"
6060
year_from: "2023"

README.rst

Lines changed: 2 additions & 2 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/softwareengineerprogrammer/GEOPHIRES-X/v3.4.25.svg
50+
.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.4.26.svg
5151
:alt: Commits since latest release
52-
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.4.25...main
52+
:target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.4.26...main
5353

5454
.. |docs| image:: https://readthedocs.org/projects/GEOPHIRES-X/badge/?style=flat
5555
:target: https://nrel.github.io/GEOPHIRES-X

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.25'
21+
version = release = '3.4.26'
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.25',
16+
version='3.4.26',
1717
license='MIT',
1818
description='GEOPHIRES is a free and open-source geothermal techno-economic simulator.',
1919
long_description='{}\n{}'.format(

src/geophires_monte_carlo/MC_GeoPHIRES3.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ def main(command_line_args=None):
358358
if 'MC_OUTPUT_FILE' in args and args.MC_OUTPUT_FILE is not None
359359
else str(Path(Path(args.Input_file).parent, 'MC_Result.txt').absolute())
360360
)
361+
code_file_name = Path(args.Code_File).name
361362
python_path = 'python'
362363
html_path = ''
363364

@@ -450,6 +451,14 @@ def main(command_line_args=None):
450451
results_pd = pd.read_csv(output_file)
451452
df = pd.DataFrame(results_pd)
452453

454+
if len(results) < 1:
455+
# TODO surface actual exceptions instead of giving this generic message
456+
raise RuntimeError(
457+
'No MC results generated, '
458+
f'this is likely caused by {code_file_name} throwing an exception '
459+
f'when run with your input file.'
460+
)
461+
453462
# Compute the stats along the specified axes.
454463
mins = np.nanmin(results, 0)
455464
maxs = np.nanmax(results, 0)

src/geophires_x/AGSWellBores.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,12 @@ def CalculateNonverticalPressureDrop(self, model:Model, time_operation: float, t
871871
# nonvertical wellbore fluid conditions based on current temperature
872872
rhowater = density_water_kg_per_m3(
873873
self.NonverticalProducedTemperature.value[year],
874-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude)
874+
pressure=model.reserv.lithostatic_pressure()
875875
)
876876

877877
muwater = viscosity_water_Pa_sec(
878878
self.NonverticalProducedTemperature.value[year],
879-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude)
879+
pressure=model.reserv.lithostatic_pressure()
880880
)
881881
vhoriz = self.q_circulation / rhowater / (math.pi / 4. * self.nonverticalwellborediameter.value ** 2)
882882

@@ -957,15 +957,15 @@ def Calculate(self, model: Model) -> None:
957957
# MIR figure out how to calculate year and extract Tini from reserv Tresoutput array
958958
year = math.trunc(self.time_operation.value / self.al)
959959
self.NonverticalProducedTemperature.value[year] = inverselaplace(
960-
self, 16, 0, model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude))
960+
self, 16, 0, model.reserv.lithostatic_pressure())
961961
# update alpha_fluid value based on next temperature of reservoir
962962

963963
self.alpha_fluid = self.WaterThermalConductivity.value / density_water_kg_per_m3(
964964
self.NonverticalProducedTemperature.value[year],
965-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude)
965+
pressure=model.reserv.lithostatic_pressure()
966966
) / heat_capacity_water_J_per_kg_per_K(
967967
self.NonverticalProducedTemperature.value[year],
968-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude)
968+
pressure=model.reserv.lithostatic_pressure()
969969
) * 24.0 * 3600.0
970970
self.time_operation.value += self.al
971971

@@ -979,7 +979,7 @@ def Calculate(self, model: Model) -> None:
979979
self.ProdTempDrop.value = self.tempdropprod.value
980980
model.reserv.cpwater.value = heat_capacity_water_J_per_kg_per_K(
981981
self.NonverticalProducedTemperature.value[0],
982-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude)
982+
pressure=model.reserv.lithostatic_pressure()
983983
)
984984
if self.rameyoptionprod.value:
985985
self.ProdTempDrop.value = RameyCalc(model.reserv.krock.value,
@@ -1002,13 +1002,13 @@ def Calculate(self, model: Model) -> None:
10021002
if self.productionwellpumping.value:
10031003
self.rhowaterinj = density_water_kg_per_m3(
10041004
model.reserv.Tsurf.value,
1005-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude)
1005+
pressure=model.reserv.lithostatic_pressure()
10061006
) * np.linspace(1, 1,
10071007
len(self.ProducedTemperature.value))
10081008

10091009
self.rhowaterprod = density_water_kg_per_m3(
10101010
model.reserv.Trock.value,
1011-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude)
1011+
pressure=model.reserv.lithostatic_pressure()
10121012
) * np.linspace(1, 1, len(self.ProducedTemperature.value))
10131013

10141014
self.DPProdWell.value, f3, vprod, self.rhowaterprod = WellPressureDrop(model,
@@ -1113,13 +1113,13 @@ def Calculate(self, model: Model) -> None:
11131113

11141114
rho_water = density_water_kg_per_m3(
11151115
self.Tout[0],
1116-
pressure = model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude),
1116+
pressure = model.reserv.lithostatic_pressure(),
11171117
)
11181118

11191119

11201120
model.reserv.cpwater.value = heat_capacity_water_J_per_kg_per_K(
11211121
self.Tout[0],
1122-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.InputDepth.quantity().to('m').magnitude),
1122+
pressure=model.reserv.lithostatic_pressure(),
11231123
) # Need this for surface plant output calculation
11241124

11251125
# set pumping power to zero for all times, assuming that the thermosphere wil always

src/geophires_x/CylindricalReservoir.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, model: Model):
9898
UnitType=Units.PERCENT,
9999
PreferredUnits=PercentUnit.TENTH,
100100
CurrentUnits=PercentUnit.TENTH,
101-
ErrMessage="assume default cyclindrical reservoir radius of effect reduction factor (0.1)",
101+
ErrMessage="assume default cylindrical reservoir radius of effect reduction factor (0.1)",
102102
ToolTipText="The radius of effect reduction factor - to account for the fact that we cannot extract 100%"
103103
+ " of the heat in the cylinder.",
104104
)
@@ -244,20 +244,17 @@ def Calculate(self, model: Model) -> None:
244244
) / 1e15 # 10^15 J
245245
self.cpwater.value = heat_capacity_water_J_per_kg_per_K(
246246
model.wellbores.Tinj.value * 0.5 + (self.Trock.value * 0.9 + model.wellbores.Tinj.value * 0.1) * 0.5,
247-
pressure=self.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.depth.quantity().to('m').magnitude)
247+
pressure=self.lithostatic_pressure()
248248
)
249249
self.rhowater.value = density_water_kg_per_m3(
250250
model.wellbores.Tinj.value * 0.5 + (self.Trock.value * 0.9 + model.wellbores.Tinj.value * 0.1) * 0.5,
251-
pressure=self.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.depth.quantity().to('m').magnitude)
251+
pressure=self.lithostatic_pressure()
252252
)
253253

254254
model.logger.info(f'complete {str(__class__)}: {sys._getframe().f_code.co_name}')
255255

256-
#def lithostatic_pressure(self) -> PlainQuantity:
257-
"""
258-
@override
256+
def lithostatic_pressure(self) -> PlainQuantity:
257+
"""@override"""
259258

260-
Standard reservoir implementation uses depth but CylindricalReservoir sets depth to total drilled length
261-
"""
262-
def lithostatic_pressure(self, rho_rock_kg_per_m3: float, depth_m: float) -> PlainQuantity:
263-
return quantity(static_pressure_MPa(rho_rock_kg_per_m3, depth_m), 'MPa')
259+
return quantity(static_pressure_MPa(self.rhorock.quantity().to('kg/m**3').magnitude,
260+
self.InputDepth.quantity().to('m').magnitude), 'MPa')

src/geophires_x/Reservoir.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,14 +749,12 @@ def Calculate(self, model: Model) -> None:
749749
# calculate reservoir water properties
750750
self.cpwater.value = heat_capacity_water_J_per_kg_per_K(
751751
model.wellbores.Tinj.value * 0.5 + (self.Trock.value * 0.9 + model.wellbores.Tinj.value * 0.1) * 0.5,
752-
pressure=self.lithostatic_pressure(self.rhorock.quantity().to('kg/m**3').magnitude,
753-
self.depth.quantity().to('m').magnitude)
752+
pressure=self.lithostatic_pressure()
754753
)
755754

756755
self.rhowater.value = density_water_kg_per_m3(
757756
model.wellbores.Tinj.value * 0.5 + (self.Trock.value * 0.9 + model.wellbores.Tinj.value * 0.1) * 0.5,
758-
pressure=self.lithostatic_pressure(self.rhorock.quantity().to('kg/m**3').magnitude,
759-
self.depth.quantity().to('m').magnitude)
757+
pressure=self.lithostatic_pressure()
760758
)
761759

762760
# temperature gain in injection wells
@@ -768,7 +766,8 @@ def Calculate(self, model: Model) -> None:
768766

769767
model.logger.info(f'complete {str(__class__)}: {sys._getframe().f_code.co_name}')
770768

771-
def lithostatic_pressure(self, rho_rock_kg_per_m3: float, depth_m: float) -> PlainQuantity:
772-
return quantity(static_pressure_MPa(rho_rock_kg_per_m3, depth_m), 'MPa')
769+
def lithostatic_pressure(self) -> PlainQuantity:
770+
return quantity(static_pressure_MPa(self.rhorock.quantity().to('kg/m**3').magnitude,
771+
self.depth.quantity().to('m').magnitude), 'MPa')
773772

774773

src/geophires_x/WellBores.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ def WellPressureDrop(model: Model, Taverage: float, wellflowrate: float, welldia
164164
rhowater = np.array([
165165
density_water_kg_per_m3(
166166
t,
167-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.depth.quantity().to('m').magnitude),
167+
pressure=model.reserv.lithostatic_pressure(),
168168
)
169169
for t in Taverage
170170
]) # replace with correlation based on Tprodaverage
171171

172172
muwater = np.array([
173173
viscosity_water_Pa_sec(
174174
t,
175-
pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value, model.reserv.depth.quantity().to('m').magnitude),
175+
pressure=model.reserv.lithostatic_pressure(),
176176
)
177177
for t in Taverage
178178
]) # replace with correlation based on Tprodaverage
@@ -228,13 +228,11 @@ def InjectionWellPressureDrop(model: Model, Taverage: float, wellflowrate: float
228228
"""
229229
# start by calculating wellbore fluid conditions [kPa], noting that most temperature drop happens in
230230
# upper section (because surrounding rock temperature is lowest in upper section)
231-
rhowater = (density_water_kg_per_m3(Taverage, pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value,
232-
model.reserv.depth.quantity().to('m').magnitude))
231+
rhowater = (density_water_kg_per_m3(Taverage, pressure=model.reserv.lithostatic_pressure())
233232
* np.linspace(1, 1, len(model.wellbores.ProducedTemperature.value)))
234233

235234
# replace with correlation based on Tinjaverage
236-
muwater = viscosity_water_Pa_sec(Taverage, pressure=model.reserv.lithostatic_pressure(model.reserv.rhorock.value,
237-
model.reserv.depth.quantity().to('m').magnitude)) * np.linspace(1, 1, len(model.wellbores.ProducedTemperature.value))
235+
muwater = viscosity_water_Pa_sec(Taverage, pressure=model.reserv.lithostatic_pressure()) * np.linspace(1, 1, len(model.wellbores.ProducedTemperature.value))
238236
v = nprod / ninj * wellflowrate * (1.0 + waterloss) / rhowater / (math.pi / 4. * welldiam ** 2)
239237
Rewater = 4. * nprod / ninj * wellflowrate * (1.0 + waterloss) / (
240238
muwater * math.pi * welldiam) # laminar or turbulent flow?
@@ -1087,8 +1085,7 @@ def Calculate(self, model: Model) -> None:
10871085
self.production_reservoir_pressure.value = get_hydrostatic_pressure_kPa(model.reserv.Trock.value, model.reserv.Tsurf.value,
10881086
model.reserv.depth.quantity().to('m').magnitude,
10891087
model.reserv.averagegradient.value,
1090-
model.reserv.lithostatic_pressure(model.reserv.rhorock.value,
1091-
model.reserv.depth.quantity().to('m').magnitude)) if self.usebuiltinhydrostaticpressurecorrelation else self.Phydrostatic.quantity().to(
1088+
model.reserv.lithostatic_pressure()) if self.usebuiltinhydrostaticpressurecorrelation else self.Phydrostatic.quantity().to(
10921089
self.production_reservoir_pressure.CurrentUnits).magnitude
10931090

10941091
self.production_reservoir_pressure.value = ReservoirPressurePredictor(model.surfaceplant.plant_lifetime.value,
@@ -1114,19 +1111,20 @@ def Calculate(self, model: Model) -> None:
11141111
if not self.injection_reservoir_temperature.Provided:
11151112
self.injection_reservoir_temperature.value = (model.reserv.averagegradient.value * self.injection_reservoir_depth.value) + model.reserv.Tsurf.value
11161113

1114+
injection_reservoir_static_pressure = quantity(static_pressure_MPa(
1115+
model.reserv.rhorock.value, self.injection_reservoir_depth.quantity().to('m').magnitude), 'MPa')
1116+
11171117
if self.injection_reservoir_pressure.value < 0: # they didn't provide a pressure so assume hydrostatic.
11181118
self.injection_reservoir_pressure.value = get_hydrostatic_pressure_kPa(self.injection_reservoir_temperature.value,
11191119
model.reserv.Tsurf.value,
11201120
self.injection_reservoir_depth.value,
11211121
model.reserv.averagegradient.value * 1000.0,
1122-
model.reserv.lithostatic_pressure(model.reserv.rhorock.value,
1123-
self.injection_reservoir_depth.quantity().to('m').magnitude))
1122+
injection_reservoir_static_pressure)
11241123
self.injection_reservoir_initial_pressure.value = self.injection_reservoir_pressure.value = get_hydrostatic_pressure_kPa(self.injection_reservoir_temperature.value,
11251124
model.reserv.Tsurf.value,
11261125
self.injection_reservoir_depth.value,
11271126
model.reserv.averagegradient.value,
1128-
model.reserv.lithostatic_pressure(model.reserv.rhorock.value,
1129-
self.injection_reservoir_depth.quantity().to('m').magnitude))
1127+
injection_reservoir_static_pressure)
11301128

11311129
# if not self.injection_reservoir_initial_pressure.Provided:
11321130
self.injection_reservoir_pressure.value = InjectionReservoirPressurePredictor(model.surfaceplant.plant_lifetime.value,

0 commit comments

Comments
 (0)