From 5357b7b92fc6fac7e47f0d202acb292bacc09228 Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Fri, 3 May 2019 17:11:13 +0200 Subject: [PATCH] Record total capacities and total costs --- Snakefile | 1 + config.yaml | 4 ++-- scripts/make_summary.py | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Snakefile b/Snakefile index 59e59011..072307a7 100644 --- a/Snakefile +++ b/Snakefile @@ -219,6 +219,7 @@ rule make_summary: #heat_demand_name='data/heating/daily_heat_demand.h5' output: costs=config['summary_dir'] + '/' + config['run'] + '/csvs/costs.csv', + capacities=config['summary_dir'] + '/' + config['run'] + '/csvs/capacities.csv', curtailment=config['summary_dir'] + '/' + config['run'] + '/csvs/curtailment.csv', energy=config['summary_dir'] + '/' + config['run'] + '/csvs/energy.csv', supply=config['summary_dir'] + '/' + config['run'] + '/csvs/supply.csv', diff --git a/config.yaml b/config.yaml index 32351cf1..918ea668 100644 --- a/config.yaml +++ b/config.yaml @@ -2,13 +2,13 @@ logging_level: INFO results_dir: 'results/' summary_dir: results -run: '190501-256' +run: '190502-181' scenario: sectors: [E] # ,E+EV,E+BEV,E+BEV+V2G] # [ E+EV, E+BEV, E+BEV+V2G ] simpl: [''] lv: [1.0,1.25]#[1.0, 1.125, 1.25, 1.5, 2.0, opt]# or opt - clusters: [256] #[90, 128, 181] #[45, 64, 90, 128, 181, 256] #, 362] # (2**np.r_[5.5:9:.5]).astype(int) minimum is 37 + clusters: [181] #[90, 128, 181] #[45, 64, 90, 128, 181, 256] #, 362] # (2**np.r_[5.5:9:.5]).astype(int) minimum is 37 opts: [''] #for pypsa-eur sector_opts: [Co2L0-3H-T-H-B-I-solar3,Co2L0-3H-T-H-B-I-onwind0p25-solar3]#,Co2L0p05-3H-T-H-B-I,Co2L0p10-3H-T-H-B-I,Co2L0p20-3H-T-H-B-I,Co2L0p30-3H-T-H-B-I,Co2L0p50-3H-T-H-B-I]#[Co2L-3H-T-H,Co2L0p10-3H-T-H,Co2L0-3H-T-H,Co2L0p20-3H-T-H] #Co2L-3H-T-H,Co2L0p10-3H-T-H,Co2L0p20-3H-T-HCo2L-3H-T-H,Co2L0p10-3H-T-H,Co2L0p30-3H-T-H,Co2L0p50-3H-T-H] #Co2L-3H,Co2L-3H-T,, LC-FL, LC-T, Ep-T, Co2L-T] # Co2L will give default (5%); Co2L0p25 will give 25% CO2 emissions; Co2Lm0p05 will give 5% negative emissions diff --git a/scripts/make_summary.py b/scripts/make_summary.py index 150a751d..63be6952 100644 --- a/scripts/make_summary.py +++ b/scripts/make_summary.py @@ -75,6 +75,11 @@ def calculate_costs(n,label,costs): else: p = c.pnl.p.multiply(n.snapshot_weightings,axis=0).sum() + #correct sequestration cost + if c.name == "Store": + items = c.df.index[(c.df.carrier == "co2 stored") & (c.df.marginal_cost <= -100.)] + c.df.loc[items,"marginal_cost"] = -20. + marginal_costs = p*c.df.marginal_cost marginal_costs_grouped = marginal_costs.groupby(c.df.carrier).sum() @@ -100,6 +105,18 @@ def calculate_costs(n,label,costs): +def calculate_capacities(n,label,capacities): + + for c in n.iterate_components(n.branch_components|n.controllable_one_port_components^{"Load"}): + capacities_grouped = c.df[opt_name.get(c.name,"p") + "_nom_opt"].groupby(c.df.carrier).sum() + + capacities = capacities.reindex(capacities.index|pd.MultiIndex.from_product([[c.list_name],capacities_grouped.index])) + + capacities.loc[idx[c.list_name,list(capacities_grouped.index)],label] = capacities_grouped.values + + return capacities + + def calculate_curtailment(n,label,curtailment): avail = n.generators_t.p_max_pu.multiply(n.generators.p_nom_opt).sum().groupby(n.generators.carrier).sum() @@ -373,6 +390,7 @@ def calculate_price_statistics(n, label, price_statistics): outputs = ["costs", + "capacities", "curtailment", "energy", "supply", @@ -449,4 +467,6 @@ if __name__ == "__main__": df = make_summaries(networks_dict) + df["metrics"].loc["total costs"] = df["costs"].sum() + to_csv(df)