only consider relevant lines for line rating
This commit is contained in:
parent
af4bccfb39
commit
fba50492a5
10
Snakefile
10
Snakefile
@ -222,11 +222,11 @@ if config['lines'].get('line_rating', False):
|
|||||||
cutout="cutouts/" + config["lines"]['cutout'] + ".nc"
|
cutout="cutouts/" + config["lines"]['cutout'] + ".nc"
|
||||||
output:
|
output:
|
||||||
output="resources/line_rating.nc"
|
output="resources/line_rating.nc"
|
||||||
log: "logs/build_line_rating.log"
|
log: "logs/build_line_rating.log"
|
||||||
benchmark: "benchmarks/build_line_rating"
|
benchmark: "benchmarks/build_line_rating"
|
||||||
threads: 1
|
threads: ATLITE_NPROCESSES
|
||||||
#resources: mem=3000
|
resources: mem=ATLITE_NPROCESSES * 1000
|
||||||
script: "scripts/build_line_rating.py"
|
script: "scripts/build_line_rating.py"
|
||||||
|
|
||||||
rule add_electricity:
|
rule add_electricity:
|
||||||
input:
|
input:
|
||||||
|
@ -541,9 +541,8 @@ def estimate_renewable_capacities(n, tech_map=None):
|
|||||||
|
|
||||||
def attach_line_rating(n):
|
def attach_line_rating(n):
|
||||||
if snakemake.config["lines"]["line_rating"]:
|
if snakemake.config["lines"]["line_rating"]:
|
||||||
s=xr.open_dataarray(snakemake.input.line_rating)
|
s_max=xr.open_dataarray(snakemake.input.line_rating).to_pandas().transpose()
|
||||||
n.lines_t.s_max_pu=s.to_pandas().transpose()/n.lines.s_nom
|
n.lines_t.s_max_pu=s_max/n.lines.loc[s_max.columns,:]['s_nom'] #only considers overhead lines
|
||||||
n.lines_t.s_max_pu.replace(np.inf, 1.0, inplace=True)
|
|
||||||
|
|
||||||
def add_nice_carrier_names(n, config=None):
|
def add_nice_carrier_names(n, config=None):
|
||||||
if config is None: config = snakemake.config
|
if config is None: config = snakemake.config
|
||||||
|
@ -60,29 +60,30 @@ import atlite
|
|||||||
import xarray as xr
|
import xarray as xr
|
||||||
|
|
||||||
|
|
||||||
def add_line_rating(n):
|
def calculate_line_rating(n):
|
||||||
buses = n.lines[["bus0", "bus1"]].values
|
relevant_lines=n.lines[(n.lines['underground']==False) & (n.lines['under_construction']==False)]
|
||||||
|
buses = relevant_lines[["bus0", "bus1"]].values
|
||||||
x = n.buses.x
|
x = n.buses.x
|
||||||
y = n.buses.y
|
y = n.buses.y
|
||||||
shapes = [Line([Point(x[b0], y[b0]), Point(x[b1], y[b1])]) for (b0, b1) in buses]
|
shapes = [Line([Point(x[b0], y[b0]), Point(x[b1], y[b1])]) for (b0, b1) in buses]
|
||||||
shapes = gpd.GeoSeries(shapes, index=n.lines.index)
|
shapes = gpd.GeoSeries(shapes, index=relevant_lines.index)
|
||||||
cutout = atlite.Cutout(snakemake.input.cutout)
|
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||||
da = xr.DataArray(data=np.sqrt(3) * cutout.line_rating(shapes, n.lines.r/n.lines.length) * 1e3,
|
if relevant_lines.r_pu.eq(0).all():
|
||||||
attrs=dict(description="Maximal possible power for given line considering line rating")) # in MW
|
#Overwrite standard line resistance with line resistance obtained from line type
|
||||||
|
relevant_lines["r_pu"]=relevant_lines.join(n.line_types["r_per_length"], on=["type"])['r_per_length']/1000 #in meters
|
||||||
|
Imax=cutout.line_rating(shapes, relevant_lines.r_pu)
|
||||||
|
da = xr.DataArray(data=np.sqrt(3) * Imax * relevant_lines["v_nom"].values.reshape(-1,1) * relevant_lines["num_parallel"].values.reshape(-1,1)/1e3, #in mW
|
||||||
|
attrs=dict(description="Maximal possible power in MW for given line considering line rating"))
|
||||||
return da
|
return da
|
||||||
#import netcdf file in add electricity.py
|
|
||||||
#n.lines_t.s_max_pu=s.to_pandas().transpose()/n.lines.s_nom
|
|
||||||
#n.lines_t.s_max_pu.replace(np.inf, 1.0, inplace=True)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if 'snakemake' not in globals():
|
if 'snakemake' not in globals():
|
||||||
from _helpers import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
snakemake = mock_snakemake('build_line_rating', network='elec', simpl='',
|
snakemake = mock_snakemake('build_line_rating', network='elec', simpl='',
|
||||||
clusters='5', ll='copt', opts='Co2L-BAU-CCL-24H')
|
clusters='6', ll='copt', opts='Co2L-24H')
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
n = pypsa.Network(snakemake.input.base_network)
|
n = pypsa.Network(snakemake.input.base_network)
|
||||||
da=add_line_rating(n)
|
da=calculate_line_rating(n)
|
||||||
|
|
||||||
da.to_netcdf(snakemake.output[0])
|
da.to_netcdf(snakemake.output[0])
|
Loading…
Reference in New Issue
Block a user