update formate and resistance calculation

This commit is contained in:
Philipp Glaum 2022-01-14 17:59:01 +01:00
parent b05cddae77
commit bc70819aef
3 changed files with 9 additions and 9 deletions

View File

@ -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"

View File

@ -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)

8
scripts/build_line_rating.py Normal file → Executable file
View File

@ -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)