Skip to content

Commit

Permalink
Merge pull request #14 from softwareengineerprogrammer/main
Browse files Browse the repository at this point in the history
AGS-related fixes/enhancements
  • Loading branch information
softwareengineerprogrammer authored Oct 11, 2023
2 parents 90f93a2 + 5461904 commit b31f3b3
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.1.2
current_version = 3.1.5
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion .cookiecutterrc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ default_context:
sphinx_doctest: "no"
sphinx_theme: "sphinx-rtd-theme"
test_matrix_separate_coverage: "no"
version: 3.1.2
version: 3.1.5
version_manager: "bump2version"
website: "https://github.com/NREL"
year_from: "2023"
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ Free software: `MIT license <LICENSE>`_
:alt: Supported implementations
:target: https://pypi.org/project/geophires-x

.. |commits-since| image:: https://img.shields.io/github/commits-since/NREL/python-geophires-x/v3.1.2.svg
.. |commits-since| image:: https://img.shields.io/github/commits-since/NREL/python-geophires-x/v3.1.5.svg
:alt: Commits since latest release
:target: https://github.com/NREL/python-geophires-x/compare/v3.1.2...main
:target: https://github.com/NREL/python-geophires-x/compare/v3.1.5...main



Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read(*names, **kwargs):

setup(
name='geophires-x',
version='3.1.2',
version='3.1.5',
license='MIT',
description='Distributable python package version of https://github.com/malcolm-dsider/GEOPHIRES-X',
long_description='{}\n{}'.format(
Expand Down
208 changes: 111 additions & 97 deletions src/geophires_x/AGSSurfacePlant.py

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/geophires_x/AGSWellBores.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,29 +694,29 @@ def verify(self, model: Model) -> int:
:return: 0 if all OK, 1 if error.
:doc-author: Koenraad Beckers
"""
model.logger.info("Init " + str(
__class__) + ": " + sys._getframe().f_code.co_name) # Verify inputs are within allowable bounds
model.logger.info(f"Init {str(__class__)}: {sys._getframe().f_code.co_name}")

# Verify inputs are within allowable bounds
self.error = 0
errors = []

def on_invalid_parameter_value(err_msg):
errors.append(err_msg)
print(err_msg)
model.logger.fatal(err_msg)
self.error = 1

if self.Nonvertical_length.value < 1000 or self.Nonvertical_length.value > 20000:
print("Error: CLGS model database imposes additional range restrictions: Nonvertical length must be \
on_invalid_parameter_value("Error: CLGS model database imposes additional range restrictions: Nonvertical length must be \
between 1,000 and 20,000 m. Simulation terminated.")
model.logger.fatal("Error: CLGS model database imposes additional range restrictions: Nonvertical length must be \
between 1,000 and 20,000 m. Simulation terminated.")
self.error = 1
if self.Tinj.value < 30.0 or self.Tinj.value > 60.0:
print("Error: CLGS model database imposes additional range restrictions: Injection temperature\
on_invalid_parameter_value("Error: CLGS model database imposes additional range restrictions: Injection temperature\
must be between 30 and 60 C. Simulation terminated.")
model.logger.fatal("Error: CLGS model database imposes additional range restrictions: Injection temperature\
must be between 30 and 60 C. Simulation terminated.")
self.error = 1
if self.krock < 1.5 or self.krock > 4.5:
print("Error: CLGS model database imposes additional range restrictions: \
Rock thermal conductivity must be between 1.5 and 4.5 W/m/K. Simulation terminated.")
model.logger.fatal("Error: CLGS model database imposes additional range restrictions: \
on_invalid_parameter_value("Error: CLGS model database imposes additional range restrictions: \
Rock thermal conductivity must be between 1.5 and 4.5 W/m/K. Simulation terminated.")
self.error = 1

model.logger.info("complete " + str(__class__) + ": " + sys._getframe().f_code.co_name)
model.logger.info(f"complete {str(__class__)}: {sys._getframe().f_code.co_name}")
return self.error

# Multilateral code
Expand Down
2 changes: 1 addition & 1 deletion src/geophires_x/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.1.2'
__version__ = '3.1.5'
2 changes: 1 addition & 1 deletion src/geophires_x_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_geophires_result(self, input_params: GeophiresInputParameters) -> Geophi
try:
geophires.main(enable_geophires_logging_config=False)
except Exception as e:
raise RuntimeError('GEOPHIRES encountered an exception') from e
raise RuntimeError(f'GEOPHIRES encountered an exception: {e!s}') from e
except SystemExit:
raise RuntimeError('GEOPHIRES exited without giving a reason') from None

Expand Down
56 changes: 44 additions & 12 deletions src/geophires_x_client/geophires_x_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class GeophiresXResult:
'SUMMARY OF RESULTS': [
# TODO uses colon delimiter inconsistently
# 'End-Use Option',
'End-Use',
'Average Net Electricity Production',
'Electricity breakeven price',
'Average Direct-Use Heat Production',
Expand All @@ -27,11 +28,7 @@ class GeophiresXResult:
'Geothermal gradient',
# AGS/CLGS
'LCOE',
# 'Fluid',
# 'Design',
# 'Flow rate',
# 'Lateral Length',
# 'Vertical Depth'
'LCOH',
],
'ECONOMIC PARAMETERS': [
'Interest Rate', # %
Expand All @@ -46,12 +43,20 @@ class GeophiresXResult:
'Water loss rate', # %
'Pump efficiency', # %
'Injection temperature',
'Injection Temperature',
'Average production well temperature drop',
'Flowrate per production well',
'Injection well casing ID',
'Production well casing ID', # TODO correct typo upstream
'Number of times redrilling',
# 'Power plant type', # Not a number - TODO parse non-number values without throwing exception
# AGS/CLGS
'Fluid',
'Design',
'Flow rate',
'Lateral Length',
'Vertical Depth',
'Wellbore Diameter',
],
'RESOURCE CHARACTERISTICS': ['Maximum reservoir temperature', 'Number of segments', 'Geothermal gradient'],
'RESERVOIR PARAMETERS': [
Expand All @@ -73,6 +78,7 @@ class GeophiresXResult:
'Reservoir thermal conductivity',
'Reservoir heat capacity',
'Reservoir porosity',
'Thermal Conductivity',
],
'RESERVOIR SIMULATION RESULTS': [
'Maximum Production Temperature',
Expand All @@ -84,6 +90,11 @@ class GeophiresXResult:
'Average Production Well Temperature Drop',
'Average Injection Well Pump Pressure Drop',
'Average Production Well Pump Pressure Drop',
'Average Production Pressure',
'Average Heat Production',
'First Year Heat Production',
'Average Net Electricity Production',
'First Year Electricity Production',
],
'CAPITAL COSTS (M$)': [
'Drilling and completion costs',
Expand All @@ -98,6 +109,7 @@ class GeophiresXResult:
'Total capital costs',
# AGS/CLGS
'Total CAPEX',
'Drilling Cost',
],
'OPERATING AND MAINTENANCE COSTS (M$/yr)': [
'Wellfield maintenance costs',
Expand Down Expand Up @@ -244,18 +256,29 @@ def power_generation_profile(self):
return self.result['POWER GENERATION PROFILE']

def _get_power_generation_profile(self):
s1 = '* HEATING, COOLING AND/OR ELECTRICITY PRODUCTION PROFILE *'
s2 = '***************************************************************' # header of next profile
profile_lines = ''.join(self._lines).split(s1)[1].split(s2)[0].split('\n') # [5:]
profile_lines = None
try:
s1 = '* HEATING, COOLING AND/OR ELECTRICITY PRODUCTION PROFILE *'
s2 = '***************************************************************' # header of next profile
profile_lines = ''.join(self._lines).split(s1)[1].split(s2)[0].split('\n') # [5:]
except IndexError:
s1 = '* POWER GENERATION PROFILE *'
s2 = '***************************************************************' # header of next profile
profile_lines = ''.join(self._lines).split(s1)[1].split(s2)[0].split('\n') # [5:]
return self._get_data_from_profile_lines(profile_lines)

@property
def heat_electricity_extraction_generation_profile(self):
return self.result['HEAT AND/OR ELECTRICITY EXTRACTION AND GENERATION PROFILE']

def _get_heat_electricity_extraction_generation_profile(self):
s1 = '* ANNUAL HEATING, COOLING AND/OR ELECTRICITY PRODUCTION PROFILE *'
profile_lines = ''.join(self._lines).split(s1)[1].split('\n')
profile_lines = None
try:
s1 = '* ANNUAL HEATING, COOLING AND/OR ELECTRICITY PRODUCTION PROFILE *'
profile_lines = ''.join(self._lines).split(s1)[1].split('\n')
except IndexError:
s1 = '* HEAT AND/OR ELECTRICITY EXTRACTION AND GENERATION PROFILE *'
profile_lines = ''.join(self._lines).split(s1)[1].split('\n')
return self._get_data_from_profile_lines(profile_lines)

def _get_data_from_profile_lines(self, profile_lines):
Expand Down Expand Up @@ -303,7 +326,16 @@ def _get_end_use_option(self) -> EndUseOption:
elif 'Electricity' in end_use_option_snippet:
return EndUseOption.ELECTRICITY
except IndexError:
# FIXME
self._logger.error('Failed to parse End-Use Option')
# FIXME clean up
try:
end_use_option_snippet = list(filter(lambda x: 'End-Use: ' in x, self._lines))[0].split('End-Use: ')[1]

if 'Direct-Use Heat' in end_use_option_snippet:
return EndUseOption.DIRECT_USE_HEAT
elif 'Electricity' in end_use_option_snippet:
return EndUseOption.ELECTRICITY
except IndexError:
# FIXME
self._logger.error('Failed to parse End-Use Option')

return None
22 changes: 22 additions & 0 deletions tests/error-code-5500.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Is AGS, True
Closed-loop Configuration, 1
End-Use Option, 1
Heat Transfer Fluid, 2
Number of Production Wells, 1
Number of Injection Wells, 0
All-in Vertical Drilling Costs, 1000
All-in Nonvertical Drilling Costs, 1000
Production Flow Rate per Well, 40
Gradient 1, 60
Total Nonvertical Length, 1000
Production Well Diameter, 8.5
Injection Temperature, 60
Plant Lifetime, 40
Ambient Temperature, 20
Electricity Rate, 0.1
Circulation Pump Efficiency, 0.8
CO2 Turbine Outlet Pressure, 200
Economic Model, 4
Reservoir Stimulation Capital Cost, 0
Exploration Capital Cost, 0
Print Output to Console, 1
Loading

0 comments on commit b31f3b3

Please sign in to comment.