Skip to content

Commit

Permalink
Merge pull request #19 from NREL/dev
Browse files Browse the repository at this point in the history
dev to main for 2024 release
  • Loading branch information
brtietz authored Jun 25, 2024
2 parents 75fb504 + 6ea0a7d commit aaa6193
Show file tree
Hide file tree
Showing 1,196 changed files with 28,442 additions and 22,778 deletions.
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

0 comments on commit aaa6193

Please sign in to comment.