Skip to content

Commit

Permalink
LCOE with Discounted Demand
Browse files Browse the repository at this point in the history
Added discounted factor
  • Loading branch information
SimoneOseiOwusu committed Feb 14, 2025
1 parent 9eff7a1 commit 6a6d646
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
7 changes: 5 additions & 2 deletions workflow/scripts/osemosys_global/summary/summarise_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from configuration import ConfigFile, ConfigPaths
from osemosys_global.visualisation.utils import transform_ts, powerplant_filter
from osemosys_global.visualisation.constants import DAYS_PER_MONTH, MONTH_NAMES
from osemosys_global.utils import apply_timeshift
from osemosys_global.utils import apply_timeshift, discount_factor
pd.set_option('mode.chained_assignment', None)


Expand Down Expand Up @@ -128,7 +128,10 @@ def headline_metrics(input_data: Dict[str,pd.DataFrame], result_data: Dict[str,p
'Value'] = (system_cost_total/1000).round(0)

# Cost of electricity generation
df_demand = result_data["Demand"]
discount_rate = input_data['DiscountRate']
years = input_data['YEAR'].VALUE.to_list()
discount_fac = discount_factor(['GLOBAL'],years, discount_rate)
df_demand = result_data["Demand"].mul(discount_fac)
demand_total = df_demand.VALUE.sum() # Total demand in TWh
df_metrics.loc[df_metrics['Metric'].str.startswith('Cost of electricity'),
'Value'] = (system_cost_total/(demand_total*0.2778)).round(0)
Expand Down
39 changes: 39 additions & 0 deletions workflow/scripts/osemosys_global/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,42 @@ def apply_dtypes(df:pd.DataFrame, name: Optional[str]) -> pd.DataFrame:
else:
logging.info(f"Can not set dtype on {col}")
return df

def discount_factor(
regions: list,
years: list,
discount_rate: pd.DataFrame,
) -> pd.DataFrame:
"""DiscountFactor
Arguments
---------
regions: list
years: list
discount_rate: pd.DataFrame
Notes
-----
From the formulation::
param DiscountFactor{r in REGION, y in YEAR} :=
(1 + DiscountRate[r]) ^ (y - min{yy in YEAR} min(yy));
"""

if discount_rate.empty:
raise ValueError(
"Cannot calculate discount factor due to missing discount rate"
)

discount_rate["YEAR"] = [years] * len(discount_rate)
discount_factor = discount_rate.explode("YEAR").reset_index(level="REGION")
discount_factor["YEAR"] = discount_factor["YEAR"].astype("int64")
discount_factor["NUM"] = discount_factor["YEAR"] - discount_factor["YEAR"].min()
discount_factor["RATE"] = discount_factor["VALUE"] + 1
discount_factor["VALUE"] = (
discount_factor["RATE"].pow(discount_factor["NUM"] + adj).astype(float)
)
return discount_factor.reset_index()[["REGION", "YEAR", "VALUE"]].set_index(
["REGION", "YEAR"]
)

0 comments on commit 6a6d646

Please sign in to comment.