Skip to content

Commit 5af5bbd

Browse files
authored
Merge pull request NREL#367 from jeffbourdier/main
Resolve three AGS bugs (280, 281, 317)
2 parents 24e927a + bbc6fbd commit 5af5bbd

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

src/geophires_x/AGSWellBores.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -716,28 +716,24 @@ def verify(self, model: Model) -> int:
716716
errors = []
717717

718718
def on_invalid_parameter_value(err_msg):
719-
errors.append(err_msg)
720-
print(err_msg)
721-
model.logger.fatal(err_msg)
719+
s = f'Error: CLGS model database imposes additional range restrictions: {err_msg}. Simulation terminated.'
720+
errors.append(s)
721+
print(s)
722+
model.logger.fatal(s)
722723
self.error = 1
723724

724725
if self.Nonvertical_length.value < 1000 or self.Nonvertical_length.value > 20000:
725-
on_invalid_parameter_value(
726-
'Error: CLGS model database imposes additional range restrictions: Nonvertical length must be '
727-
'between 1,000 and 20,000 m. Simulation terminated.'
728-
)
726+
on_invalid_parameter_value('Nonvertical length must be between 1,000 and 20,000 m')
729727

730728
if self.Tinj.value < 30.0 or self.Tinj.value > 60.0:
731-
on_invalid_parameter_value(
732-
'Error: CLGS model database imposes additional range restrictions: Injection temperature '
733-
'must be between 30 and 60 C. Simulation terminated.'
734-
)
729+
on_invalid_parameter_value('Injection temperature must be between 30 and 60 C')
735730

736731
if self.krock < 1.5 or self.krock > 4.5:
737-
on_invalid_parameter_value(
738-
'Error: CLGS model database imposes additional range restrictions: '
739-
'Rock thermal conductivity must be between 1.5 and 4.5 W/m/K. Simulation terminated.'
740-
)
732+
on_invalid_parameter_value('Rock thermal conductivity must be between 1.5 and 4.5 W/m/K')
733+
734+
if model.reserv.gradient.value[0] < 0.03 or model.reserv.gradient.value[0] > 0.07:
735+
on_invalid_parameter_value(f'{model.reserv.gradient1.Name} must be between '
736+
f'30 and 70 {TemperatureGradientUnit.DEGREESCPERKM.value}')
741737

742738
model.logger.info(f'complete {str(__class__)}: {sys._getframe().f_code.co_name}')
743739

@@ -816,6 +812,12 @@ def Calculate(self, model: Model) -> None:
816812
"""
817813
model.logger.info(f'Init {__class__!s}: {sys._getframe().f_code.co_name}')
818814

815+
if model.reserv.Trock.value > model.reserv.Tmax.value:
816+
s = f'{model.reserv.Trock.Name} ({model.reserv.Trock.value}) exceeds ' \
817+
f'{model.reserv.Tmax.Name} ({model.reserv.Tmax.value})'
818+
model.logger.critical(s)
819+
raise ValueError(s)
820+
819821
self.Tini = model.reserv.Trock.value # initialize the temperature to be the initial temperature of the reservoir
820822
if self.Tini > 375.0 or self.numnonverticalsections.value > 1:
821823
# must be a multilateral setup or too hot for CLGS, so must try to use wanju code.

src/geophires_x/SurfacePlant.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ def electricity_heat_production(self, enduse_option: EndUseOptions, availability
152152

153153
# next do the electricity produced - the same for all, except enduse=5, where it is recalculated
154154
ElectricityProduced = availability * etau * nprod * prodwellflowrate
155+
if ElectricityProduced.max() < 0:
156+
# TODO: make message more informative (possibly by hinting that maximum temperature may be too high)
157+
raise RuntimeError('Electricity production calculated as negative.')
155158

156159
if enduse_option == EndUseOptions.ELECTRICITY:
157160
# pure electricity

tests/test_geophires_x.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,3 +854,49 @@ def test_field_gathering_cost(self):
854854
)
855855

856856
self.assertEqual(fg_cost, result.result['CAPITAL COSTS (M$)']['Field gathering system costs']['value'])
857+
858+
def test_ags_temperature_limitations(self):
859+
client = GeophiresXClient()
860+
861+
with self.assertRaises(RuntimeError) as e:
862+
params = GeophiresInputParameters(
863+
{
864+
'Is AGS': True,
865+
'Well Geometry Configuration': 1,
866+
'Injection Temperature': 60,
867+
'Gradient 1': 60,
868+
'Reservoir Depth': 8,
869+
'Cylindrical Reservoir Input Depth': 8,
870+
'Economic Model': 3,
871+
}
872+
)
873+
client.get_geophires_result(params)
874+
self.assertIn(' exceeds ', str(e.exception))
875+
876+
with self.assertRaises(RuntimeError) as e:
877+
params = GeophiresInputParameters(
878+
{
879+
'Is AGS': True,
880+
'Closed-loop Configuration': 2,
881+
'Gradient 1': 25,
882+
'Reservoir Depth': 3,
883+
'Injection Temperature': 60,
884+
'Economic Model': 4,
885+
}
886+
)
887+
client.get_geophires_result(params)
888+
self.assertIn('failed to validate CLGS input value', str(e.exception))
889+
890+
def test_negative_electricity_production_raises_error(self):
891+
client = GeophiresXClient()
892+
with self.assertRaises(RuntimeError) as e:
893+
params = GeophiresInputParameters(
894+
{
895+
'Reservoir Depth': 5,
896+
'Gradient 1': 112,
897+
'Power Plant Type': 2,
898+
'Maximum Temperature': 600,
899+
}
900+
)
901+
client.get_geophires_result(params)
902+
self.assertIn('Electricity production calculated as negative', str(e.exception))

0 commit comments

Comments
 (0)