Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev to main for 2024 release #19

Merged
merged 16 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
28 changes: 23 additions & 5 deletions debt_fraction_calculator/debt_fraction_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import PySAM.Levpartflip as levpartflip

from lcoe_calculator.extractor import Extractor
from lcoe_calculator.config import YEARS, FINANCIAL_CASES, CrpChoiceType
from lcoe_calculator.config import YEARS, FINANCIAL_CASES, CrpChoiceType, PTC_PLUS_ITC_CASE_PVB
from lcoe_calculator.tech_processors import LCOE_TECHS
import lcoe_calculator.tech_processors
from lcoe_calculator.base_processor import TechProcessor
from lcoe_calculator.macrs import MACRS_6, MACRS_16, MACRS_21

Expand Down Expand Up @@ -246,7 +247,7 @@ def calculate_all_debt_fractions(data_workbook_filename: str, output_filename: s
click.echo(f"Processing tech {Tech.tech_name} and financial case {fin_case}")
debt_fracs = [Tech.tech_name, fin_case] # First two columns are metadata

proc = Tech(data_workbook_filename, crp=crp, case=fin_case)
proc = Tech(data_workbook_filename, crp=crp, case=fin_case, tcc=PTC_PLUS_ITC_CASE_PVB)
proc.run()

d = proc.flat
Expand Down Expand Up @@ -278,13 +279,30 @@ def calculate_all_debt_fractions(data_workbook_filename: str, output_filename: s
if debug:
click.echo(f"Processing tech {Tech.tech_name}, financial case {fin_case}, "
f"and year {year}")
if not year in detail_vals or not year in tech_vals:
debt_fracs.append(None)
continue

input_vals = detail_vals.set_index('Parameter')[year].to_dict()
gen_vals = tech_vals.set_index('Parameter')[year].to_dict()

# Tax credits
# Tax credits - assumes each tech has one PTC or one ITC
if Tech.has_tax_credit and fin_case == 'Market':
input_vals["PTC"] = df_ptc.loc[Tech.sheet_name][year]
input_vals["ITC"] = df_itc.loc[Tech.sheet_name][year]
if Tech.sheet_name == "Utility-Scale PV-Plus-Battery":
if proc.tax_credit_case is PTC_PLUS_ITC_CASE_PVB and year > 2022:
ncf = proc.df_ncf.loc[Tech.default_tech_detail + '/Moderate'][year]
pvcf = proc.df_pvcf.loc[Tech.default_tech_detail + '/Moderate'][year]

batt_occ_percent = proc.df_batt_cost * proc.CO_LOCATION_SAVINGS / proc.df_occ

input_vals["PTC"] = df_ptc.loc[Tech.sheet_name][year] * min(ncf / pvcf, 1.0)
input_vals["ITC"] = df_itc.loc[Tech.sheet_name][year] * batt_occ_percent.loc[Tech.default_tech_detail + '/Moderate'][year]
else:
input_vals["PTC"] = 0
input_vals["ITC"] = df_itc.loc[Tech.sheet_name][year]
else:
input_vals["PTC"] = df_ptc.loc[Tech.sheet_name][year]
input_vals["ITC"] = df_itc.loc[Tech.sheet_name][year]
else:
input_vals["PTC"] = 0
input_vals["ITC"] = 0
Expand Down
Loading
Loading