Source code for energy_methods.wind_project_finance

"""Transparent, debt-only cash-cover screening for contracted wind projects.

The model is NOT a lender's DSCR calculation: OPEX, debt interest, repayment
period, flat tariff and output are explicit scenario inputs, not audited cash flow.
"""

from __future__ import annotations

import math
from dataclasses import dataclass

HOURS_PER_YEAR = 8760.0


[docs] @dataclass(frozen=True, slots=True) class WindFinanceScenario: """Annual-average screening inputs, in MW, MWh/year and nominal USD. ``annual_generation_mwh`` is the assumed net **delivered** annual energy. ``annual_opex_usd`` includes *only* an explicit annual operating cost proxy. Contract escalation, taxes, reserves and financial covenants are excluded. """ capacity_mw: float annual_generation_mwh: float ppa_usd_per_mwh: float capex_usd: float senior_debt_usd: float annual_opex_usd: float annual_interest_rate: float debt_tenor_years: int
[docs] @dataclass(frozen=True, slots=True) class WindFinanceScreen: """Simplified screening indicators; none are actual lender covenants.""" net_capacity_factor: float gross_revenue_usd_year: float debt_to_capex: float annual_debt_service_usd: float gross_operating_cash_usd_year: float cash_cover_ratio: float | None tariff_for_unit_cash_cover_usd_per_mwh: float
[docs] def constant_annual_debt_payment( principal_usd: float, annual_interest_rate: float, tenor_years: int ) -> float: """Level end-of-year payment for a fully amortizing fixed-rate loan. Zero interest is treated exactly as straight-line principal repayment. This is a hypothetical loan structure, not the financing agreement. """ if not math.isfinite(principal_usd) or principal_usd < 0: raise ValueError("principal_usd must be finite and nonnegative") if not math.isfinite(annual_interest_rate) or not 0 <= annual_interest_rate < 1: raise ValueError("annual_interest_rate must be finite and in [0, 1)") if type(tenor_years) is not int or tenor_years < 1: raise ValueError("tenor_years must be a positive integer") if principal_usd == 0: return 0.0 if annual_interest_rate == 0: return principal_usd / tenor_years # Inverse annuity formula; this form avoids underflow for long tenors. annuity_factor = -math.expm1(-tenor_years * math.log1p(annual_interest_rate)) return principal_usd * annual_interest_rate / annuity_factor
[docs] def screen_wind_project(scenario: WindFinanceScenario) -> WindFinanceScreen: """Evaluate capacity factor, tariff revenue and simplified annual debt cover. ``cash_cover_ratio`` = (annual delivered MWh * tariff - annual OPEX) / assumed level debt payment. It is undefined (None) for zero debt. No inference about creditworthiness is possible without real debt schedules, taxes, reserve accounts, curtailment and net output evidence. """ numeric = ( scenario.capacity_mw, scenario.annual_generation_mwh, scenario.ppa_usd_per_mwh, scenario.capex_usd, scenario.senior_debt_usd, scenario.annual_opex_usd, ) if not all(math.isfinite(number) for number in numeric): raise ValueError("All energy, price and cost inputs must be finite") if scenario.capacity_mw <= 0 or scenario.annual_generation_mwh <= 0: raise ValueError("Capacity and annual delivered energy must be positive") if scenario.annual_generation_mwh > scenario.capacity_mw * HOURS_PER_YEAR: raise ValueError("Annual energy cannot exceed the nameplate MW-year ceiling") if any(number < 0 for number in numeric[2:]): raise ValueError("Prices, costs and debt must be nonnegative") if scenario.capex_usd <= 0 or scenario.senior_debt_usd > scenario.capex_usd: raise ValueError("CAPEX must be positive and debt cannot exceed CAPEX") payment = constant_annual_debt_payment( scenario.senior_debt_usd, scenario.annual_interest_rate, scenario.debt_tenor_years ) gross_revenue = scenario.annual_generation_mwh * scenario.ppa_usd_per_mwh after_opex = gross_revenue - scenario.annual_opex_usd return WindFinanceScreen( net_capacity_factor=scenario.annual_generation_mwh / (scenario.capacity_mw * HOURS_PER_YEAR), gross_revenue_usd_year=gross_revenue, debt_to_capex=scenario.senior_debt_usd / scenario.capex_usd, annual_debt_service_usd=payment, gross_operating_cash_usd_year=after_opex, cash_cover_ratio=after_opex / payment if payment > 0 else None, tariff_for_unit_cash_cover_usd_per_mwh=(scenario.annual_opex_usd + payment) / scenario.annual_generation_mwh, )