Skip to content

Commit d0122f6

Browse files
Itemize costs incurred by the objective function. Use real dollars instead of NPV when reporting future energy costs per MWh. Update the output files for the two examples that include all output files.
1 parent 79db76b commit d0122f6

File tree

7 files changed

+56
-9
lines changed

7 files changed

+56
-9
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PERIOD,Component,AnnualCost_NPV,AnnualCost_Real,Component_type
2+
2020,TotalGenFixedCosts,11213737.1287,1601083.86234,annual
3+
2020,GenVariableOMCostsInTP,1608195.12658,229616.160528,timepoint
4+
2020,FuelCostsPerTP,5682691.43038,811367.828532,timepoint
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
PERIOD,EnergyCost_per_MWh,SystemCostPerPeriod
2-
2020,49.6695083562,18504623.6857
1+
PERIOD,EnergyCostReal_per_MWh,SystemCostPerPeriod_NPV,SystemCostPerPeriod_Real,SystemDemand_MWh
2+
2020,7.09175249668,18504623.6857,2642067.8514,372555.0
0 Bytes
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PERIOD,Component,AnnualCost_NPV,AnnualCost_Real,Component_type
2+
2020,TotalGenFixedCosts,16582355.87,2367608.77112,annual
3+
2020,StorageEnergyInstallCosts,35397.2613454,5053.97828224,annual
4+
2020,GenVariableOMCostsInTP,7867155.78173,1123263.01393,timepoint
5+
2020,FuelCostsPerTP,0.0,0.0,timepoint
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PERIOD,EnergyCostReal_per_MWh,SystemCostPerPeriod_NPV,SystemCostPerPeriod_Real,SystemDemand_MWh
2+
2020,9.3836501009,24484908.913,3495925.76334,372555.0
0 Bytes
Binary file not shown.

switch_model/financials.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,53 @@ def load_inputs(mod, switch_data, inputs_dir):
308308
switch_data.load(filename=os.path.join(inputs_dir, 'financials.dat'))
309309

310310
def post_solve(instance, outdir):
311-
mod = instance
311+
m = instance
312+
# Overall electricity costs
312313
normalized_dat = [
313314
{
314315
"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
316+
"SystemCostPerPeriod_NPV": value(m.SystemCostPerPeriod[p]),
317+
"SystemCostPerPeriod_Real": value(
318+
m.SystemCostPerPeriod[p] / m.bring_annual_costs_to_base_year[p]
319+
),
320+
"EnergyCostReal_per_MWh": value(
321+
m.SystemCostPerPeriod[p] / m.bring_annual_costs_to_base_year[p] /
322+
sum(m.zone_total_demand_in_period_mwh[z,p] for z in m.LOAD_ZONES)
323+
),
324+
"SystemDemand_MWh": value(sum(
325+
m.zone_total_demand_in_period_mwh[z,p] for z in m.LOAD_ZONES
326+
))
327+
} for p in m.PERIODS
321328
]
322329
df = pd.DataFrame(normalized_dat)
323330
df.set_index(["PERIOD"], inplace=True)
324331
df.to_csv(os.path.join(outdir, "electricity_cost.csv"))
332+
# Itemized annual costs
333+
annualized_costs = [
334+
{
335+
"PERIOD": p,
336+
"Component": annual_cost,
337+
"Component_type": "annual",
338+
"AnnualCost_NPV": value(
339+
getattr(m, annual_cost)[p] * m.bring_annual_costs_to_base_year[p]
340+
),
341+
"AnnualCost_Real": value(getattr(m, annual_cost)[p])
342+
} for p in m.PERIODS for annual_cost in m.Cost_Components_Per_Period
343+
] + [
344+
{
345+
"PERIOD": p,
346+
"Component": tp_cost,
347+
"Component_type": "timepoint",
348+
"AnnualCost_NPV": value(sum(
349+
getattr(m, tp_cost)[t] * m.tp_weight_in_year[t]
350+
for t in m.TPS_IN_PERIOD[p]
351+
) * m.bring_annual_costs_to_base_year[p]),
352+
"AnnualCost_Real": value(sum(
353+
getattr(m, tp_cost)[t] * m.tp_weight_in_year[t]
354+
for t in m.TPS_IN_PERIOD[p]
355+
))
356+
} for p in m.PERIODS for tp_cost in m.Cost_Components_Per_TP
357+
]
358+
df = pd.DataFrame(annualized_costs)
359+
df.set_index(["PERIOD", "Component"], inplace=True)
360+
df.to_csv(os.path.join(outdir, "costs_itemized.csv"))

0 commit comments

Comments
 (0)