|
10 | 10 | import numpy as np |
11 | 11 | import numpy_financial as npf |
12 | 12 | import pandas as pd |
| 13 | +from pint.facets.plain import PlainQuantity |
13 | 14 |
|
14 | 15 | from geophires_x.Parameter import listParameter |
15 | 16 |
|
@@ -1176,33 +1177,40 @@ def _royalty_rates_from_cash_flow(r: GeophiresXResult) -> list[float]: |
1176 | 1177 | expected_royalties_based_on_cash_flow_ppa_revenue, result_4_royalty_cash_flow_usd, percent=0.0001 |
1177 | 1178 | ) |
1178 | 1179 |
|
1179 | | - # def test_royalty_supplemental_payments(self): |
1180 | | - # plant_lifetime = 25 |
1181 | | - # construction_years = 5 |
1182 | | - # |
1183 | | - # m: Model = EconomicsSamTestCase._new_model( |
1184 | | - # self._egs_test_file_path(), |
1185 | | - # additional_params={ |
1186 | | - # 'Royalty Supplemental Payments': '1 * 3, 0.25 * 5, 0.1', |
1187 | | - # 'Plant Lifetime': plant_lifetime, |
1188 | | - # 'Construction Years': construction_years, |
1189 | | - # }, |
1190 | | - # ) |
1191 | | - # |
1192 | | - # schedule_usd: list[float] = m.economics.get_royalty_supplemental_payments_schedule_usd(m) |
1193 | | - # expected_schedule = [1e6, 1e6, 1e6, 0.25e6, 0.25e6, *[0.25e6] * 3, *[0.1e6] * (plant_lifetime - 3)] |
1194 | | - # |
1195 | | - # self.assertListAlmostEqual( |
1196 | | - # expected_schedule, |
1197 | | - # schedule_usd, |
1198 | | - # places=3, |
1199 | | - # ) |
1200 | | - # |
1201 | | - # result: GeophiresXResult = EconomicsSamTestCase._get_result_from_model(m) |
1202 | | - # |
1203 | | - # opex_cashflow = self._get_cash_flow_row(result.result['SAM CASH FLOW PROFILE'], 'O&M fixed expense ($)') |
1204 | | - # operational_years_opex_cashflow_usd = opex_cashflow[construction_years:] |
1205 | | - # self.assertEqual(150_000, operational_years_opex_cashflow_usd[2] - operational_years_opex_cashflow_usd[3]) |
| 1180 | + def test_royalty_supplemental_payments(self): |
| 1181 | + plant_lifetime = 25 |
| 1182 | + construction_years = 5 |
| 1183 | + |
| 1184 | + m: Model = EconomicsSamTestCase._new_model( |
| 1185 | + self._egs_test_file_path(), |
| 1186 | + additional_params={ |
| 1187 | + 'Royalty Supplemental Payments': '1 * 3, 0.25 * 5, 0.1', |
| 1188 | + 'Plant Lifetime': plant_lifetime, |
| 1189 | + 'Construction Years': construction_years, |
| 1190 | + }, |
| 1191 | + ) |
| 1192 | + |
| 1193 | + schedule_usd: list[float] = m.economics.get_royalty_supplemental_payments_schedule_usd(m) |
| 1194 | + expected_schedule = [1e6, 1e6, 1e6, 0.25e6, 0.25e6, *[0.25e6] * 3, *[0.1e6] * (plant_lifetime - 3)] |
| 1195 | + |
| 1196 | + self.assertListAlmostEqual( |
| 1197 | + expected_schedule, |
| 1198 | + schedule_usd, |
| 1199 | + places=3, |
| 1200 | + ) |
| 1201 | + |
| 1202 | + result: GeophiresXResult = EconomicsSamTestCase._get_result_from_model(m) |
| 1203 | + |
| 1204 | + opex_cashflow = self._get_cash_flow_row(result.result['SAM CASH FLOW PROFILE'], 'O&M fixed expense ($)') |
| 1205 | + operational_years_opex_cashflow_usd = opex_cashflow[construction_years:] |
| 1206 | + self.assertEqual(150_000, operational_years_opex_cashflow_usd[2] - operational_years_opex_cashflow_usd[3]) |
| 1207 | + |
| 1208 | + royalty_holder_total_revenue_vu = result.result['EXTENDED ECONOMICS']['Royalty Holder Total Revenue'] |
| 1209 | + self.assertAlmostEqual( |
| 1210 | + royalty_holder_total_revenue_vu['value'], |
| 1211 | + PlainQuantity(sum(expected_schedule), 'USD').to(royalty_holder_total_revenue_vu['unit']).magnitude, |
| 1212 | + places=2, |
| 1213 | + ) |
1206 | 1214 |
|
1207 | 1215 | def test_sam_cash_flow_total_after_tax_returns_all_years(self): |
1208 | 1216 | input_file = self._egs_test_file_path() |
|
0 commit comments