Skip to content

Commit ef43265

Browse files
test_number_of_doublets_non_integer to ensure MC compatibility
1 parent 999866f commit ef43265

File tree

1 file changed

+56
-40
lines changed

1 file changed

+56
-40
lines changed
Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
43
from base_test_case import BaseTestCase
54

65
# ruff: noqa: I001 # Successful module initialization is dependent on this specific import order.
@@ -16,57 +15,24 @@
1615
class WellBoresTestCase(BaseTestCase):
1716

1817
def test_number_of_doublets(self):
19-
def _get_result(_params) -> GeophiresXResult:
20-
params = GeophiresInputParameters(
21-
{
22-
'Reservoir Depth': 5,
23-
'Gradient 1': 74,
24-
'Power Plant Type': 2,
25-
'Maximum Temperature': 600,
26-
}
27-
| _params
28-
)
29-
return GeophiresXClient().get_geophires_result(params)
30-
31-
def _prod_inj_lcoe(_r: GeophiresXResult) -> tuple[int, int]:
32-
return (
33-
_r.result['ENGINEERING PARAMETERS']['Number of Production Wells']['value'],
34-
_r.result['ENGINEERING PARAMETERS']['Number of Injection Wells']['value'],
35-
_r.result['SUMMARY OF RESULTS']['Electricity breakeven price']['value'],
36-
_r.result['SUMMARY OF RESULTS']['Electricity breakeven price']['value'],
37-
_r.result['SURFACE EQUIPMENT SIMULATION RESULTS']['Average Net Electricity Generation']['value'],
38-
)
39-
40-
r_prod_inj: GeophiresXResult = _get_result(
18+
r_prod_inj: GeophiresXResult = self._get_result(
4119
{
4220
'Number of Production Wells': 10,
4321
'Number of Injection Wells': 10,
4422
}
4523
)
4624

47-
r_doublets: GeophiresXResult = _get_result(
25+
r_doublets: GeophiresXResult = self._get_result(
4826
{
4927
'Number of Doublets': 10,
5028
}
5129
)
5230

53-
self.assertEqual(_prod_inj_lcoe(r_doublets), _prod_inj_lcoe(r_prod_inj))
31+
self.assertEqual(self._prod_inj_lcoe_production(r_doublets), self._prod_inj_lcoe_production(r_prod_inj))
5432

5533
def test_number_of_doublets_validation(self):
56-
def _get_result(_params) -> GeophiresXResult:
57-
params = GeophiresInputParameters(
58-
{
59-
'Reservoir Depth': 5,
60-
'Gradient 1': 74,
61-
'Power Plant Type': 2,
62-
'Maximum Temperature': 600,
63-
}
64-
| _params
65-
)
66-
return GeophiresXClient().get_geophires_result(params)
67-
6834
with self.assertRaises(RuntimeError):
69-
_get_result(
35+
self._get_result(
7036
{
7137
'Number of Production Wells': 10,
7238
'Number of Injection Wells': 10,
@@ -75,17 +41,67 @@ def _get_result(_params) -> GeophiresXResult:
7541
)
7642

7743
with self.assertRaises(RuntimeError):
78-
_get_result(
44+
self._get_result(
7945
{
8046
'Number of Production Wells': 10,
8147
'Number of Doublets': 10,
8248
}
8349
)
8450

8551
with self.assertRaises(RuntimeError):
86-
_get_result(
52+
self._get_result(
8753
{
8854
'Number of Injection Wells': 10,
8955
'Number of Doublets': 10,
9056
}
9157
)
58+
59+
def test_number_of_doublets_non_integer(self):
60+
"""
61+
Non-integer values are relevant for MC simulations, since distributions produce floats, and we want
62+
Number of Doublets to be compatible with MC.
63+
"""
64+
65+
prod_inj_lcoe = self._prod_inj_lcoe_production(
66+
self._get_result(
67+
{
68+
'Number of Doublets': 40.7381,
69+
}
70+
)
71+
)
72+
73+
self.assertEqual(prod_inj_lcoe[0], 40)
74+
self.assertEqual(prod_inj_lcoe[1], 40)
75+
76+
prod_inj_lcoe_2 = self._prod_inj_lcoe_production(
77+
self._get_result(
78+
{
79+
'Number of Doublets': 199.2,
80+
}
81+
)
82+
)
83+
84+
self.assertEqual(prod_inj_lcoe_2[0], 199)
85+
self.assertEqual(prod_inj_lcoe_2[1], 199)
86+
87+
# noinspection PyMethodMayBeStatic
88+
def _get_result(self, _params) -> GeophiresXResult:
89+
params = GeophiresInputParameters(
90+
{
91+
'Reservoir Depth': 5,
92+
'Gradient 1': 74,
93+
'Power Plant Type': 2,
94+
'Maximum Temperature': 600,
95+
}
96+
| _params
97+
)
98+
return GeophiresXClient().get_geophires_result(params)
99+
100+
# noinspection PyMethodMayBeStatic
101+
def _prod_inj_lcoe_production(self, _r: GeophiresXResult) -> tuple[int, int, float, float]:
102+
return (
103+
_r.result['ENGINEERING PARAMETERS']['Number of Production Wells']['value'],
104+
_r.result['ENGINEERING PARAMETERS']['Number of Injection Wells']['value'],
105+
_r.result['SUMMARY OF RESULTS']['Electricity breakeven price']['value'],
106+
_r.result['SURFACE EQUIPMENT SIMULATION RESULTS']['Average Net Electricity Generation']['value'],
107+
)

0 commit comments

Comments
 (0)