Skip to content

Commit bbc6fbd

Browse files
committed
tweak unit tests and error message as requested for PR 367
1 parent 1c0ae64 commit bbc6fbd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/geophires_x/SurfacePlant.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def electricity_heat_production(self, enduse_option: EndUseOptions, availability
153153
# next do the electricity produced - the same for all, except enduse=5, where it is recalculated
154154
ElectricityProduced = availability * etau * nprod * prodwellflowrate
155155
if ElectricityProduced.max() < 0:
156-
raise RuntimeError('Electricity production calculated as negative. '
157-
'Check maximum temperature for power plant type.')
156+
# TODO: make message more informative (possibly by hinting that maximum temperature may be too high)
157+
raise RuntimeError('Electricity production calculated as negative.')
158158

159159
if enduse_option == EndUseOptions.ELECTRICITY:
160160
# pure electricity

tests/test_geophires_x.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def test_field_gathering_cost(self):
855855

856856
self.assertEqual(fg_cost, result.result['CAPITAL COSTS (M$)']['Field gathering system costs']['value'])
857857

858-
def test_temperature_limitations(self):
858+
def test_ags_temperature_limitations(self):
859859
client = GeophiresXClient()
860860

861861
with self.assertRaises(RuntimeError) as e:
@@ -864,6 +864,8 @@ def test_temperature_limitations(self):
864864
'Is AGS': True,
865865
'Well Geometry Configuration': 1,
866866
'Injection Temperature': 60,
867+
'Gradient 1': 60,
868+
'Reservoir Depth': 8,
867869
'Cylindrical Reservoir Input Depth': 8,
868870
'Economic Model': 3,
869871
}
@@ -877,14 +879,24 @@ def test_temperature_limitations(self):
877879
'Is AGS': True,
878880
'Closed-loop Configuration': 2,
879881
'Gradient 1': 25,
882+
'Reservoir Depth': 3,
880883
'Injection Temperature': 60,
881884
'Economic Model': 4,
882885
}
883886
)
884887
client.get_geophires_result(params)
885888
self.assertIn('failed to validate CLGS input value', str(e.exception))
886889

890+
def test_negative_electricity_production_raises_error(self):
891+
client = GeophiresXClient()
887892
with self.assertRaises(RuntimeError) as e:
888-
params = GeophiresInputParameters({'Power Plant Type': 2, 'Maximum Temperature': 600})
893+
params = GeophiresInputParameters(
894+
{
895+
'Reservoir Depth': 5,
896+
'Gradient 1': 112,
897+
'Power Plant Type': 2,
898+
'Maximum Temperature': 600,
899+
}
900+
)
889901
client.get_geophires_result(params)
890-
self.assertIn('Check maximum temperature for power plant type', str(e.exception))
902+
self.assertIn('Electricity production calculated as negative', str(e.exception))

0 commit comments

Comments
 (0)