diff --git a/.bumpversion.cfg b/.bumpversion.cfg index bf05c081..78cad86c 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 3.4.35 +current_version = 3.4.36 commit = True tag = True diff --git a/.cookiecutterrc b/.cookiecutterrc index bc1b93b3..36da1a99 100644 --- a/.cookiecutterrc +++ b/.cookiecutterrc @@ -54,7 +54,7 @@ default_context: sphinx_doctest: "no" sphinx_theme: "sphinx-py3doc-enhanced-theme" test_matrix_separate_coverage: "no" - version: 3.4.35 + version: 3.4.36 version_manager: "bump2version" website: "https://github.com/NREL" year_from: "2023" diff --git a/README.rst b/README.rst index 3111289c..b6df06fa 100644 --- a/README.rst +++ b/README.rst @@ -47,9 +47,9 @@ Free software: `MIT license `__ :alt: Supported implementations :target: https://pypi.org/project/geophires-x -.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.4.35.svg +.. |commits-since| image:: https://img.shields.io/github/commits-since/softwareengineerprogrammer/GEOPHIRES-X/v3.4.36.svg :alt: Commits since latest release - :target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.4.35...main + :target: https://github.com/softwareengineerprogrammer/GEOPHIRES-X/compare/v3.4.36...main .. |docs| image:: https://readthedocs.org/projects/GEOPHIRES-X/badge/?style=flat :target: https://nrel.github.io/GEOPHIRES-X diff --git a/docs/conf.py b/docs/conf.py index ca898e81..0575b954 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,7 @@ year = '2023' author = 'NREL' copyright = f'{year}, {author}' -version = release = '3.4.35' +version = release = '3.4.36' pygments_style = 'trac' templates_path = ['./templates'] diff --git a/setup.py b/setup.py index 2339f9cf..8e32a7a4 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read(*names, **kwargs): setup( name='geophires-x', - version='3.4.35', + version='3.4.36', license='MIT', description='GEOPHIRES is a free and open-source geothermal techno-economic simulator.', long_description='{}\n{}'.format( diff --git a/src/geophires_x/Outputs.py b/src/geophires_x/Outputs.py index 47bb2b39..f7ab9f1f 100644 --- a/src/geophires_x/Outputs.py +++ b/src/geophires_x/Outputs.py @@ -745,7 +745,8 @@ def PrintOutputs(self, model: Model): for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]: for key in obj.ParameterDict: param = obj.ParameterDict[key] - if not param.UnitsMatch: ConvertUnitsBack(param, model) + if not param.UnitsMatch: + ConvertUnitsBack(param, model) # now we need to loop through all the output parameters to update their units to # whatever units the user has specified. @@ -847,19 +848,20 @@ def PrintOutputs(self, model: Model): model.reserv.depth.CurrentUnits.value)) if model.reserv.numseg.value == 1: - summary.append(OutputTableItem('Geothermal gradient', '{0:10.4f}'.format(model.reserv.gradient.value[0]), + summary.append(OutputTableItem('Geothermal gradient', '{0:10.4g}'.format(model.reserv.gradient.value[0]), model.reserv.gradient.CurrentUnits.value)) else: for i in range(1, model.reserv.numseg.value): summary.append(OutputTableItem(f'Segment {str(i)} Geothermal gradient', - '{0:10.4f}'.format(model.reserv.gradient.value[i - 1]), + '{0:10.4g}'.format(model.reserv.gradient.value[i - 1]), model.reserv.gradient.CurrentUnits.value)) summary.append(OutputTableItem(f'Segment {str(i)} Thickness', '{0:10.0f}'.format(model.reserv.layerthickness.value[i - 1]), model.reserv.layerthickness.CurrentUnits.value)) summary.append(OutputTableItem(f'Segment {str(i + 1)} Geothermal gradient', - '{0:10.4f}'.format(model.reserv.gradient.value[i]), + '{0:10.4g}'.format(model.reserv.gradient.value[i]), model.reserv.gradient.CurrentUnits.value)) + if model.economics.DoCarbonCalculations.value: summary.append(OutputTableItem('Total Avoided Carbon Emissions', '{0:10.2f}'.format( model.economics.CarbonThatWouldHaveBeenProducedTotal.value * 0.000453592), 'metric tonnes')) @@ -946,18 +948,18 @@ def PrintOutputs(self, model: Model): model.reserv.Tmax.CurrentUnits.value)) resource_characteristics.append(OutputTableItem('Number of segments', '{0:10.0f}'.format(model.reserv.numseg.value))) if model.reserv.numseg.value == 1: - resource_characteristics.append(OutputTableItem('Geothermal gradient', '{0:10.4f}'.format(model.reserv.gradient.value[0]), + resource_characteristics.append(OutputTableItem('Geothermal gradient', '{0:10.4g}'.format(model.reserv.gradient.value[0]), model.reserv.gradient.CurrentUnits.value)) else: for i in range(1, model.reserv.numseg.value): resource_characteristics.append(OutputTableItem(f'Segment {str(i)} Geothermal gradient', - '{0:10.4f}'.format( + '{0:10.4g}'.format( model.reserv.gradient.value[i - 1]), model.reserv.gradient.CurrentUnits.value)) resource_characteristics.append(OutputTableItem(f'Segment {str(i)} Thickness', '{0:10.0f}'.format( model.reserv.layerthickness.value[i - 1]), model.reserv.layerthickness.CurrentUnits.value)) resource_characteristics.append(OutputTableItem(f'Segment {str(i + 1)} Geothermal gradient', - '{0:10.4f}'.format(model.reserv.gradient.value[i]), + '{0:10.4g}'.format(model.reserv.gradient.value[i]), model.reserv.gradient.CurrentUnits.value)) if model.wellbores.IsAGS.value: reservoir_parameters.append(OutputTableItem('The AGS models contain an intrinsic reservoir model that doesn\'t expose values that can be used in extensive reporting.')) @@ -1596,12 +1598,12 @@ def PrintOutputs(self, model: Model): f.write(f' Well depth (or total length, if not vertical): {model.reserv.depth.value:10.1f} ' +model.reserv.depth.CurrentUnits.value + NL) if model.reserv.numseg.value == 1: - f.write(f' Geothermal gradient: {model.reserv.gradient.value[0]:10.4f} ' + model.reserv.gradient.CurrentUnits.value + NL) + f.write(f' Geothermal gradient: {model.reserv.gradient.value[0]:10.4g} ' + model.reserv.gradient.CurrentUnits.value + NL) else: for i in range(1, model.reserv.numseg.value): - f.write(f' Segment {str(i):s} Geothermal gradient: {model.reserv.gradient.value[i-1]:10.4f} ' + model.reserv.gradient.CurrentUnits.value +NL) + f.write(f' Segment {str(i):s} Geothermal gradient: {model.reserv.gradient.value[i-1]:10.4g} ' + model.reserv.gradient.CurrentUnits.value +NL) f.write(f' Segment {str(i):s} Thickness: {model.reserv.layerthickness.value[i-1]:10.0f} ' + model.reserv.layerthickness.CurrentUnits.value + NL) - f.write(f' Segment {str(i+1):s} Geothermal gradient: {model.reserv.gradient.value[i]:10.4f} ' + model.reserv.gradient.CurrentUnits.value + NL) + f.write(f' Segment {str(i+1):s} Geothermal gradient: {model.reserv.gradient.value[i]:10.4g} ' + model.reserv.gradient.CurrentUnits.value + NL) if model.economics.DoCarbonCalculations.value: f.write(f' Total Avoided Carbon Emissions: {model.economics.CarbonThatWouldHaveBeenProducedTotal.value*0.000453592:10.2f} metric tonnes' + NL) @@ -1670,12 +1672,12 @@ def PrintOutputs(self, model: Model): f.write(f' Maximum reservoir temperature: {model.reserv.Tmax.value:10.1f} ' + model.reserv.Tmax.CurrentUnits.value + NL) f.write(f' Number of segments: {model.reserv.numseg.value:10.0f} ' + NL) if model.reserv.numseg.value == 1: - f.write(f' Geothermal gradient: {model.reserv.gradient.value[0]:10.4f} ' + model.reserv.gradient.CurrentUnits.value + NL) + f.write(f' Geothermal gradient: {model.reserv.gradient.value[0]:10.4g} ' + model.reserv.gradient.CurrentUnits.value + NL) else: for i in range(1, model.reserv.numseg.value): - f.write(f' Segment {str(i):s} Geothermal gradient: {model.reserv.gradient.value[i-1]:10.4f} ' + model.reserv.gradient.CurrentUnits.value +NL) + f.write(f' Segment {str(i):s} Geothermal gradient: {model.reserv.gradient.value[i-1]:10.4g} ' + model.reserv.gradient.CurrentUnits.value +NL) f.write(f' Segment {str(i):s} Thickness: {model.reserv.layerthickness.value[i-1]:10.0f} ' + model.reserv.layerthickness.CurrentUnits.value + NL) - f.write(f' Segment {str(i+1):s} Geothermal gradient: {model.reserv.gradient.value[i]:10.4f} ' + model.reserv.gradient.CurrentUnits.value + NL) + f.write(f' Segment {str(i+1):s} Geothermal gradient: {model.reserv.gradient.value[i]:10.4g} ' + model.reserv.gradient.CurrentUnits.value + NL) f.write(NL) f.write(NL) diff --git a/src/geophires_x/Parameter.py b/src/geophires_x/Parameter.py index dced85b4..a5938d29 100644 --- a/src/geophires_x/Parameter.py +++ b/src/geophires_x/Parameter.py @@ -107,14 +107,22 @@ class Parameter(HasQuantity): InputComment: str = "" ToolTipText: str = Name UnitType: IntEnum = Units.NONE - PreferredUnits: Enum = Units.NONE + PreferredUnits: Enum = None # set to PreferredUnits assuming that the current units are the preferred units # - they will only change if the read function reads a different unit associated with a parameter CurrentUnits: Enum = PreferredUnits - UnitsMatch: bool = True + + @property + def UnitsMatch(self) -> bool: + return self.PreferredUnits == self.CurrentUnits + parameter_category: str = None + def __post_init__(self): + if self.PreferredUnits is None: + self.PreferredUnits = self.CurrentUnits + @dataclass class boolParameter(Parameter): @@ -176,6 +184,7 @@ class floatParameter(Parameter): def __post_init__(self): if self.value is None: self.value = self.DefaultValue + super().__post_init__() value: float = None @@ -271,7 +280,6 @@ def ReadParameter(ParameterReadIn: ParameterEntry, ParamToModify, model): else: # The value came in without any units, so it must be using the default PreferredUnits ParamToModify.CurrentUnits = ParamToModify.PreferredUnits - ParamToModify.UnitsMatch = True def default_parameter_value_message(new_val: Any, param_to_modify_name: str, default_value: Any) -> str: return ( @@ -414,7 +422,6 @@ def ConvertUnits(ParamToModify, strUnit: str, model) -> str: # user has provided a currency that is the currency expected, so just strip off the currency if prefType == currType: strUnit = str(val) - ParamToModify.UnitsMatch = True ParamToModify.CurrentUnits = currType return strUnit @@ -470,7 +477,6 @@ def ConvertUnits(ParamToModify, strUnit: str, model) -> str: val = float(val) * Factor strUnit = str(val) - ParamToModify.UnitsMatch = True ParamToModify.CurrentUnits = currType return strUnit @@ -494,7 +500,6 @@ def ConvertUnits(ParamToModify, strUnit: str, model) -> str: New_val = (conv_rate * float(val)) * Factor strUnit = str(New_val) - ParamToModify.UnitsMatch = False ParamToModify.CurrentUnits = parts[1] if len(prefSuff) > 0: @@ -562,7 +567,6 @@ def ConvertUnits(ParamToModify, strUnit: str, model) -> str: if new_val_units_lookup is not None and new_val_units_lookup[0] is not None: ParamToModify.CurrentUnits = new_val_units_lookup[0] - ParamToModify.UnitsMatch = False else: # if we come here, we must have a unit declared, but the unit must be the same as the preferred unit, # so we need to just get rid of the extra text after the space @@ -585,14 +589,43 @@ def ConvertUnitsBack(ParamToModify: Parameter, model): :return: None """ model.logger.info(f'Init {str(__name__)}: {sys._getframe().f_code.co_name} for {ParamToModify.Name}') - param_modified: Parameter = parameter_with_units_converted_back_to_preferred_units(ParamToModify, model) - ParamToModify.value = param_modified.value - ParamToModify.CurrentUnits = param_modified.CurrentUnits - ParamToModify.UnitType = param_modified.UnitsMatch + + try: + ParamToModify.value = _ureg.Quantity(ParamToModify.value, ParamToModify.CurrentUnits.value).to(ParamToModify.PreferredUnits.value).magnitude + ParamToModify.CurrentUnits = ParamToModify.PreferredUnits + except AttributeError as ae: + # TODO refactor to check for/convert currency instead of relying on try/except once currency conversion is + # re-enabled - https://github.com/NREL/GEOPHIRES-X/issues/236?title=Currency+conversions+disabled + model.logger.warning(f'Failed to convert units with pint, attempting currency conversion ({ae})') + + try: + param_modified: Parameter = _parameter_with_currency_units_converted_back_to_preferred_units(ParamToModify, + model) + ParamToModify.value = param_modified.value + ParamToModify.CurrentUnits = param_modified.CurrentUnits + ParamToModify.UnitType = param_modified.UnitType + except AttributeError as cce: + model.logger.error(f'Currency conversion failed ({cce})') + + msg = ( + f'Error: GEOPHIRES failed to convert your units for {ParamToModify.Name} to something it understands. ' + f'You gave {ParamToModify.CurrentUnits} - Are the units defined for Pint library, ' + f' or have you defined them in the user defined units file (GEOPHIRES3_newunits)? ' + f'Cannot continue. Exiting.' + ) + model.logger.critical(msg) + + raise RuntimeError(msg) + + model.logger.info(f'Complete {str(__name__)}: {sys._getframe().f_code.co_name}') -def parameter_with_units_converted_back_to_preferred_units(param: Parameter, model) -> Parameter: +def _parameter_with_currency_units_converted_back_to_preferred_units(param: Parameter, model) -> Parameter: + """ + TODO clean up and consolidate with pint-based conversion in ConvertUnitsBack + """ + param_with_units_converted_back = copy.deepcopy(param) # deal with the currency case @@ -651,7 +684,6 @@ def parameter_with_units_converted_back_to_preferred_units(param: Parameter, mod # this is true, then we just have a conversion between KUSD and USD, MUSD to KUSD, MUER to EUR, etc., # so just do the simple factor conversion param_with_units_converted_back.value = param.value * Factor - param_with_units_converted_back.UnitsMatch = True param_with_units_converted_back.CurrentUnits = currType return param_with_units_converted_back @@ -667,7 +699,7 @@ def parameter_with_units_converted_back_to_preferred_units(param: Parameter, mod msg = ( f'Error: GEOPHIRES failed to convert your currency for {param.Name} to something it understands.' f'You gave {currType} - Are these currency units defined for forex-python? ' - f'or perhaps the currency server is down? Please change your units to {param.PreferredUnits.value}' + f'or perhaps the currency server is down? Please change your units to {param.PreferredUnits.value} ' f'to continue. Cannot continue unless you do. Exiting.' ) print(msg) @@ -677,70 +709,13 @@ def parameter_with_units_converted_back_to_preferred_units(param: Parameter, mod raise RuntimeError(msg, ex) param_with_units_converted_back.value = (conv_rate * float(param.value)) / prefFactor - param_with_units_converted_back.UnitsMatch = False return param_with_units_converted_back else: - # must be something other than currency - if isinstance(param.CurrentUnits, pint.Quantity): - val = param.CurrentUnits.value - currType = str(param.CurrentUnits.value) - else: - if ' ' in param.CurrentUnits.value: - parts = param.CurrentUnits.value.split(' ') - val = parts[0].strip() - currType = parts[1].strip() - else: - val = param.value - currType = param.CurrentUnits.value - - try: - if isinstance(param.PreferredUnits, pint.Quantity): - prefQ = param.PreferredUnits - else: - # Make a Pint Quantity out of the old value - prefQ = param.PreferredUnits - if isinstance(param.CurrentUnits, pint.Quantity): - currQ = param.CurrentUnits - else: - currQ = _ureg.Quantity(float(val), currType) # Make a Pint Quantity out of the new value - except BaseException as ex: - print(str(ex)) - msg = ( - f'Error: GEOPHIRES failed to initialize your units for {param.Name} to something it understands. ' - f'You gave {currType} - Are the units defined for Pint library, ' - f'or have you defined them in the user defined units file (GEOPHIRES3_newunits)? ' - f'Cannot continue. Exiting.' - ) - print(msg) - model.logger.critical(str(ex)) - model.logger.critical(msg) - - raise RuntimeError(msg) - try: - # update The quantity back to the current units (the units that we started with) units - # so the display will be in the right units - currQ = currQ.to(prefQ) - except BaseException as ex: - print(str(ex)) - msg = ( - f'Error: GEOPHIRES failed to convert your units for {param.Name} to something it understands. ' - f'You gave {currType} - Are the units defined for Pint library, ' - f' or have you defined them in the user defined units file (GEOPHIRES3_newunits)? ' - f'Cannot continue. Exiting.' - ) - print(msg) - model.logger.critical(str(ex)) - model.logger.critical(msg) - - raise RuntimeError(msg) - - # reset the values - if param.value != currQ.magnitude: - param_with_units_converted_back.value = currQ.magnitude - param_with_units_converted_back.CurrentUnits = param.PreferredUnits - - return param_with_units_converted_back + raise AttributeError( + f'Unit/unit type ({param.CurrentUnits}/{param.UnitType} for {param.Name} ' + f'is not a recognized currency unit' + ) def LookupUnits(sUnitText: str): @@ -837,6 +812,9 @@ def ConvertOutputUnits(oparam: OutputParameter, newUnit: Units, model): """ ConvertOutputUnits Given an output parameter, convert the value(s) from what they contain (as calculated by GEOPHIRES) to what the user specified as what they want for outputs. Conversion happens inline. + + TODO switch to pint-based conversion like in ConvertUnitsBack + :param oparam: The parameter you want to be converted (value or list of values). Because Parameters know the PreferredUnits and CurrentUnits, this routine knows what to do. It will convert the value(s) in the parameter to the new units, and then reset the CurrentUnits to the new units. This is done so that the user can see the units @@ -1004,7 +982,6 @@ def ConvertOutputUnits(oparam: OutputParameter, newUnit: Units, model): # so just do the simple factor conversion and exit oparam.value = oparam.value * Factor oparam.CurrentUnits = DefUnit - # oparam.UnitsMatch = False return # start the currency conversion process @@ -1061,5 +1038,4 @@ def ConvertOutputUnits(oparam: OutputParameter, newUnit: Units, model): oparam.value = Factor * conv_rate * float(oparam.value) oparam.CurrentUnits = DefUnit - oparam.UnitsMatch = False model.logger.info(f'Complete {str(__name__)}: {sys._getframe().f_code.co_name}') diff --git a/src/geophires_x/Reservoir.py b/src/geophires_x/Reservoir.py index 40575891..22151699 100644 --- a/src/geophires_x/Reservoir.py +++ b/src/geophires_x/Reservoir.py @@ -94,13 +94,13 @@ def __init__(self, model: Model): ToolTipText="Number of rock segments from surface to reservoir depth with specific geothermal gradient" ) - self.gradient = self.ParameterDict[self.gradient.Name] = floatParameter( + self.gradient = self.ParameterDict[self.gradient.Name] = listParameter( "Gradients", DefaultValue=[0.05, 0.0, 0.0, 0.0], Min=0.0, Max=500.0, UnitType=Units.TEMP_GRADIENT, - PreferredUnits=TemperatureGradientUnit.DEGREESCPERM, + PreferredUnits=TemperatureGradientUnit.DEGREESCPERKM, CurrentUnits=TemperatureGradientUnit.DEGREESCPERM, Required=True, ErrMessage="assume default geothermal gradients 1 (50, 0, 0, 0 deg.C/km)", @@ -109,12 +109,12 @@ def __init__(self, model: Model): self.gradient1 = self.ParameterDict[self.gradient1.Name] = floatParameter( "Gradient 1", - DefaultValue=0.05, + DefaultValue=50, Min=0.0, Max=500.0, UnitType=Units.TEMP_GRADIENT, - PreferredUnits=TemperatureGradientUnit.DEGREESCPERM, - CurrentUnits=TemperatureGradientUnit.DEGREESCPERM, + PreferredUnits=TemperatureGradientUnit.DEGREESCPERKM, + CurrentUnits=TemperatureGradientUnit.DEGREESCPERKM, Required=True, ErrMessage="assume default geothermal gradient 1 (50 deg.C/km)", ToolTipText="Geothermal gradient 1 in rock segment 1" @@ -585,7 +585,6 @@ def read_parameters(self, model: Model) -> None: # FIXME TODO only convert if current units are km ParameterToModify.value = ParameterToModify.value * 1000 ParameterToModify.CurrentUnits = LengthUnit.METERS - ParameterToModify.UnitsMatch = False elif ParameterToModify.Name == "Reservoir Volume Option": if ParameterReadIn.sValue == '1': diff --git a/src/geophires_x/SUTRAWellBores.py b/src/geophires_x/SUTRAWellBores.py index b0dc73a3..5bcee0ee 100644 --- a/src/geophires_x/SUTRAWellBores.py +++ b/src/geophires_x/SUTRAWellBores.py @@ -253,11 +253,9 @@ def Calculate(self, model: Model) -> None: if self.injwelldiam.value > 2.0: self.injwelldiam.value = self.injwelldiam.value * 0.0254 self.injwelldiam.CurrentUnits = LengthUnit.METERS - self.injwelldiam.UnitsMatch = False if self.prodwelldiam.value > 2.0: self.prodwelldiam.value = self.prodwelldiam.value * 0.0254 self.prodwelldiam.CurrentUnits = LengthUnit.METERS - self.prodwelldiam.UnitsMatch = False # get wellbore flow rates from SUTRA data prodwellflowrates = np.append( diff --git a/src/geophires_x/WellBores.py b/src/geophires_x/WellBores.py index 7d383fb1..b7f609b7 100644 --- a/src/geophires_x/WellBores.py +++ b/src/geophires_x/WellBores.py @@ -1264,11 +1264,9 @@ def Calculate(self, model: Model) -> None: if self.injwelldiam.value > 2.0: self.injwelldiam.value = self.injwelldiam.value * 0.0254 self.injwelldiam.CurrentUnits = LengthUnit.METERS - self.injwelldiam.UnitsMatch = False if self.prodwelldiam.value > 2.0: self.prodwelldiam.value = self.prodwelldiam.value * 0.0254 self.prodwelldiam.CurrentUnits = LengthUnit.METERS - self.prodwelldiam.UnitsMatch = False # calculate wellbore temperature drop self.ProdTempDrop.value = self.tempdropprod.value # if not Ramey, hard code a user-supplied temperature drop. diff --git a/src/geophires_x/__init__.py b/src/geophires_x/__init__.py index fc33c0e0..9ebc1e15 100644 --- a/src/geophires_x/__init__.py +++ b/src/geophires_x/__init__.py @@ -1 +1 @@ -__version__ = '3.4.35' +__version__ = '3.4.36' diff --git a/src/geophires_x_schema_generator/geophires-request.json b/src/geophires_x_schema_generator/geophires-request.json index 289af2f8..dfaf6ec0 100644 --- a/src/geophires_x_schema_generator/geophires-request.json +++ b/src/geophires_x_schema_generator/geophires-request.json @@ -79,7 +79,7 @@ }, "Gradients": { "description": "Geothermal gradients", - "type": "number", + "type": "array", "units": "degC/m", "category": "Reservoir", "default": [ @@ -94,9 +94,9 @@ "Gradient 1": { "description": "Geothermal gradient 1 in rock segment 1", "type": "number", - "units": "degC/m", + "units": "degC/km", "category": "Reservoir", - "default": 0.05, + "default": 50, "minimum": 0.0, "maximum": 500.0 }, @@ -1600,6 +1600,15 @@ "minimum": null, "maximum": null }, + "Estimated Jobs Created per MW of Electricity Produced": { + "description": "Estimated jobs created per MW of electricity produced, per https://geothermal.org/resources/geothermal-basics", + "type": "number", + "units": null, + "category": "Economics", + "default": 2.13, + "minimum": -1.8e+30, + "maximum": 1.8e+30 + }, "Operation & Maintenance Cost of Surface Plant": { "description": "", "type": "number", diff --git a/src/hip_ra/HIP_RA.py b/src/hip_ra/HIP_RA.py index ad0fc2eb..250f79ba 100755 --- a/src/hip_ra/HIP_RA.py +++ b/src/hip_ra/HIP_RA.py @@ -668,7 +668,6 @@ def read_parameters(self) -> None: self.OutputParameterDict[key.replace('Units:', '')].CurrentUnits = LookupUnits( self.InputParameters[key].sValue )[0] - self.OutputParameterDict[key.replace('Units:', '')].UnitsMatch = False self.logger.info(f'complete {__class__!s}: {sys._getframe().f_code.co_name}') diff --git a/src/hip_ra_x/hip_ra_x.py b/src/hip_ra_x/hip_ra_x.py index 9b841582..810b9f5b 100644 --- a/src/hip_ra_x/hip_ra_x.py +++ b/src/hip_ra_x/hip_ra_x.py @@ -628,7 +628,6 @@ def read_parameters(self) -> None: self.OutputParameterDict[key.replace('Units:', '')].CurrentUnits = LookupUnits( self.InputParameters[key].sValue )[0] - self.OutputParameterDict[key.replace('Units:', '')].UnitsMatch = False self.logger.info(f'complete {__class__.__name__!s}: {__name__}') diff --git a/tests/example1_addons.csv b/tests/example1_addons.csv index ecb17897..fe067704 100644 --- a/tests/example1_addons.csv +++ b/tests/example1_addons.csv @@ -6,7 +6,7 @@ SUMMARY OF RESULTS,Number of production wells,,2,count SUMMARY OF RESULTS,Number of injection wells,,2,count SUMMARY OF RESULTS,Flowrate per production well,,55.0,kg/sec SUMMARY OF RESULTS,"Well depth (or total length\, if not vertical)",,3.0,kilometer -SUMMARY OF RESULTS,Geothermal gradient,,0.05,degC/m +SUMMARY OF RESULTS,Geothermal gradient,,50,degC/km SUMMARY OF RESULTS,Total Avoided Carbon Emissions,,472017.81, ECONOMIC PARAMETERS,Economic Model,,Fixed Charge Rate (FCR), ECONOMIC PARAMETERS,Accrued financing during construction,,0.0, @@ -47,7 +47,7 @@ ENGINEERING PARAMETERS,Number of times redrilling,,0,count ENGINEERING PARAMETERS,Power plant type,,Supercritical ORC, RESOURCE CHARACTERISTICS,Maximum reservoir temperature,,400.0,degC RESOURCE CHARACTERISTICS,Number of segments,,1,count -RESOURCE CHARACTERISTICS,Geothermal gradient,,0.05,degC/m +RESOURCE CHARACTERISTICS,Geothermal gradient,,50,degC/km RESERVOIR PARAMETERS,Reservoir Model,,Multiple Parallel Fractures Model, RESERVOIR PARAMETERS,Fracture model,,Square, RESERVOIR PARAMETERS,Bottom-hole temperature,,170.0,degC diff --git a/tests/examples/Fervo_Norbeck_Latimer_2023.out b/tests/examples/Fervo_Norbeck_Latimer_2023.out index 110cf38a..9b48804e 100644 --- a/tests/examples/Fervo_Norbeck_Latimer_2023.out +++ b/tests/examples/Fervo_Norbeck_Latimer_2023.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:57 - Calculation Time: 0.345 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:42 + Calculation Time: 0.336 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 1 Flowrate per production well: 41.0 kg/sec Well depth (or total length, if not vertical): 2.3 kilometer - Geothermal gradient: 0.0767 degC/m + Geothermal gradient: 76.74 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +55,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0767 degC/m + Geothermal gradient: 76.74 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/Wanju_Yuan_Closed-Loop_Geothermal_Energy_Recovery.out b/tests/examples/Wanju_Yuan_Closed-Loop_Geothermal_Energy_Recovery.out index 3711d508..b164cd35 100644 --- a/tests/examples/Wanju_Yuan_Closed-Loop_Geothermal_Energy_Recovery.out +++ b/tests/examples/Wanju_Yuan_Closed-Loop_Geothermal_Energy_Recovery.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:56 - Calculation Time: 1.619 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:42 + Calculation Time: 1.614 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 1 Flowrate per production well: 110.0 kg/sec Well depth (or total length, if not vertical): 4.0 kilometer - Geothermal gradient: 0.0262 degC/m + Geothermal gradient: 26.25 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +55,7 @@ Simulation Metadata Maximum reservoir temperature: 375.0 degC Number of segments: 1 - Geothermal gradient: 0.0262 degC/m + Geothermal gradient: 26.25 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example1.out b/tests/examples/example1.out index 88cd695a..5297ae23 100644 --- a/tests/examples/example1.out +++ b/tests/examples/example1.out @@ -5,8 +5,8 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:53 + Simulation Date: 2024-06-19 + Simulation Time: 07:42 Calculation Time: 0.609 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 55.0 kg/sec Well depth (or total length, if not vertical): 3.0 kilometer - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example10_HP.out b/tests/examples/example10_HP.out index a3373876..eb006d71 100644 --- a/tests/examples/example10_HP.out +++ b/tests/examples/example10_HP.out @@ -4,10 +4,10 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.29 - Simulation Date: 2024-05-15 - Simulation Time: 12:01 - Calculation Time: 0.107 sec + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:42 + Calculation Time: 0.104 sec ***SUMMARY OF RESULTS*** @@ -19,7 +19,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 70.0 kg/sec Well depth (or total length, if not vertical): 2.1 kilometer - Geothermal gradient: 0.0450 degC/m + Geothermal gradient: 45 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +55,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0450 degC/m + Geothermal gradient: 45 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example11_AC.out b/tests/examples/example11_AC.out index 41b7fbf7..822c3601 100644 --- a/tests/examples/example11_AC.out +++ b/tests/examples/example11_AC.out @@ -4,10 +4,10 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.31 - Simulation Date: 2024-06-17 - Simulation Time: 06:45 - Calculation Time: 0.110 sec + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:42 + Calculation Time: 0.106 sec ***SUMMARY OF RESULTS*** @@ -20,7 +20,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 50.0 kg/sec Well depth (or total length, if not vertical): 2.1 kilometer - Geothermal gradient: 0.0450 degC/m + Geothermal gradient: 45 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0450 degC/m + Geothermal gradient: 45 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example12_DH.out b/tests/examples/example12_DH.out index a4ec4b9d..fd75697a 100644 --- a/tests/examples/example12_DH.out +++ b/tests/examples/example12_DH.out @@ -4,9 +4,9 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.29 - Simulation Date: 2024-05-15 - Simulation Time: 11:53 + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:43 Calculation Time: 0.111 sec ***SUMMARY OF RESULTS*** @@ -22,7 +22,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 50.0 kg/sec Well depth (or total length, if not vertical): 3.5 kilometer - Geothermal gradient: 0.0295 degC/m + Geothermal gradient: 29.5 degC/km ***ECONOMIC PARAMETERS*** @@ -58,7 +58,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0295 degC/m + Geothermal gradient: 29.5 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example13.out b/tests/examples/example13.out index c29e34f8..e79fbc2a 100644 --- a/tests/examples/example13.out +++ b/tests/examples/example13.out @@ -4,10 +4,10 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.29 - Simulation Date: 2024-05-15 - Simulation Time: 11:52 - Calculation Time: 0.037 sec + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.034 sec ***SUMMARY OF RESULTS*** @@ -20,7 +20,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 50.0 kg/sec Well depth (or total length, if not vertical): 4.0 kilometer - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***ECONOMIC PARAMETERS*** @@ -58,7 +58,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example1_addons.out b/tests/examples/example1_addons.out index 0e43fe4a..7af1d09f 100644 --- a/tests/examples/example1_addons.out +++ b/tests/examples/example1_addons.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:52 - Calculation Time: 0.590 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.594 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 55.0 kg/sec Well depth (or total length, if not vertical): 3.0 kilometer - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km Total Avoided Carbon Emissions: 472017.81 metric tonnes @@ -57,7 +57,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example1_outputunits.out b/tests/examples/example1_outputunits.out index d152cf44..86d09793 100644 --- a/tests/examples/example1_outputunits.out +++ b/tests/examples/example1_outputunits.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:53 - Calculation Time: 0.595 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.587 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 55.0 kg/sec Well depth (or total length, if not vertical): 3.0 kilometer - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example2.out b/tests/examples/example2.out index fb4ab5bc..1b9b377c 100644 --- a/tests/examples/example2.out +++ b/tests/examples/example2.out @@ -4,11 +4,10 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.28 - GEOPHIRES Build Date: 2024-03-05 - Simulation Date: 2024-05-14 - Simulation Time: 17:14 - Calculation Time: 0.541 sec + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.210 sec ***SUMMARY OF RESULTS*** @@ -19,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 30.0 kg/sec Well depth (or total length, if not vertical): 3.0 kilometer - Geothermal gradient: 0.0550 degC/m + Geothermal gradient: 55 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +54,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0550 degC/m + Geothermal gradient: 55 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example3.out b/tests/examples/example3.out index 837a09a4..5a5cd474 100644 --- a/tests/examples/example3.out +++ b/tests/examples/example3.out @@ -4,10 +4,10 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.29 - Simulation Date: 2024-05-15 - Simulation Time: 11:52 - Calculation Time: 0.131 sec + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.126 sec ***SUMMARY OF RESULTS*** @@ -20,7 +20,7 @@ Simulation Metadata Number of injection wells: 3 Flowrate per production well: 70.0 kg/sec Well depth (or total length, if not vertical): 3.1 kilometer - Geothermal gradient: 0.0700 degC/m + Geothermal gradient: 70 degC/km ***ECONOMIC PARAMETERS*** @@ -57,7 +57,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0700 degC/m + Geothermal gradient: 70 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example4.out b/tests/examples/example4.out index d49d6d5c..b9052feb 100644 --- a/tests/examples/example4.out +++ b/tests/examples/example4.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:53 - Calculation Time: 0.054 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.049 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 110.0 kg/sec Well depth (or total length, if not vertical): 2.0 kilometer - Geothermal gradient: 0.0650 degC/m + Geothermal gradient: 65 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +55,7 @@ Simulation Metadata Maximum reservoir temperature: 375.0 degC Number of segments: 1 - Geothermal gradient: 0.0650 degC/m + Geothermal gradient: 65 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example5.out b/tests/examples/example5.out index bcbc9f11..fcd3018d 100644 --- a/tests/examples/example5.out +++ b/tests/examples/example5.out @@ -4,11 +4,10 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.28 - GEOPHIRES Build Date: 2024-03-05 - Simulation Date: 2024-05-14 - Simulation Time: 17:14 - Calculation Time: 0.161 sec + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.049 sec ***SUMMARY OF RESULTS*** @@ -19,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 50.0 kg/sec Well depth (or total length, if not vertical): 3.0 kilometer - Geothermal gradient: 0.0450 degC/m + Geothermal gradient: 45 degC/km ***ECONOMIC PARAMETERS*** @@ -54,7 +53,7 @@ Simulation Metadata Maximum reservoir temperature: 375.0 degC Number of segments: 1 - Geothermal gradient: 0.0450 degC/m + Geothermal gradient: 45 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example8.out b/tests/examples/example8.out index 837f3606..5c5b042f 100644 --- a/tests/examples/example8.out +++ b/tests/examples/example8.out @@ -4,11 +4,10 @@ Simulation Metadata ---------------------- - GEOPHIRES Version: 3.4.28 - GEOPHIRES Build Date: 2024-03-05 - Simulation Date: 2024-05-14 - Simulation Time: 17:14 - Calculation Time: 1.568 sec + GEOPHIRES Version: 3.4.34 + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.601 sec ***SUMMARY OF RESULTS*** @@ -19,7 +18,7 @@ Simulation Metadata Number of injection wells: 1 Flowrate per production well: 40.0 kg/sec Well depth (or total length, if not vertical): 2.8 kilometer - Geothermal gradient: 0.0280 degC/m + Geothermal gradient: 28 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +54,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0280 degC/m + Geothermal gradient: 28 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example9.out b/tests/examples/example9.out index 2961bff8..72b2ab80 100644 --- a/tests/examples/example9.out +++ b/tests/examples/example9.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:54 - Calculation Time: 0.604 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.591 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 1 Flowrate per production well: 40.0 kg/sec Well depth (or total length, if not vertical): 3.8 kilometer - Geothermal gradient: 0.0280 degC/m + Geothermal gradient: 28 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0280 degC/m + Geothermal gradient: 28 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example_ITC.out b/tests/examples/example_ITC.out index 7d92eda4..52cbea37 100644 --- a/tests/examples/example_ITC.out +++ b/tests/examples/example_ITC.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:54 - Calculation Time: 0.600 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:43 + Calculation Time: 0.596 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 55.0 kg/sec Well depth (or total length, if not vertical): 5.0 kilometer - Geothermal gradient: 0.0550 degC/m + Geothermal gradient: 55 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +55,7 @@ Simulation Metadata Maximum reservoir temperature: 500.0 degC Number of segments: 1 - Geothermal gradient: 0.0550 degC/m + Geothermal gradient: 55 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example_PTC.out b/tests/examples/example_PTC.out index 17e97297..ccbdc3a4 100644 --- a/tests/examples/example_PTC.out +++ b/tests/examples/example_PTC.out @@ -5,8 +5,8 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:53 + Simulation Date: 2024-06-19 + Simulation Time: 07:43 Calculation Time: 0.593 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 55.0 kg/sec Well depth (or total length, if not vertical): 5.0 kilometer - Geothermal gradient: 0.0550 degC/m + Geothermal gradient: 55 degC/km ***ECONOMIC PARAMETERS*** @@ -55,7 +55,7 @@ Simulation Metadata Maximum reservoir temperature: 500.0 degC Number of segments: 1 - Geothermal gradient: 0.0550 degC/m + Geothermal gradient: 55 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example_SHR-1.out b/tests/examples/example_SHR-1.out index 07b6f267..3d3441a7 100644 --- a/tests/examples/example_SHR-1.out +++ b/tests/examples/example_SHR-1.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:54 - Calculation Time: 0.591 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:44 + Calculation Time: 0.587 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 55.0 kg/sec Well depth (or total length, if not vertical): 7.5 kilometer - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 500.0 degC Number of segments: 1 - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example_SHR-2.out b/tests/examples/example_SHR-2.out index 839300da..6d250020 100644 --- a/tests/examples/example_SHR-2.out +++ b/tests/examples/example_SHR-2.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:54 - Calculation Time: 0.604 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:44 + Calculation Time: 0.593 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 55.0 kg/sec Well depth (or total length, if not vertical): 7.5 kilometer - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 500.0 degC Number of segments: 1 - Geothermal gradient: 0.0500 degC/m + Geothermal gradient: 50 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example_multiple_gradients.out b/tests/examples/example_multiple_gradients.out index 69e915e0..f73cb7de 100644 --- a/tests/examples/example_multiple_gradients.out +++ b/tests/examples/example_multiple_gradients.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:54 - Calculation Time: 0.606 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:44 + Calculation Time: 0.596 sec ***SUMMARY OF RESULTS*** @@ -18,13 +18,13 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 60.0 kg/sec Well depth (or total length, if not vertical): 4.0 kilometer - Segment 1 Geothermal gradient: 0.0500 degC/m - Segment 1 Thickness: 1000 meter - Segment 2 Geothermal gradient: 0.0400 degC/m - Segment 2 Thickness: 1000 meter - Segment 3 Geothermal gradient: 0.0300 degC/m - Segment 3 Thickness: 1000 meter - Segment 4 Geothermal gradient: 0.0500 degC/m + Segment 1 Geothermal gradient: 50 degC/km + Segment 1 Thickness: 1 kilometer + Segment 2 Geothermal gradient: 40 degC/km + Segment 2 Thickness: 1 kilometer + Segment 3 Geothermal gradient: 30 degC/km + Segment 3 Thickness: 1 kilometer + Segment 4 Geothermal gradient: 50 degC/km ***ECONOMIC PARAMETERS*** @@ -62,13 +62,13 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 4 - Segment 1 Geothermal gradient: 0.0500 degC/m - Segment 1 Thickness: 1000 meter - Segment 2 Geothermal gradient: 0.0400 degC/m - Segment 2 Thickness: 1000 meter - Segment 3 Geothermal gradient: 0.0300 degC/m - Segment 3 Thickness: 1000 meter - Segment 4 Geothermal gradient: 0.0500 degC/m + Segment 1 Geothermal gradient: 50 degC/km + Segment 1 Thickness: 1 kilometer + Segment 2 Geothermal gradient: 40 degC/km + Segment 2 Thickness: 1 kilometer + Segment 3 Geothermal gradient: 30 degC/km + Segment 3 Thickness: 1 kilometer + Segment 4 Geothermal gradient: 50 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example_overpressure.out b/tests/examples/example_overpressure.out index afc432ae..a1eee6dc 100644 --- a/tests/examples/example_overpressure.out +++ b/tests/examples/example_overpressure.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:53 - Calculation Time: 0.595 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:44 + Calculation Time: 0.591 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 70.0 kg/sec Well depth (or total length, if not vertical): 3.0 kilometer - Geothermal gradient: 0.0470 degC/m + Geothermal gradient: 47 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0470 degC/m + Geothermal gradient: 47 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/examples/example_overpressure2.out b/tests/examples/example_overpressure2.out index a84b8766..698c8ee7 100644 --- a/tests/examples/example_overpressure2.out +++ b/tests/examples/example_overpressure2.out @@ -5,9 +5,9 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.4.34 - Simulation Date: 2024-06-18 - Simulation Time: 15:54 - Calculation Time: 0.606 sec + Simulation Date: 2024-06-19 + Simulation Time: 07:44 + Calculation Time: 0.592 sec ***SUMMARY OF RESULTS*** @@ -18,7 +18,7 @@ Simulation Metadata Number of injection wells: 2 Flowrate per production well: 70.0 kg/sec Well depth (or total length, if not vertical): 3.0 kilometer - Geothermal gradient: 0.0470 degC/m + Geothermal gradient: 47 degC/km ***ECONOMIC PARAMETERS*** @@ -56,7 +56,7 @@ Simulation Metadata Maximum reservoir temperature: 400.0 degC Number of segments: 1 - Geothermal gradient: 0.0470 degC/m + Geothermal gradient: 47 degC/km ***RESERVOIR PARAMETERS*** diff --git a/tests/test_geophires_x.py b/tests/test_geophires_x.py index da0b6d26..02ca2d2e 100644 --- a/tests/test_geophires_x.py +++ b/tests/test_geophires_x.py @@ -331,6 +331,23 @@ def test_input_unit_conversion(self): self.assertDictEqual(result_kilometers_input.result, result_meters_input.result) + result_gradient_c_per_m_input = client.get_geophires_result( + GeophiresInputParameters( + from_file_path=self._get_test_file_path(Path('examples/example1.txt')), + params={ + 'Gradient 1': 0.017 # Values less than 1.0 interpreted as being in degC/m (instead of degC/km) + }, + ) + ) + del result_gradient_c_per_m_input.result['metadata'] + + self.assertEqual( + result_gradient_c_per_m_input.result['SUMMARY OF RESULTS']['Geothermal gradient']['value'], 17.0 + ) + self.assertEqual( + result_gradient_c_per_m_input.result['SUMMARY OF RESULTS']['Geothermal gradient']['unit'], 'degC/km' + ) + def test_fcr_sensitivity(self): def input_for_fcr(fcr: float) -> GeophiresInputParameters: return GeophiresInputParameters( diff --git a/tests/test_geophires_x_client.py b/tests/test_geophires_x_client.py index 15bfb99c..fa4c1625 100644 --- a/tests/test_geophires_x_client.py +++ b/tests/test_geophires_x_client.py @@ -107,23 +107,23 @@ def test_example_multiple_gradients_result(self): categories = ['SUMMARY OF RESULTS', 'RESOURCE CHARACTERISTICS'] for category in categories: - assert result.result[category]['Segment 1 Geothermal gradient']['value'] == 0.0500 - assert result.result[category]['Segment 1 Geothermal gradient']['unit'] == 'degC/m' - assert result.result[category]['Segment 1 Thickness']['value'] == 1000 - assert result.result[category]['Segment 1 Thickness']['unit'] == 'meter' - - assert result.result[category]['Segment 2 Geothermal gradient']['value'] == 0.0400 - assert result.result[category]['Segment 2 Geothermal gradient']['unit'] == 'degC/m' - assert result.result[category]['Segment 2 Thickness']['value'] == 1000 - assert result.result[category]['Segment 2 Thickness']['unit'] == 'meter' - - assert result.result[category]['Segment 3 Geothermal gradient']['value'] == 0.0300 - assert result.result[category]['Segment 3 Geothermal gradient']['unit'] == 'degC/m' - assert result.result[category]['Segment 3 Thickness']['value'] == 1000 - assert result.result[category]['Segment 3 Thickness']['unit'] == 'meter' - - assert result.result[category]['Segment 4 Geothermal gradient']['value'] == 0.0500 - assert result.result[category]['Segment 4 Geothermal gradient']['unit'] == 'degC/m' + assert result.result[category]['Segment 1 Geothermal gradient']['value'] == 50 + assert result.result[category]['Segment 1 Geothermal gradient']['unit'] == 'degC/km' + assert result.result[category]['Segment 1 Thickness']['value'] == 1 + assert result.result[category]['Segment 1 Thickness']['unit'] == 'kilometer' + + assert result.result[category]['Segment 2 Geothermal gradient']['value'] == 40 + assert result.result[category]['Segment 2 Geothermal gradient']['unit'] == 'degC/km' + assert result.result[category]['Segment 2 Thickness']['value'] == 1 + assert result.result[category]['Segment 2 Thickness']['unit'] == 'kilometer' + + assert result.result[category]['Segment 3 Geothermal gradient']['value'] == 30 + assert result.result[category]['Segment 3 Geothermal gradient']['unit'] == 'degC/km' + assert result.result[category]['Segment 3 Thickness']['value'] == 1 + assert result.result[category]['Segment 3 Thickness']['unit'] == 'kilometer' + + assert result.result[category]['Segment 4 Geothermal gradient']['value'] == 50 + assert result.result[category]['Segment 4 Geothermal gradient']['unit'] == 'degC/km' def test_example_absorption_chiller_result(self): test_result_path = self._get_test_file_path('examples/example11_AC.out') diff --git a/tests/test_parameter.py b/tests/test_parameter.py index 33c8f333..59262226 100644 --- a/tests/test_parameter.py +++ b/tests/test_parameter.py @@ -4,11 +4,13 @@ from pathlib import Path from geophires_x.Model import Model +from geophires_x.Parameter import ConvertUnitsBack from geophires_x.Parameter import OutputParameter from geophires_x.Parameter import Parameter from geophires_x.Parameter import floatParameter from geophires_x.Parameter import listParameter -from geophires_x.Parameter import parameter_with_units_converted_back_to_preferred_units +from geophires_x.Units import CostPerMassUnit +from geophires_x.Units import CurrencyUnit from geophires_x.Units import EnergyCostUnit from geophires_x.Units import LengthUnit from geophires_x.Units import PressureUnit @@ -31,17 +33,17 @@ def test_convert_units_back(self): UnitType=Units.LENGTH, PreferredUnits=LengthUnit.INCHES, CurrentUnits=LengthUnit.METERS, - UnitsMatch=False, value=0.17779999999999999, DefaultValue=8.0, Min=1.0, Max=30.0, ) + self.assertFalse(param_to_modify.UnitsMatch) - result = parameter_with_units_converted_back_to_preferred_units(param_to_modify, model) + ConvertUnitsBack(param_to_modify, model) - self.assertEqual(result.value, 7.0) - self.assertEqual(result.CurrentUnits, LengthUnit.INCHES) + self.assertEqual(param_to_modify.value, 7.0) + self.assertEqual(param_to_modify.CurrentUnits, LengthUnit.INCHES) def test_set_default_value(self): without_val = floatParameter( @@ -149,6 +151,35 @@ def test_output_parameter_with_preferred_units(self): self.assertEqual(5.5, result.value[0]) self.assertEqual(5.5, result.value[-1]) + def test_convert_units_back_currency(self): + model = self._new_model() + + param = floatParameter( + 'CAPEX', + DefaultValue=1379.0, + UnitType=Units.COSTPERMASS, + PreferredUnits=CostPerMassUnit.DOLLARSPERMT, + CurrentUnits=CostPerMassUnit.CENTSSPERMT, + ) + + ConvertUnitsBack(param, model) + self.assertEqual(param.CurrentUnits, CostPerMassUnit.DOLLARSPERMT) + self.assertAlmostEqual(param.value, 13.79, places=2) + + with self.assertRaises(RuntimeError) as re: + # TODO update once https://github.com/NREL/GEOPHIRES-X/issues/236?title=Currency+conversions+disabled is + # addressed + param2 = floatParameter( + 'OPEX', + DefaultValue=240, + UnitType=Units.CURRENCY, + PreferredUnits=CurrencyUnit.DOLLARS, + CurrentUnits=CurrencyUnit.EUR, + ) + ConvertUnitsBack(param2, model) + + self.assertIn('GEOPHIRES failed to convert your units for OPEX', str(re)) + def _new_model(self) -> Model: stash_cwd = Path.cwd() stash_sys_argv = sys.argv