Skip to content

Commit 36f35f2

Browse files
WorkingFluid enum values
1 parent 53d1ccc commit 36f35f2

File tree

3 files changed

+80
-25
lines changed

3 files changed

+80
-25
lines changed

src/geophires_x/OptionList.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
class GeophiresInputEnum(str, Enum):
77
"""
88
Input enums have a name, integer input value, and string value
9+
10+
TODO implement from_int/from_input_string here instead of child classes
911
"""
1012

1113
def __new__(cls, *args, **kwds):
@@ -236,8 +238,22 @@ def from_input_string(input_string: str):
236238

237239

238240

239-
class Configuration(str, Enum):
240-
ULOOP = "utube"
241-
COAXIAL = "coaxial"
242-
VERTICAL = "vertical"
243-
L = "L"
241+
class Configuration(GeophiresInputEnum):
242+
ULOOP = 1, "utube"
243+
COAXIAL = 2, "coaxial"
244+
VERTICAL = 3, "vertical"
245+
L = 4, "L"
246+
247+
@staticmethod
248+
def from_int(int_val):
249+
for member in __class__:
250+
if member.int_value == int_val:
251+
return member
252+
253+
@staticmethod
254+
def from_input_string(input_string: str):
255+
for member in __class__:
256+
if input_string == str(member.int_value):
257+
return member
258+
259+
raise ValueError(f'Unknown Configuration input value: {input_string}')

src/geophires_x/WellBores.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -888,20 +888,24 @@ def __init__(self, model: Model):
888888
# This is a alias for "Well Geometry Configuration" - putting it here for backwards compatibility
889889
self.Configuration = self.ParameterDict[self.Configuration.Name] = intParameter(
890890
"Closed-loop Configuration",
891-
DefaultValue=Configuration.VERTICAL,
891+
DefaultValue=Configuration.VERTICAL.int_value,
892892
AllowableRange=[1, 2, 3, 4],
893+
ValuesEnum=Configuration,
893894
UnitType=Units.NONE,
894895
Required=True,
895-
ErrMessage="assume simple vertical well (3)"
896+
ErrMessage="assume simple vertical well (3)",
897+
ToolTipText = '; '.join([f'{it.int_value}: {it.value}' for it in Configuration])
896898
)
897899
# This is a alias for "Closed-loop Configuration" - putting it here for backwards compatibility
898900
self.Configuration = self.ParameterDict[self.Configuration.Name] = intParameter(
899901
"Well Geometry Configuration",
900-
DefaultValue=Configuration.VERTICAL,
902+
DefaultValue=Configuration.VERTICAL.int_value,
901903
AllowableRange=[1, 2, 3, 4],
904+
ValuesEnum=Configuration,
902905
UnitType=Units.NONE,
903906
Required=True,
904-
ErrMessage="assume simple vertical well (3)"
907+
ErrMessage="assume simple vertical well (3)",
908+
ToolTipText='; '.join([f'{it.int_value}: {it.value}' for it in Configuration])
905909
)
906910

907911
self.WaterThermalConductivity = self.ParameterDict[self.WaterThermalConductivity.Name] = floatParameter(
@@ -1169,16 +1173,7 @@ def read_parameters(self, model: Model) -> None:
11691173
self.usebuiltinppwellheadcorrelation = False
11701174
elif (ParameterToModify.Name == "Closed-loop Configuration" or
11711175
ParameterToModify.Name == "Well Geometry Configuration"): # These two are alias of each other
1172-
if ParameterReadIn.sValue == str(1):
1173-
self.Configuration.value = Configuration.ULOOP
1174-
elif ParameterReadIn.sValue == str(2):
1175-
self.Configuration.value = Configuration.COAXIAL
1176-
elif ParameterReadIn.sValue == str(3):
1177-
self.Configuration.value = Configuration.VERTICAL
1178-
elif ParameterReadIn.sValue == str(4):
1179-
self.Configuration.value = Configuration.L
1180-
else:
1181-
raise ValueError(f'Invalid Configuration: {self.Configuration.value}')
1176+
self.Configuration.value = Configuration.from_input_string(ParameterReadIn.sValue)
11821177
else:
11831178
model.logger.info("No parameters read because no content provided")
11841179

src/geophires_x_schema_generator/geophires-request.json

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,22 +697,66 @@
697697
"maximum": 1.8e+30
698698
},
699699
"Closed-loop Configuration": {
700-
"description": "",
700+
"description": "1: utube; 2: coaxial; 3: vertical; 4: L",
701701
"type": "integer",
702702
"units": null,
703703
"category": "Well Bores",
704-
"default": "vertical",
704+
"default": 3,
705705
"minimum": 1,
706-
"maximum": 4
706+
"maximum": 4,
707+
"enum_values": [
708+
{
709+
"name": "ULOOP",
710+
"value": "utube",
711+
"int_value": 1
712+
},
713+
{
714+
"name": "COAXIAL",
715+
"value": "coaxial",
716+
"int_value": 2
717+
},
718+
{
719+
"name": "VERTICAL",
720+
"value": "vertical",
721+
"int_value": 3
722+
},
723+
{
724+
"name": "L",
725+
"value": "L",
726+
"int_value": 4
727+
}
728+
]
707729
},
708730
"Well Geometry Configuration": {
709-
"description": "",
731+
"description": "1: utube; 2: coaxial; 3: vertical; 4: L",
710732
"type": "integer",
711733
"units": null,
712734
"category": "Well Bores",
713-
"default": "vertical",
735+
"default": 3,
714736
"minimum": 1,
715-
"maximum": 4
737+
"maximum": 4,
738+
"enum_values": [
739+
{
740+
"name": "ULOOP",
741+
"value": "utube",
742+
"int_value": 1
743+
},
744+
{
745+
"name": "COAXIAL",
746+
"value": "coaxial",
747+
"int_value": 2
748+
},
749+
{
750+
"name": "VERTICAL",
751+
"value": "vertical",
752+
"int_value": 3
753+
},
754+
{
755+
"name": "L",
756+
"value": "L",
757+
"int_value": 4
758+
}
759+
]
716760
},
717761
"Water Thermal Conductivity": {
718762
"description": "Water Thermal Conductivity",

0 commit comments

Comments
 (0)