Skip to content

Commit 2616613

Browse files
designate royalties sub tests
1 parent dba6334 commit 2616613

File tree

1 file changed

+89
-86
lines changed

1 file changed

+89
-86
lines changed

tests/test_geophires_x.py

Lines changed: 89 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,62 +1318,63 @@ def test_royalty_rate(self):
13181318

13191319
zero_royalty_npv = None
13201320
for royalty_rate in [0, 0.1]:
1321-
result = GeophiresXClient().get_geophires_result(
1322-
ImmutableGeophiresInputParameters(
1323-
from_file_path=self._get_test_file_path(
1324-
'geophires_x_tests/generic-egs-case-2_sam-single-owner-ppa.txt'
1325-
),
1326-
params={
1327-
'Royalty Rate': royalty_rate,
1328-
},
1321+
with self.subTest(msg=f'royalty_rate={royalty_rate}'):
1322+
result = GeophiresXClient().get_geophires_result(
1323+
ImmutableGeophiresInputParameters(
1324+
from_file_path=self._get_test_file_path(
1325+
'geophires_x_tests/generic-egs-case-2_sam-single-owner-ppa.txt'
1326+
),
1327+
params={
1328+
'Royalty Rate': royalty_rate,
1329+
},
1330+
)
13291331
)
1330-
)
1331-
opex_result = result.result['OPERATING AND MAINTENANCE COSTS (M$/yr)']
1332+
opex_result = result.result['OPERATING AND MAINTENANCE COSTS (M$/yr)']
13321333

1333-
self.assertIsNotNone(opex_result[royalties_output_name])
1334-
self.assertEqual('MUSD/yr', opex_result[royalties_output_name]['unit'])
1334+
self.assertIsNotNone(opex_result[royalties_output_name])
1335+
self.assertEqual('MUSD/yr', opex_result[royalties_output_name]['unit'])
13351336

1336-
total_opex_MUSD = opex_result['Total operating and maintenance costs']['value']
1337+
total_opex_MUSD = opex_result['Total operating and maintenance costs']['value']
13371338

1338-
opex_line_item_sum = 0
1339-
for line_item_names in [
1340-
'Wellfield maintenance costs',
1341-
'Power plant maintenance costs',
1342-
'Water costs',
1343-
royalties_output_name,
1344-
]:
1345-
opex_line_item_sum += opex_result[line_item_names]['value']
1339+
opex_line_item_sum = 0
1340+
for line_item_names in [
1341+
'Wellfield maintenance costs',
1342+
'Power plant maintenance costs',
1343+
'Water costs',
1344+
royalties_output_name,
1345+
]:
1346+
opex_line_item_sum += opex_result[line_item_names]['value']
13461347

1347-
self.assertEqual(opex_line_item_sum, total_opex_MUSD)
1348+
self.assertEqual(opex_line_item_sum, total_opex_MUSD)
13481349

1349-
econ_result = result.result['EXTENDED ECONOMICS']
1350-
royalty_holder_npv_MUSD = econ_result['Royalty Holder NPV']['value']
1350+
econ_result = result.result['EXTENDED ECONOMICS']
1351+
royalty_holder_npv_MUSD = econ_result['Royalty Holder NPV']['value']
13511352

1352-
if royalty_rate > 0.0:
1353-
self.assertEqual(58.88, opex_result[royalties_output_name]['value'])
1354-
self.assertGreater(royalty_holder_npv_MUSD, 0)
1353+
if royalty_rate > 0.0:
1354+
self.assertEqual(58.88, opex_result[royalties_output_name]['value'])
1355+
self.assertGreater(royalty_holder_npv_MUSD, 0)
13551356

1356-
# Owner NPV is lower when royalty rate is non-zero
1357-
self.assertGreater(zero_royalty_npv, result.result['ECONOMIC PARAMETERS']['Project NPV']['value'])
1357+
# Owner NPV is lower when royalty rate is non-zero
1358+
self.assertGreater(zero_royalty_npv, result.result['ECONOMIC PARAMETERS']['Project NPV']['value'])
13581359

1359-
royalties_cash_flow_MUSD = [
1360-
it * 1e-6
1361-
for it in _cash_flow_profile_row(
1362-
result.result['SAM CASH FLOW PROFILE'], 'O&M production-based expense ($)'
1363-
)
1364-
]
1360+
royalties_cash_flow_MUSD = [
1361+
it * 1e-6
1362+
for it in _cash_flow_profile_row(
1363+
result.result['SAM CASH FLOW PROFILE'], 'O&M production-based expense ($)'
1364+
)
1365+
]
13651366

1366-
self.assertAlmostEqual(
1367-
np.average(royalties_cash_flow_MUSD[1:]), opex_result[royalties_output_name]['value'], places=1
1368-
)
1367+
self.assertAlmostEqual(
1368+
np.average(royalties_cash_flow_MUSD[1:]), opex_result[royalties_output_name]['value'], places=1
1369+
)
13691370

1370-
if royalty_rate == 0.1:
1371-
self.assertAlmostEqual(708.07, royalty_holder_npv_MUSD, places=2)
1371+
if royalty_rate == 0.1:
1372+
self.assertAlmostEqual(708.07, royalty_holder_npv_MUSD, places=2)
13721373

1373-
if royalty_rate == 0.0:
1374-
self.assertEqual(0, opex_result[royalties_output_name]['value'])
1375-
self.assertEqual(0, royalty_holder_npv_MUSD)
1376-
zero_royalty_npv = result.result['ECONOMIC PARAMETERS']['Project NPV']['value']
1374+
if royalty_rate == 0.0:
1375+
self.assertEqual(0, opex_result[royalties_output_name]['value'])
1376+
self.assertEqual(0, royalty_holder_npv_MUSD)
1377+
zero_royalty_npv = result.result['ECONOMIC PARAMETERS']['Project NPV']['value']
13771378

13781379
def test_royalty_rate_escalation(self):
13791380
royalties_output_name = 'Average Annual Royalty Cost'
@@ -1382,59 +1383,61 @@ def test_royalty_rate_escalation(self):
13821383
escalation_rate = 0.01
13831384

13841385
for max_rate in [0.08, 1.0]:
1385-
result = GeophiresXClient().get_geophires_result(
1386-
ImmutableGeophiresInputParameters(
1387-
from_file_path=self._get_test_file_path(
1388-
'geophires_x_tests/generic-egs-case-2_sam-single-owner-ppa.txt'
1389-
),
1390-
params={
1391-
'Royalty Rate': base_royalty_rate,
1392-
'Royalty Rate Escalation': escalation_rate,
1393-
'Royalty Rate Maximum': max_rate,
1394-
},
1386+
with self.subTest(msg=f'max_rate={max_rate}'):
1387+
result = GeophiresXClient().get_geophires_result(
1388+
ImmutableGeophiresInputParameters(
1389+
from_file_path=self._get_test_file_path(
1390+
'geophires_x_tests/generic-egs-case-2_sam-single-owner-ppa.txt'
1391+
),
1392+
params={
1393+
'Royalty Rate': base_royalty_rate,
1394+
'Royalty Rate Escalation': escalation_rate,
1395+
'Royalty Rate Maximum': max_rate,
1396+
},
1397+
)
13951398
)
1396-
)
1397-
opex_result = result.result['OPERATING AND MAINTENANCE COSTS (M$/yr)']
1399+
opex_result = result.result['OPERATING AND MAINTENANCE COSTS (M$/yr)']
13981400

1399-
self.assertIsNotNone(opex_result[royalties_output_name])
1400-
self.assertEqual('MUSD/yr', opex_result[royalties_output_name]['unit'])
1401+
self.assertIsNotNone(opex_result[royalties_output_name])
1402+
self.assertEqual('MUSD/yr', opex_result[royalties_output_name]['unit'])
14011403

1402-
total_opex_MUSD = opex_result['Total operating and maintenance costs']['value']
1404+
total_opex_MUSD = opex_result['Total operating and maintenance costs']['value']
14031405

1404-
opex_line_item_sum = 0
1405-
for line_item_names in [
1406-
'Wellfield maintenance costs',
1407-
'Power plant maintenance costs',
1408-
'Water costs',
1409-
royalties_output_name,
1410-
]:
1411-
opex_line_item_sum += opex_result[line_item_names]['value']
1406+
opex_line_item_sum = 0
1407+
for line_item_names in [
1408+
'Wellfield maintenance costs',
1409+
'Power plant maintenance costs',
1410+
'Water costs',
1411+
royalties_output_name,
1412+
]:
1413+
opex_line_item_sum += opex_result[line_item_names]['value']
14121414

1413-
self.assertAlmostEqual(opex_line_item_sum, total_opex_MUSD, places=4)
1415+
self.assertAlmostEqual(opex_line_item_sum, total_opex_MUSD, places=4)
14141416

1415-
project_lifetime_yrs = result.result['ECONOMIC PARAMETERS']['Project lifetime']['value']
1417+
project_lifetime_yrs = result.result['ECONOMIC PARAMETERS']['Project lifetime']['value']
14161418

1417-
royalties_cash_flow_MUSD = [
1418-
it * 1e-6
1419-
for it in _cash_flow_profile_row(
1420-
result.result['SAM CASH FLOW PROFILE'], 'O&M production-based expense ($)'
1421-
)
1422-
][1:]
1419+
royalties_cash_flow_MUSD = [
1420+
it * 1e-6
1421+
for it in _cash_flow_profile_row(
1422+
result.result['SAM CASH FLOW PROFILE'], 'O&M production-based expense ($)'
1423+
)
1424+
][1:]
14231425

1424-
ppa_revenue_MUSD = [
1425-
it * 1e-6 for it in _cash_flow_profile_row(result.result['SAM CASH FLOW PROFILE'], 'PPA revenue ($)')
1426-
][1:]
1426+
ppa_revenue_MUSD = [
1427+
it * 1e-6
1428+
for it in _cash_flow_profile_row(result.result['SAM CASH FLOW PROFILE'], 'PPA revenue ($)')
1429+
][1:]
14271430

1428-
actual_royalty_rate = [None] * len(ppa_revenue_MUSD)
1429-
for i in range(len(ppa_revenue_MUSD)):
1430-
actual_royalty_rate[i] = royalties_cash_flow_MUSD[i] / ppa_revenue_MUSD[i]
1431+
actual_royalty_rate = [None] * len(ppa_revenue_MUSD)
1432+
for i in range(len(ppa_revenue_MUSD)):
1433+
actual_royalty_rate[i] = royalties_cash_flow_MUSD[i] / ppa_revenue_MUSD[i]
14311434

1432-
max_expected_rate = (
1433-
max_rate if max_rate < 1.0 else base_royalty_rate + escalation_rate * (project_lifetime_yrs - 1)
1434-
)
1435+
max_expected_rate = (
1436+
max_rate if max_rate < 1.0 else base_royalty_rate + escalation_rate * (project_lifetime_yrs - 1)
1437+
)
14351438

1436-
expected_last_year_revenue = ppa_revenue_MUSD[-1] * max_expected_rate
1437-
self.assertAlmostEqual(expected_last_year_revenue, royalties_cash_flow_MUSD[-1], places=3)
1439+
expected_last_year_revenue = ppa_revenue_MUSD[-1] * max_expected_rate
1440+
self.assertAlmostEqual(expected_last_year_revenue, royalties_cash_flow_MUSD[-1], places=3)
14381441

14391442
def test_royalty_rate_with_addon(self):
14401443
"""

0 commit comments

Comments
 (0)