Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIP-RA-X schema; SBT docs generation #285

Merged
merged 14 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ requirements.txt
.DS_Store
*.lock
*.json
all_messages_conf.log

# C extensions
*.so
Expand Down Expand Up @@ -81,6 +82,8 @@ docs/reference/geophires-request.json
docs/reference/parameters.rst
docs/geophires-request.json
docs/parameters.rst
docs/hip-ra-x-request.json
docs/hip_ra_x_parameters.rst
_site/
/docs/geophires_x.rstx
/docs/temperature.txt
Expand Down
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,15 @@ Extending GEOPHIRES-X

- `Extension example: SUTRA <https://github.com/NREL/GEOPHIRES-X/commit/984cb4da1505667adb2c45cb1297cab6550774bd#diff-5b1ea85ce061b9a1137a46c48d2d293126224d677d3ab38d9b2f4dcfc4e1674e>`__


HIP-RA: Heat in Place - Resource Assessment
-------------------------------------------

* `HIP-RA-X README <src/hip_ra_x/README.md>`__
* `HIP-RA-X Parameters Reference <https://softwareengineerprogrammer.github.io/GEOPHIRES-X/hip_ra_x_parameters.html>`__

.. TODO switch over to https://nrel.github.io/GEOPHIRES-X/hip_ra_x_parameters.html once merged

Monte Carlo
-----------

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Contents
overview
parameters
How-to-extend-GEOPHIRES-X
hip_ra_x_parameters
Monte-Carlo-User-Guide
.. reference/index

Expand Down
3 changes: 0 additions & 3 deletions src/geophires_x/OptionList.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ class WellDrillingCostCorrelation(GeophiresInputEnum):
VERTICAL_LARGE_IDEAL = 16, "vertical open-hole, large diameter, ideal", -0.00240, 752.93946, 524337.65380
DEVIATED_LARGE_IDEAL = 17, "deviated liner, large diameter, ideal", 0.00376, 762.52696, 765103.07690

def calculate_cost_MUSD(self, meters) -> float:
return (self._c2 * meters ** 2 + self._c1 * meters + self._c0) * 1E-6

