Skip to content

Commit cef86c8

Browse files
WIP - wiring up S-DAC carbon extracted line item in ENERGY cash flow category
1 parent 5d352f4 commit cef86c8

5 files changed

Lines changed: 280 additions & 188 deletions

File tree

src/geophires_x/EconomicsS_DAC_GT.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import sys
22
import os
33
import numpy as np
4+
5+
from geophires_x.EconomicsUtils import carbon_extracted_annually_output_parameter
46
from geophires_x.Parameter import floatParameter, OutputParameter, ReadParameter, intParameter
57
from geophires_x.Units import *
68
from geophires_x.OptionList import EndUseOptions
@@ -360,12 +362,8 @@ def __init__(self, model: Model):
360362
PreferredUnits=CurrencyUnit.DOLLARS,
361363
CurrentUnits=CurrencyUnit.DOLLARS
362364
)
363-
self.CarbonExtractedAnnually = self.OutputParameterDict[self.CarbonExtractedAnnually.Name] = OutputParameter(
364-
Name="Tonnes per Year CO2 extracted",
365-
UnitType=Units.MASSPERTIME,
366-
PreferredUnits=MassPerTimeUnit.TONNEPERYEAR,
367-
CurrentUnits=MassPerTimeUnit.TONNEPERYEAR
368-
)
365+
self.CarbonExtractedAnnually = self.OutputParameterDict[self.CarbonExtractedAnnually.Name] = \
366+
carbon_extracted_annually_output_parameter()
369367
self.S_DAC_GTCummCarbonExtracted = self.OutputParameterDict[
370368
self.S_DAC_GTCummCarbonExtracted.Name] = OutputParameter(
371369
Name="Running Carbon Capture",

src/geophires_x/EconomicsSam.py

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

3+
import copy
34
import json
45
import logging
56
import os
@@ -277,6 +278,11 @@ def sf(_v: float, num_sig_figs: int = 5) -> float:
277278
sam_economics.nominal_discount_rate.value, sam_economics.wacc.value = _calculate_nominal_discount_rate_and_wacc_pct(
278279
model, single_owner
279280
)
281+
282+
# noinspection SpellCheckingInspection
283+
if hasattr(model.economics, 'DoSDACGTCalculations') and model.economics.DoSDACGTCalculations.value:
284+
sam_economics.s_dac_carbon_extracted_annually = copy.deepcopy(model.sdacgteconomics.CarbonExtractedAnnually)
285+
280286
sam_economics.moic.value = _calculate_moic(sam_economics.sam_cash_flow_profile, model)
281287
sam_economics.project_vir.value = _calculate_project_vir(sam_economics.sam_cash_flow_profile, model)
282288
sam_economics.project_payback_period.value = _calculate_project_payback_period(

src/geophires_x/EconomicsSamCalculations.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
investment_tax_credit_output_parameter,
2323
lcoh_output_parameter,
2424
lcoc_output_parameter,
25+
carbon_extracted_annually_output_parameter,
2526
)
2627
from geophires_x.GeoPHIRESUtils import is_float, quantity, is_int
2728
from geophires_x.Parameter import OutputParameter
@@ -83,6 +84,7 @@ class SamEconomicsCalculations:
8384
investment_tax_credit: OutputParameter = field(default_factory=investment_tax_credit_output_parameter)
8485

8586
capacity_payment_revenue_sources: list[CapacityPaymentRevenueSource] = field(default_factory=list)
87+
s_dac_carbon_extracted_annually: OutputParameter = field(default_factory=carbon_extracted_annually_output_parameter)
8688

8789
@property
8890
def _pre_revenue_years_count(self) -> int:
@@ -169,6 +171,8 @@ def _get_row(row_name__: str) -> list[Any]:
169171

170172
ret = self._insert_capacity_payment_line_items(ret)
171173

174+
ret = self._insert_s_dac_line_items(ret)
175+
172176
ret = self._insert_calculated_levelized_metrics_line_items(ret)
173177

174178
if self._may_consume_grid_electricity:
@@ -261,6 +265,70 @@ def _for_operational_years(_row: list[Any]) -> list[Any]:
261265

262266
return ret
263267

268+
def _insert_s_dac_line_items(self, cf_ret: list[list[Any]]) -> list[list[Any]]:
269+
ret: list[list[Any]] = cf_ret.copy()
270+
271+
def _get_row_index(row_name_: str) -> int:
272+
return [it[0] for it in ret].index(row_name_)
273+
274+
def _insert_row_before(before_row_name: str, row_name: str, row_content: list[Any]) -> None:
275+
ret.insert(
276+
_get_row_index(before_row_name),
277+
[row_name, *row_content],
278+
)
279+
280+
def _insert_blank_line_before(before_row_name: str) -> None:
281+
_insert_row_before(before_row_name, '', ['' for _it in ret[_get_row_index(before_row_name)]][1:])
282+
283+
REVENUE_CATEGORY_ROW_NAME = 'REVENUE'
284+
ENERGY_CATEGORY_ROW_NAME = 'ENERGY'
285+
CAPACITY_PAYMENT_REVENUE_ROW_NAME = 'Capacity payment revenue ($)'
286+
287+
_insert_blank_line_before(REVENUE_CATEGORY_ROW_NAME)
288+
# _insert_blank_line_before(CAPACITY_PAYMENT_REVENUE_ROW_NAME)
289+
290+
def _for_operational_years(_row: list[Any]) -> list[Any]:
291+
return [*([''] * (self._pre_revenue_years_count - 1)), 0, *_row]
292+
293+
_insert_row_before(
294+
REVENUE_CATEGORY_ROW_NAME,
295+
f'{self.s_dac_carbon_extracted_annually.Name} ({self.s_dac_carbon_extracted_annually.CurrentUnits})',
296+
_for_operational_years(self.s_dac_carbon_extracted_annually.value),
297+
)
298+
_insert_blank_line_before(REVENUE_CATEGORY_ROW_NAME)
299+
300+
# for i, capacity_payment_revenue_source in enumerate([None]):
301+
# if capacity_payment_revenue_source.amount_provided_label is not None:
302+
#
303+
#
304+
# revenue_row_name = f'{capacity_payment_revenue_source.name} revenue ($)'
305+
# _insert_row_before(
306+
# CAPACITY_PAYMENT_REVENUE_ROW_NAME,
307+
# revenue_row_name,
308+
# _for_operational_years(capacity_payment_revenue_source.revenue_usd),
309+
# )
310+
#
311+
# if capacity_payment_revenue_source.price_label is not None:
312+
# _insert_row_before(
313+
# revenue_row_name,
314+
# capacity_payment_revenue_source.price_label.replace('USD', '$'),
315+
# capacity_payment_revenue_source.price,
316+
# )
317+
#
318+
# if len(self.capacity_payment_revenue_sources) > 1 and i < len(self.capacity_payment_revenue_sources) - 1:
319+
# _insert_row_before(
320+
# CAPACITY_PAYMENT_REVENUE_ROW_NAME,
321+
# 'plus:',
322+
# ['' for _it in ret[_get_row_index(revenue_row_name)]][1:],
323+
# )
324+
#
325+
# if len(self.capacity_payment_revenue_sources) > 0:
326+
# _insert_row_before(
327+
# CAPACITY_PAYMENT_REVENUE_ROW_NAME, 'equals:', ['' for _it in ret[_get_row_index(revenue_row_name)]][1:]
328+
# )
329+
330+
return ret
331+
264332
def _insert_calculated_levelized_metrics_line_items(self, cf_ret: list[list[Any]]) -> list[list[Any]]:
265333
ret = cf_ret.copy()
266334

src/geophires_x/EconomicsUtils.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
from geophires_x.GeoPHIRESUtils import is_float, is_int
44
from geophires_x.Parameter import OutputParameter, SCHEDULE_DSL_MULTIPLIER_SYMBOL
5-
from geophires_x.Units import Units, PercentUnit, TimeUnit, CurrencyUnit, CurrencyFrequencyUnit, EnergyCostUnit
5+
from geophires_x.Units import (
6+
Units,
7+
PercentUnit,
8+
TimeUnit,
9+
CurrencyUnit,
10+
CurrencyFrequencyUnit,
11+
EnergyCostUnit,
12+
MassPerTimeUnit,
13+
)
614

715
CONSTRUCTION_CAPEX_SCHEDULE_PARAMETER_NAME = 'Construction CAPEX Schedule'
816

@@ -246,6 +254,15 @@ def investment_tax_credit_output_parameter() -> OutputParameter:
246254
)
247255

248256

257+
def carbon_extracted_annually_output_parameter() -> OutputParameter:
258+
return OutputParameter(
259+
Name="Tonnes per Year CO2 extracted",
260+
UnitType=Units.MASSPERTIME,
261+
PreferredUnits=MassPerTimeUnit.TONNEPERYEAR,
262+
CurrentUnits=MassPerTimeUnit.TONNEPERYEAR,
263+
)
264+
265+
249266
def expand_schedule_dsl(schedule_strings: list[str | float], total_years: int) -> list[float]:
250267
"""
251268
Parse a duration-based scheduling DSL and expand it into a fixed-length time-series array.

0 commit comments

Comments
 (0)