Skip to content

Commit c53df07

Browse files
Export energy costs per period
1 parent 0664c12 commit c53df07

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PERIOD,EnergyCost_per_MWh,SystemCostPerPeriod
2+
2020,49.6695083562,18504623.6857

switch_model/financials.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88
from pyomo.environ import *
99
import os
10+
import pandas as pd
1011

1112
dependencies = 'switch_model.timescales'
1213

@@ -305,3 +306,19 @@ def load_inputs(mod, switch_data, inputs_dir):
305306
base_financial_year, interest_rate and optionally discount_rate.
306307
"""
307308
switch_data.load(filename=os.path.join(inputs_dir, 'financials.dat'))
309+
310+
def post_solve(instance, outdir):
311+
mod = instance
312+
normalized_dat = [
313+
{
314+
"PERIOD": p,
315+
"SystemCostPerPeriod": value(mod.SystemCostPerPeriod[p]),
316+
"EnergyCost_per_MWh": value(
317+
mod.SystemCostPerPeriod[p] /
318+
sum(mod.zone_total_demand_in_period_mwh[z,p] for z in mod.LOAD_ZONES)
319+
)
320+
} for p in mod.PERIODS
321+
]
322+
df = pd.DataFrame(normalized_dat)
323+
df.set_index(["PERIOD"], inplace=True)
324+
df.to_csv(os.path.join(outdir, "electricity_cost.csv"))

switch_model/transmission/transport/build.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,3 @@ def post_solve(instance, outdir):
366366
tx_build_df = pd.DataFrame(normalized_dat)
367367
tx_build_df.set_index(["TRANSMISSION_LINE", "PERIOD"], inplace=True)
368368
tx_build_df.to_csv(os.path.join(outdir, "transmission.csv"))
369-

0 commit comments

Comments
 (0)