Skip to content

Commit f325f57

Browse files
Fix HIP-RA-X unitless result field parsing
1 parent 81661cf commit f325f57

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ requirements.txt
1414
*.lock
1515
*.json
1616
all_messages_conf.log
17+
HDR.out
1718

1819
# C extensions
1920
*.so

src/hip_ra/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ def __init__(self, output_file_path):
4444
def _parse_fields(self):
4545
with open(self.output_file_path) as f:
4646
text = f.read()
47-
pattern = re.compile(r'(.+?):\s+([0-9eE.+-]+)\s*(.+)+?')
47+
pattern = re.compile(r'(.+?):\s+([0-9eE.+-]+)\s*(\S+)*?\n')
4848

4949
matches = re.findall(pattern, text)
5050

5151
result = {
52-
key.strip(): (
53-
{'value': float(value), 'unit': unit.strip()} if unit else {'value': float(value), 'unit': None}
54-
)
52+
key.strip(): {'value': float(value), 'unit': unit.strip() if unit else None}
5553
for key, value, unit in matches
5654
}
5755

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
*********************
2+
***HIP CASE REPORT***
3+
*********************
4+
5+
***SUMMARY OF INPUTS***
6+
Reservoir Temperature: 250.00 degC
7+
Rejection Temperature: 60.00 degC
8+
Reservoir Porosity: 18.00 %
9+
Reservoir Area: 55.00 km**2
10+
Reservoir Thickness: 0.25 kilometer
11+
Reservoir Life Cycle: 25.00 yr
12+
Rock Heat Capacity: 2.84e+12 kJ/km**3C
13+
Fluid Specific Heat Capacity: 4.34 kJ/kgC
14+
Density Of Reservoir Fluid: 8.62e+11 kg/km**3
15+
Density Of Reservoir Rock: 2.55e+12 kg/km**3
16+
Recoverable Fluid Factor: 0.50
17+
Recoverable Heat from Rock: 0.75
18+
19+
***SUMMARY OF RESULTS***
20+
Reservoir Pressure: 76.82 MPa
21+
Reservoir Depth: 7.83 kilometer
22+
Reservoir Volume (reservoir): 13.75 km**3
23+
Reservoir Volume (rock): 11.28 km**3
24+
Recoverable Volume (recoverable fluid): 1.24 km**3
25+
Stored Heat (reservoir): 5.40e+15 kJ
26+
Stored Heat (rock): 4.56e+15 kJ
27+
Stored Heat (fluid): 8.41e+14 kJ
28+
Mass of Reservoir (rock): 2.88e+13 kilogram
29+
Mass of Reservoir (fluid): 6.86e+12 kilogram
30+
Specific Enthalpy (reservoir): 377.60 kJ/kg
31+
Specific Enthalpy (rock): 211.61 kJ/kg
32+
Specific Enthalpy (fluid): 166.00 kJ/kg
33+
Recovery Factor (reservoir): 13.90 %
34+
Available Heat (reservoir): 1.14e+15 kJ
35+
Producible Heat (reservoir): 7.51e+14 kJ
36+
Producible Heat/Unit Area (reservoir): 1.37e+13 kJ/km**2
37+
Producible Heat/Unit Volume (reservoir): 5.46e+13 kJ/km**3
38+
Producible Electricity (reservoir): 577.44 MW
39+
Producible Electricity/Unit Area (reservoir): 10.50 MW/km**2
40+
Producible Electricity/Unit Volume (reservoir): 42.00 MW/km**3

tests/hip_ra_x_tests/test_hip_ra_x.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ def test_result_parsing_2(self):
115115
},
116116
)
117117

118+
def test_result_parsing_3(self):
119+
result = HipRaResult(self._get_test_file_path('hip-result_test-result-parsing-3.out'))
120+
self.assertIsNone(result.result['Recoverable Fluid Factor']['unit'])
121+
self.assertEqual(result.result['Recoverable Fluid Factor']['value'], 0.50)
122+
self.assertEqual(result.result['Producible Heat/Unit Area (reservoir)']['value'], 1.37e13)
123+
self.assertEqual(result.result['Producible Heat/Unit Area (reservoir)']['unit'], 'kJ/km**2')
124+
118125
def test_calculate_reservoir_volume(self):
119126
"""Calculates the volume of the reservoir"""
120127

0 commit comments

Comments
 (0)