diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index ad932cd8..ceef2390 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -94,7 +94,6 @@ import geopandas as gpd import powerplantmatching as pm from powerplantmatching.export import map_country_bus -from vresutils.costdata import annuity from vresutils import transfer as vtransfer idx = pd.IndexSlice @@ -105,6 +104,18 @@ logger = logging.getLogger(__name__) def normed(s): return s/s.sum() +def calculate_annuity(n, r): + """Calculate the annuity factor for an asset with lifetime n years and + discount rate of r, e.g. annuity(20, 0.05) * 20 = 1.6""" + + if isinstance(r, pd.Series): + return pd.Series(1/n, index=r.index).where(r == 0, r/(1. - 1./(1.+r)**n)) + elif r > 0: + return r / (1. - 1./(1.+r)**n) + else: + return 1 / n + + def _add_missing_carriers_from_costs(n, costs, carriers): missing_carriers = pd.Index(carriers).difference(n.carriers.index) if missing_carriers.empty: return @@ -138,7 +149,7 @@ def load_costs(tech_costs, config, elec_config, Nyears=1.): "investment" : 0, "lifetime" : 25}) - costs["capital_cost"] = ((annuity(costs["lifetime"], costs["discount rate"]) + + costs["capital_cost"] = ((calculate_annuity(costs["lifetime"], costs["discount rate"]) + costs["FOM"]/100.) * costs["investment"] * Nyears)