diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index acbde263..b767787d 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -257,7 +257,7 @@ def update_transmission_costs(n, costs, length_factor=1.0, simple_hvdc_costs=Fal def attach_wind_and_solar(n, costs, input_profiles, technologies, line_length_factor=1): # TODO: rename tech -> carrier, technologies -> carriers - + for tech in technologies: if tech == 'hydro': continue @@ -526,9 +526,13 @@ def estimate_renewable_capacities(n, tech_map): .where(lambda s: s>0.1, 0.)) # only capacities above 100kW n.generators.loc[tech_i, 'p_nom_min'] = n.generators.loc[tech_i, 'p_nom'] -def attach_line_rating(n, fn): +def attach_line_rating(n, fn, s_max_py_factor): s_max = xr.open_dataarray(fn).to_pandas().transpose() n.lines_t.s_max_pu = s_max / n.lines.s_nom[s_max.columns] #only considers overhead lines + # account for maximal voltage angles of maximally 30 degree. + x = n.lines.x_pu + s_max_pu_cap = np.pi / (6 * x * n.lines.s_nom) + n.lines_t.s_max_pu = n.lines_t.s_max_pu.clip(upper=s_max_pu_cap, lower=1) def add_nice_carrier_names(n, config): carrier_i = n.carriers.index @@ -578,9 +582,10 @@ if __name__ == "__main__": attach_OPSD_renewables(n, techs) update_p_nom_max(n) - + if snakemake.config["lines"]["line_rating"]: - attach_line_rating(n, snakemake.input.line_rating) + s_max_pu_factor = snakemake.config["lines"]["s_max_pu"] + attach_line_rating(n, snakemake.input.line_rating, s_max_pu_factor) add_nice_carrier_names(n, snakemake.config) diff --git a/scripts/build_line_rating.py b/scripts/build_line_rating.py index c492c22f..e73e6312 100755 --- a/scripts/build_line_rating.py +++ b/scripts/build_line_rating.py @@ -21,7 +21,7 @@ Relevant Settings Inputs ------ -- ``data/cutouts``: +- ``data/cutouts``: - ``networks/base.nc``: confer :ref:`base` Outputs @@ -33,8 +33,8 @@ Outputs Description ----------- -The rule :mod:`build_line_rating` calculates the line rating for transmission lines. -The line rating provides the maximal capacity of a transmission line considering the heat exchange with the environment. +The rule :mod:`build_line_rating` calculates the line rating for transmission lines. +The line rating provides the maximal capacity of a transmission line considering the heat exchange with the environment. The folloing heat gains and losses are considered: @@ -42,10 +42,10 @@ The folloing heat gains and losses are considered: - heat gain trough solar radiation - heat loss through radiation of the trasnmission line - heat loss through forced convection with wind -- heat loss through natural convection +- heat loss through natural convection -With a heat balance considering the maximum temperature threshold of the tranmission line, +With a heat balance considering the maximum temperature threshold of the tranmission line, the maximal possible capacity factor "s_max_pu" for each transmission line at each time step is calculated. """ @@ -89,12 +89,12 @@ def calculate_line_rating(n): Parameters ---------- n : pypsa.Network object containing information on grid - + Returns ------- xarray DataArray object with maximal power. """ - relevant_lines=n.lines[(n.lines['underground']==False)] + relevant_lines=n.lines[(n.lines['underground']==False)] buses = relevant_lines[["bus0", "bus1"]].values x = n.buses.x y = n.buses.y @@ -112,7 +112,7 @@ def calculate_line_rating(n): 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 #in mW - da = xr.DataArray(data=np.sqrt(3) * Imax * line_factor.values.reshape(-1,1), + 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 @@ -124,7 +124,6 @@ if __name__ == "__main__": configure_logging(snakemake) n = pypsa.Network(snakemake.input.base_network) - s_max_pu_factor=snakemake.config["lines"]["s_max_pu"] - da=calculate_line_rating(n)*s_max_pu_factor + da=calculate_line_rating(n) da.to_netcdf(snakemake.output[0]) \ No newline at end of file