Skip to content

Commit c36e267

Browse files
WorkingFluid enum values NREL#245
1 parent 28298eb commit c36e267

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

src/geophires_x/OptionList.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def from_input_string(input_string: str):
194194
raise ValueError(f'Unknown Well Drilling Cost Correlation input value: {input_string}')
195195

196196

197-
198197
class FractureShape(GeophiresInputEnum):
199198
CIRCULAR_AREA = 1, "Circular fracture with known area"
200199
CIRCULAR_DIAMETER = 2, "Circular fracture with known diameter"
@@ -215,9 +214,26 @@ def from_input_string(input_string:str):
215214

216215
raise ValueError(f'Unknown Fracture Shape input value: {input_string}')
217216

218-
class WorkingFluid(str, Enum):
219-
WATER = "water"
220-
SCO2 = "sCO2"
217+
218+
class WorkingFluid(GeophiresInputEnum):
219+
WATER = 1, "water"
220+
SCO2 = 2, "sCO2"
221+
222+
@staticmethod
223+
def from_int(int_val):
224+
for member in __class__:
225+
if member.int_value == int_val:
226+
return member
227+
228+
@staticmethod
229+
def from_input_string(input_string: str):
230+
for member in __class__:
231+
if input_string == str(member.int_value):
232+
return member
233+
234+
raise ValueError(f'Unknown Working Fluid input value: {input_string}')
235+
236+
221237

222238

223239
class Configuration(str, Enum):

src/geophires_x/WellBores.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import numpy as np
33
from pint.facets.plain import PlainQuantity
44

5-
from .Parameter import floatParameter, intParameter, boolParameter, OutputParameter, ReadParameter
5+
from .Parameter import floatParameter, intParameter, boolParameter, OutputParameter, ReadParameter, \
6+
coerce_int_params_to_enum_values
67
from geophires_x.GeoPHIRESUtils import vapor_pressure_water_kPa, quantity, static_pressure_MPa
78
from geophires_x.GeoPHIRESUtils import density_water_kg_per_m3
89
from geophires_x.GeoPHIRESUtils import viscosity_water_Pa_sec
@@ -917,11 +918,13 @@ def __init__(self, model: Model):
917918

918919
self.Fluid = self.ParameterDict[self.Fluid.Name] = intParameter(
919920
"Heat Transfer Fluid",
920-
DefaultValue=WorkingFluid.WATER,
921+
DefaultValue=WorkingFluid.WATER.int_value,
921922
AllowableRange=[1, 2],
923+
ValuesEnum=WorkingFluid,
922924
UnitType=Units.NONE,
923925
Required=True,
924-
ErrMessage="assume default Heat transfer fluid is water (1)"
926+
ErrMessage="assume default Heat transfer fluid is water (1)",
927+
ToolTipText='; '.join([f'{it.int_value}: {it.value}' for it in WorkingFluid])
925928
)
926929

927930
# Input data for subsurface condition
@@ -1136,15 +1139,13 @@ def read_parameters(self, model: Model) -> None:
11361139

11371140
# handle special cases
11381141
if ParameterToModify.Name == "Heat Transfer Fluid":
1139-
if ParameterReadIn.sValue == str(1):
1140-
self.Fluid.value = WorkingFluid.WATER
1141-
else:
1142-
self.Fluid.value = WorkingFluid.SCO2
1143-
# IsAGS is false by default - if it equal 1, then it is true
1142+
self.Fluid.value = WorkingFluid.from_input_string(ParameterReadIn.sValue)
1143+
1144+
# IsAGS is false by default - if it equals 1, then it is true
11441145
if ParameterToModify.Name == "Ramey Production Wellbore Model":
11451146
if ParameterReadIn.sValue == '0':
11461147
ParameterToModify.value = False
1147-
# Ramey Production Wellbore Model is true by default - if it equal 0, then it is false
1148+
# Ramey Production Wellbore Model is true by default - if it equals 0, then it is false
11481149
elif ParameterToModify.Name == "Is AGS":
11491150
if ParameterReadIn.sValue == '1':
11501151
ParameterToModify.value = True
@@ -1180,6 +1181,9 @@ def read_parameters(self, model: Model) -> None:
11801181
raise ValueError(f'Invalid Configuration: {self.Configuration.value}')
11811182
else:
11821183
model.logger.info("No parameters read because no content provided")
1184+
1185+
coerce_int_params_to_enum_values(self.ParameterDict)
1186+
11831187
model.logger.info(f"read parameters complete {self.__class__.__name__}: {__name__}")
11841188

11851189
def Calculate(self, model: Model) -> None:

src/geophires_x_schema_generator/geophires-request.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,13 +724,25 @@
724724
"maximum": 100.0
725725
},
726726
"Heat Transfer Fluid": {
727-
"description": "",
727+
"description": "1: water; 2: sCO2",
728728
"type": "integer",
729729
"units": null,
730730
"category": "Well Bores",
731-
"default": "water",
731+
"default": 1,
732732
"minimum": 1,
733-
"maximum": 2
733+
"maximum": 2,
734+
"enum_values": [
735+
{
736+
"name": "WATER",
737+
"value": "water",
738+
"int_value": 1
739+
},
740+
{
741+
"name": "SCO2",
742+
"value": "sCO2",
743+
"int_value": 2
744+
}
745+
]
734746
},
735747
"Total Nonvertical Length": {
736748
"description": "",

0 commit comments

Comments
 (0)