From bc70819aef83c23079b8336f8a0cd1dcdfeb3434 Mon Sep 17 00:00:00 2001 From: Philipp Glaum Date: Fri, 14 Jan 2022 17:59:01 +0100 Subject: [PATCH] update formate and resistance calculation --- Snakefile | 2 +- scripts/add_electricity.py | 8 ++++---- scripts/build_line_rating.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) mode change 100644 => 100755 scripts/build_line_rating.py diff --git a/Snakefile b/Snakefile index 04b43211..8954c89e 100644 --- a/Snakefile +++ b/Snakefile @@ -410,4 +410,4 @@ rule plot_p_nom_max: input: input_plot_p_nom_max output: "results/plots/elec_s{simpl}_cum_p_nom_max_{clusts}_{techs}_{country}.{ext}" log: "logs/plot_p_nom_max/elec_s{simpl}_{clusts}_{techs}_{country}_{ext}.log" - script: "scripts/plot_p_nom_max.py" + script: "scripts/plot_p_nom_max.py" \ No newline at end of file diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 8194b906..7f331ed2 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -540,9 +540,8 @@ def estimate_renewable_capacities(n, tech_map=None): n.generators.loc[tech_i, 'p_nom_min'] = n.generators.loc[tech_i, 'p_nom'] def attach_line_rating(n): - if snakemake.config["lines"]["line_rating"]: - s_max=xr.open_dataarray(snakemake.input.line_rating).to_pandas().transpose() - n.lines_t.s_max_pu=s_max/n.lines.loc[s_max.columns,:]['s_nom'] #only considers overhead lines + s_max=xr.open_dataarray(snakemake.input.line_rating).to_pandas().transpose() + n.lines_t.s_max_pu=s_max/n.lines.loc[s_max.columns,:]['s_nom'] #only considers overhead lines def add_nice_carrier_names(n, config=None): if config is None: config = snakemake.config @@ -583,7 +582,8 @@ if __name__ == "__main__": estimate_renewable_capacities(n) attach_OPSD_renewables(n) update_p_nom_max(n) - attach_line_rating(n) + if snakemake.config["lines"]["line_rating"]: + attach_line_rating(n) add_nice_carrier_names(n) diff --git a/scripts/build_line_rating.py b/scripts/build_line_rating.py old mode 100644 new mode 100755 index c9d4dbee..06d2fb20 --- a/scripts/build_line_rating.py +++ b/scripts/build_line_rating.py @@ -79,7 +79,7 @@ def calculate_resistance(T, R_ref, T_ref=20, alpha=0.00403): ------- Resistance of at given temperature. """ - R=R_ref+(1+alpha*(T-T_ref)) + R=R_ref*(1+alpha*(T-T_ref)) return R def calculate_line_rating(n): @@ -111,8 +111,8 @@ def calculate_line_rating(n): R*=relevant_lines["n_bundle"] R=calculate_resistance(T=353, R_ref=R) Imax=cutout.line_rating(shapes, R, D=0.0218 ,Ts=353 , epsilon=0.8, alpha=0.8) - line_factor= relevant_lines.eval("v_nom * n_bundle * num_parallel")/1e3 - da = xr.DataArray(data=np.sqrt(3) * Imax * line_factor.values.reshape(-1,1), #in mW + line_factor= relevant_lines.eval("v_nom * n_bundle * num_parallel")/1e3 #in mW + da = xr.DataArray(data=np.sqrt(3) * Imax * line_factor.values.reshape(-1,1), attrs=dict(description="Maximal possible power in MW for given line considering line rating")) return da @@ -120,7 +120,7 @@ if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake snakemake = mock_snakemake('build_line_rating', network='elec', simpl='', - clusters='6', ll='copt', opts='Co2L-24H') + clusters='40', ll='copt', opts='Co2L-4H') configure_logging(snakemake) n = pypsa.Network(snakemake.input.base_network)