|
27 | 27 | from geophires_x import Model as Model |
28 | 28 | from geophires_x.EconomicsSamCashFlow import _calculate_sam_economics_cash_flow |
29 | 29 | from geophires_x.GeoPHIRESUtils import is_float, is_int |
| 30 | +from geophires_x.OptionList import EconomicModel, EndUseOptions |
30 | 31 | from geophires_x.Parameter import Parameter |
31 | 32 | from geophires_x.Units import convertible_unit |
32 | 33 |
|
33 | 34 | _SAM_CASH_FLOW_PROFILE_KEY = 'Cash Flow' |
34 | 35 | _GEOPHIRES_TO_SAM_PRICING_MODEL_RATE_CONVERSION_CONSTANT = 0.745 |
35 | 36 |
|
36 | 37 |
|
| 38 | +def validate_read_parameters(model: Model): |
| 39 | + def _inv_msg(param_name: str, invalid_value: Any, supported_description: str) -> str: |
| 40 | + return ( |
| 41 | + f'Invalid {param_name} ({invalid_value}) for ' |
| 42 | + f'{EconomicModel.SAM_SINGLE_OWNER_PPA.name} economic model. ' |
| 43 | + f'{EconomicModel.SAM_SINGLE_OWNER_PPA.name} only supports ' |
| 44 | + f'{supported_description}.' |
| 45 | + ) |
| 46 | + |
| 47 | + if model.surfaceplant.enduse_option.value != EndUseOptions.ELECTRICITY: |
| 48 | + raise ValueError( |
| 49 | + _inv_msg( |
| 50 | + model.surfaceplant.enduse_option.Name, |
| 51 | + model.surfaceplant.enduse_option.value.value, |
| 52 | + f'{EndUseOptions.ELECTRICITY.name} End-Use Option', |
| 53 | + ) |
| 54 | + ) |
| 55 | + |
| 56 | + if model.surfaceplant.construction_years.value != 1: |
| 57 | + raise ValueError( |
| 58 | + _inv_msg( |
| 59 | + model.surfaceplant.construction_years.Name, |
| 60 | + model.surfaceplant.construction_years.value, |
| 61 | + f'{model.surfaceplant.construction_years.Name} = 1', |
| 62 | + ) |
| 63 | + ) |
| 64 | + |
| 65 | + |
37 | 66 | @lru_cache(maxsize=12) |
38 | 67 | def calculate_sam_economics(model: Model) -> dict[str, dict[str, Any]]: |
39 | 68 | custom_gen = CustomGeneration.new() |
@@ -126,7 +155,12 @@ def get_entry_display(entry: Any) -> str: |
126 | 155 |
|
127 | 156 |
|
128 | 157 | def _get_custom_gen_parameters(model: Model) -> dict[str, Any]: |
129 | | - ret: dict[str, Any] = {'analysis_period': model.surfaceplant.plant_lifetime.value} |
| 158 | + # fmt:off |
| 159 | + ret: dict[str, Any] = { |
| 160 | + # Project lifetime |
| 161 | + 'analysis_period': model.surfaceplant.plant_lifetime.value |
| 162 | + } |
| 163 | + # fmt:on |
130 | 164 |
|
131 | 165 | return ret |
132 | 166 |
|
@@ -164,10 +198,10 @@ def pct(econ_value: Parameter) -> float: |
164 | 198 | # GEOPHIRES assumes O&M fixed costs are not affected by inflation |
165 | 199 | ret['om_fixed_escal'] = -1.0 * pct(econ.RINFL) |
166 | 200 |
|
167 | | - # TODO project lifetime |
168 | | - |
169 | 201 | # TODO construction years |
170 | 202 |
|
| 203 | + # TODO 'Inflation Rate During Construction' |
| 204 | + |
171 | 205 | # Note generation profile is generated relative to the max in _get_utility_rate_parameters |
172 | 206 | ret['system_capacity'] = _get_max_net_generation_MW(model) * 1e3 |
173 | 207 |
|
@@ -205,6 +239,7 @@ def pct(econ_value: Parameter) -> float: |
205 | 239 | # Interest rate |
206 | 240 | ret['real_discount_rate'] = pct(econ.discountrate) |
207 | 241 |
|
| 242 | + # Project lifetime |
208 | 243 | ret['term_tenor'] = model.surfaceplant.plant_lifetime.value |
209 | 244 | ret['term_int_rate'] = pct(econ.BIR) |
210 | 245 |
|
|
0 commit comments