def __init__(self, int_value: int, _: str, c2: float, c1: float, c0: float):
self._c2 = c2
self._c1 = c1
Expand Down
24 changes: 12 additions & 12 deletions src/geophires_x/SBTReservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def __init__(self, model: Model):
AllowableRange=[1, 2],
UnitType=Units.NONE,
ErrMessage="assume constant user-provided flowrate (1)",
ToolTipText="Must be 1 or 2. '1' means the user provides a constant mass flow rate. \
'1' means the user provides an excel file with a mass flow rate profile."
ToolTipText="Must be 1 or 2. '1' means the user provides a constant mass flow rate. "
"'1' means the user provides an excel file with a mass flow rate profile."
)
self.flow_rate_file = self.ParameterDict[self.flow_rate_file.Name] = strParameter(
"Flowrate File",
Expand All @@ -206,8 +206,8 @@ def __init__(self, model: Model):
AllowableRange=[1, 2],
UnitType=Units.NONE,
ErrMessage="assume constant user-provided injection temperature (1)",
ToolTipText="Must be 1 or 2. '1' means the user provides a constant injection temperature. \
'1' means the user provides an excel file with an injection temperature profile."
ToolTipText="Must be 1 or 2. '1' means the user provides a constant injection temperature. "
"'1' means the user provides an excel file with an injection temperature profile."
)
self.injection_temperature_file = self.ParameterDict[self.injection_temperature_file.Name] = strParameter(
"Injection Temperature File",
Expand All @@ -222,9 +222,9 @@ def __init__(self, model: Model):
AllowableRange=[1, 5],
UnitType=Units.NONE,
ErrMessage="assume default SBT accuracy desired (1)",
ToolTipText="Must be 1, 2, 3, 4 or 5 with 1 lowest accuracy and 5 highest accuracy. \
Lowest accuracy runs fastest. Accuracy level impacts number of discretizations for \
numerical integration and decision tree thresholds in SBT algorithm."
ToolTipText="Must be 1, 2, 3, 4 or 5 with 1 lowest accuracy and 5 highest accuracy. "
"Lowest accuracy runs fastest. Accuracy level impacts number of discretizations for "
"numerical integration and decision tree thresholds in SBT algorithm."
)
self.percent_implicit = self.ParameterDict[self.percent_implicit.Name] = floatParameter(
"SBT Percent Implicit Euler Scheme",
Expand All @@ -235,11 +235,11 @@ def __init__(self, model: Model):
PreferredUnits=PercentUnit.TENTH,
CurrentUnits=PercentUnit.TENTH,
ErrMessage="assume default percent implicit (1.0)",
ToolTipText="Should be between 0 and 1. Most stable is setting it to 1 which results in \
a fully implicit Euler scheme when calculating the fluid temperature at each time step. \
With a value of 0, the convective term is modelled using explicit Euler. \
A value of 0.5 would model the convective term 50% explicit and 50% implicit, \
which may be slightly more accurate than fully implicit."
ToolTipText="Should be between 0 and 1. Most stable is setting it to 1 which results in "
"a fully implicit Euler scheme when calculating the fluid temperature at each time step. "
"With a value of 0, the convective term is modelled using explicit Euler. "
"A value of 0.5 would model the convective term 50% explicit and 50% implicit, "
"which may be slightly more accurate than fully implicit."
)
self.initial_timestep_count = self.ParameterDict[self.initial_timestep_count.Name] = intParameter(
'SBT Initial Timestep Count',
Expand Down
5 changes: 4 additions & 1 deletion src/geophires_x_schema_generator/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
parameters.rst
*parameters.rst
all_messages_conf.log
!geophires-request.json
!hip-ra-x-request.json
58 changes: 43 additions & 15 deletions src/geophires_x_schema_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# Ruff disabled because imports are order-dependent
# ruff: noqa: I001
from geophires_x.Model import Model
from geophires_x.SBTEconomics import SBTEconomics
from geophires_x.SBTReservoir import SBTReservoir
from geophires_x.SBTWellbores import SBTWellbores

from geophires_x.SFReservoir import SFReservoir
from geophires_x.LHSReservoir import LHSReservoir
Expand All @@ -24,6 +27,7 @@
from geophires_x.SUTRAReservoir import SUTRAReservoir
from geophires_x.SUTRAWellBores import SUTRAWellBores
from geophires_x.TDPReservoir import TDPReservoir
from hip_ra_x.hip_ra_x import HIP_RA_X


class GeophiresXSchemaGenerator:
Expand All @@ -41,37 +45,48 @@ def _get_dummy_model(self):
sys.argv = stash_sys_argv
os.chdir(stash_cwd)

def get_parameters_json(self) -> Tuple[str, str]:
def get_parameter_sources(self) -> list:
"""
:rtype: list[Tuple[Any, str]]
"""
dummy_model = self._get_dummy_model()

def with_category(param_dict: dict, category: str):
def _with_cat(p: Parameter, cat: str):
p.parameter_category = cat
return p

return {k: _with_cat(v, category) for k, v in param_dict.items()}

parameter_sources = [
return [
(dummy_model.reserv, 'Reservoir'),
(TDPReservoir(dummy_model), 'Reservoir'),
(LHSReservoir(dummy_model), 'Reservoir'),
(MPFReservoir(dummy_model), 'Reservoir'),
(SFReservoir(dummy_model), 'Reservoir'),
(CylindricalReservoir(dummy_model), 'Reservoir'),
(SBTReservoir(dummy_model), 'Reservoir'),
(SUTRAReservoir(dummy_model), 'Reservoir'),
(dummy_model.wellbores, 'Well Bores'),
(AGSWellBores(dummy_model), 'Well Bores'),
(SBTWellbores(dummy_model), 'Well Bores'),
(SUTRAWellBores(dummy_model), 'Well Bores'),
(dummy_model.surfaceplant, 'Surface Plant'),
(SurfacePlantAGS(dummy_model), 'Surface Plant'),
(SurfacePlantSUTRA(dummy_model), 'Surface Plant'),
(dummy_model.economics, 'Economics'),
(AGSEconomics(dummy_model), 'Economics'),
(SBTEconomics(dummy_model), 'Economics'),
(SUTRAEconomics(dummy_model), 'Economics'),
(EconomicsCCUS(dummy_model), 'Economics'),
(EconomicsAddOns(dummy_model), 'Economics'),
]

def get_schema_title(self) -> str:
return 'GEOPHIRES-X'

def get_parameters_json(self) -> Tuple[str, str]:

def with_category(param_dict: dict, category: str):
def _with_cat(p: Parameter, cat: str):
p.parameter_category = cat
return p

return {k: _with_cat(v, category) for k, v in param_dict.items()}

parameter_sources = self.get_parameter_sources()
output_params = {}
input_params = {}
for param_source in parameter_sources:
Expand Down Expand Up @@ -112,7 +127,7 @@ def generate_json_schema(self) -> dict:
'definitions': {},
'$schema': 'http://json-schema.org/draft-04/schema#',
'type': 'object',
'title': 'GEOPHIRES Schema',
'title': f'{self.get_schema_title()} Schema',
'required': required,
'properties': properties,
}
Expand All @@ -132,10 +147,11 @@ def generate_parameters_reference_rst(self) -> str:
input_params_by_category[category][input_param_name] = input_param

def get_input_params_table(category_params, category_name) -> str:
category_display = category_name if category_name is not None else ''
input_rst = f"""
{category_name}
{'-' * len(category_name)}
.. list-table:: {category_name} Parameters
{category_display}
{'-' * len(category_display)}
.. list-table:: {category_display}{' ' if len(category_display) > 0 else ''}Parameters
:header-rows: 1

* - Name
Expand Down Expand Up @@ -170,7 +186,7 @@ def get_input_params_table(category_params, category_name) -> str:

output_rst = self.get_output_params_table_rst(output_params_json)

rst = f"""Parameters
rst = f"""{self.get_schema_title()} Parameters
==========

.. contents::
Expand Down Expand Up @@ -230,3 +246,15 @@ def _get_min_and_max(param: dict, default_val='') -> Tuple:
max_val = max(param['AllowableRange'])

return (min_val, max_val)


class HipRaXSchemaGenerator(GeophiresXSchemaGenerator):
def get_parameter_sources(self) -> list:
"""
:rtype: list[Tuple[Any, str]]
"""
dummy_model = HIP_RA_X()
return [(dummy_model, None)]

def get_schema_title(self) -> str:
return 'HIP-RA-X'
Loading