Skip to content

Commit cd8fc67

Browse files
fix unit test failure introduced in d6966a6 by keeping electricity rate percent constant
1 parent 46522ac commit cd8fc67

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/geophires_x/EconomicsSam.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from geophires_x.Units import convertible_unit
2828

2929
_SAM_CASH_FLOW_PROFILE_KEY = 'Cash Flow'
30+
_GEOPHIRES_TO_SAM_PRICING_MODEL_RATE_CONVERSION_CONSTANT = 0.745
3031

3132

3233
@lru_cache(maxsize=12)
@@ -132,7 +133,12 @@ def _get_single_owner_parameters(model: Model) -> dict[str, Any]:
132133

133134
ret['ppa_price_input'] = [econ.ElecStartPrice.value]
134135
# Approximation of GEOPHIRES rate model into SAM's percent inflation model (TODO - could probably be improved)
135-
ppa_escalation_rate_percent = round(econ.ElecEscalationRate.value / econ.ElecStartPrice.value * 0.745 * 100.0)
136+
ppa_escalation_rate_percent = round(
137+
econ.ElecEscalationRate.value
138+
/ econ.ElecStartPrice.value
139+
* _GEOPHIRES_TO_SAM_PRICING_MODEL_RATE_CONVERSION_CONSTANT
140+
* 100.0
141+
)
136142
ret['ppa_escalation'] = ppa_escalation_rate_percent
137143

138144
# Debt/equity ratio ('Fraction of Investment in Bonds' parameter)

tests/geophires_x_tests/test_economics_sam.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
from geophires_x.Model import Model
1414

1515
# noinspection PyProtectedMember
16-
from geophires_x.EconomicsSam import calculate_sam_economics, _sig_figs, _SAM_CASH_FLOW_PROFILE_KEY
16+
from geophires_x.EconomicsSam import (
17+
calculate_sam_economics,
18+
_sig_figs,
19+
_SAM_CASH_FLOW_PROFILE_KEY,
20+
_GEOPHIRES_TO_SAM_PRICING_MODEL_RATE_CONVERSION_CONSTANT,
21+
)
1722

1823
# noinspection PyProtectedMember
1924
from geophires_x.EconomicsSamCashFlow import _clean_profile
@@ -50,7 +55,19 @@ def _npv(r: GeophiresXResult) -> float:
5055
self.assertEqual(ir['value'], 7.0)
5156
self.assertEqual(ir['unit'], '%')
5257

53-
npvs = [_npv(self._get_result({'Starting Electricity Sale Price': x / 100.0})) for x in range(1, 20, 4)]
58+
inflation = 0.02
59+
rate_params = [
60+
{
61+
'Starting Electricity Sale Price': x / 100.0,
62+
# Escalation rate must remain constant percent
63+
'Electricity Escalation Rate Per Year': x
64+
* inflation
65+
/ 100.0
66+
/ _GEOPHIRES_TO_SAM_PRICING_MODEL_RATE_CONVERSION_CONSTANT,
67+
}
68+
for x in range(1, 20, 4)
69+
]
70+
npvs = [_npv(self._get_result(rp)) for rp in rate_params]
5471
for i in range(len(npvs) - 1):
5572
self.assertLess(npvs[i], npvs[i + 1])
5673

0 commit comments

Comments
 (0)