[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
2072aa4a99
commit
286b836c3f
@ -251,18 +251,23 @@ rule build_hydro_profile:
|
|||||||
"../scripts/build_hydro_profile.py"
|
"../scripts/build_hydro_profile.py"
|
||||||
|
|
||||||
|
|
||||||
if config['lines']['dynamic_line_rating']['activate']:
|
if config["lines"]["dynamic_line_rating"]["activate"]:
|
||||||
|
|
||||||
rule build_line_rating:
|
rule build_line_rating:
|
||||||
input:
|
input:
|
||||||
base_network="networks/base.nc",
|
base_network="networks/base.nc",
|
||||||
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:
|
||||||
benchmark: "benchmarks/build_line_rating"
|
"logs/build_line_rating.log",
|
||||||
|
benchmark:
|
||||||
|
"benchmarks/build_line_rating"
|
||||||
threads: ATLITE_NPROCESSES
|
threads: ATLITE_NPROCESSES
|
||||||
resources: mem_mb=ATLITE_NPROCESSES * 1000
|
resources:
|
||||||
script: "scripts/build_line_rating.py"
|
mem_mb=ATLITE_NPROCESSES * 1000,
|
||||||
|
script:
|
||||||
|
"scripts/build_line_rating.py"
|
||||||
|
|
||||||
|
|
||||||
rule add_electricity:
|
rule add_electricity:
|
||||||
@ -278,7 +283,9 @@ rule add_electricity:
|
|||||||
if str(fn).startswith("data/")
|
if str(fn).startswith("data/")
|
||||||
},
|
},
|
||||||
base_network=RESOURCES + "networks/base.nc",
|
base_network=RESOURCES + "networks/base.nc",
|
||||||
line_rating="resources/line_rating.nc" if config['lines']['dynamic_line_rating']['activate'] else "networks/base.nc",
|
line_rating="resources/line_rating.nc"
|
||||||
|
if config["lines"]["dynamic_line_rating"]["activate"]
|
||||||
|
else "networks/base.nc",
|
||||||
tech_costs=COSTS,
|
tech_costs=COSTS,
|
||||||
regions=RESOURCES + "regions_onshore.geojson",
|
regions=RESOURCES + "regions_onshore.geojson",
|
||||||
powerplants=RESOURCES + "powerplants.csv",
|
powerplants=RESOURCES + "powerplants.csv",
|
||||||
|
@ -700,19 +700,30 @@ def estimate_renewable_capacities(n, config):
|
|||||||
expansion_limit * n.generators.loc[tech_i, "p_nom_min"]
|
expansion_limit * n.generators.loc[tech_i, "p_nom_min"]
|
||||||
)
|
)
|
||||||
|
|
||||||
def attach_line_rating(n, rating, s_max_pu, correction_factor, max_voltage_difference, max_line_rating):
|
|
||||||
|
def attach_line_rating(
|
||||||
|
n, rating, s_max_pu, correction_factor, max_voltage_difference, max_line_rating
|
||||||
|
):
|
||||||
# TODO: Only considers overhead lines
|
# TODO: Only considers overhead lines
|
||||||
n.lines_t.s_max_pu = (rating / n.lines.s_nom[rating.columns]) * correction_factor
|
n.lines_t.s_max_pu = (rating / n.lines.s_nom[rating.columns]) * correction_factor
|
||||||
if max_voltage_difference:
|
if max_voltage_difference:
|
||||||
x_pu = n.lines.type.map(n.line_types["x_per_length"])*n.lines.length/(n.lines.v_nom**2)
|
x_pu = (
|
||||||
# need to clip here as cap values might be below 1
|
n.lines.type.map(n.line_types["x_per_length"])
|
||||||
|
* n.lines.length
|
||||||
|
/ (n.lines.v_nom**2)
|
||||||
|
)
|
||||||
|
# need to clip here as cap values might be below 1
|
||||||
# -> would mean the line cannot be operated at actual given pessimistic ampacity
|
# -> would mean the line cannot be operated at actual given pessimistic ampacity
|
||||||
s_max_pu_cap = (np.deg2rad(max_voltage_difference) / ( x_pu * n.lines.s_nom)).clip(lower=1)
|
s_max_pu_cap = (
|
||||||
n.lines_t.s_max_pu = n.lines_t.s_max_pu.clip(lower=1, upper=s_max_pu_cap, axis=1)
|
np.deg2rad(max_voltage_difference) / (x_pu * n.lines.s_nom)
|
||||||
|
).clip(lower=1)
|
||||||
|
n.lines_t.s_max_pu = n.lines_t.s_max_pu.clip(
|
||||||
|
lower=1, upper=s_max_pu_cap, axis=1
|
||||||
|
)
|
||||||
if max_line_rating:
|
if max_line_rating:
|
||||||
n.lines_t.s_max_pu = n.lines_t.s_max_pu.clip(upper=max_line_rating)
|
n.lines_t.s_max_pu = n.lines_t.s_max_pu.clip(upper=max_line_rating)
|
||||||
n.lines_t.s_max_pu *= s_max_pu
|
n.lines_t.s_max_pu *= s_max_pu
|
||||||
|
|
||||||
|
|
||||||
def add_nice_carrier_names(n, config):
|
def add_nice_carrier_names(n, config):
|
||||||
carrier_i = n.carriers.index
|
carrier_i = n.carriers.index
|
||||||
@ -864,18 +875,18 @@ if __name__ == "__main__":
|
|||||||
line_rating_config = snakemake.config["lines"]["dynamic_line_rating"]
|
line_rating_config = snakemake.config["lines"]["dynamic_line_rating"]
|
||||||
if line_rating_config["activate"]:
|
if line_rating_config["activate"]:
|
||||||
rating = xr.open_dataarray(snakemake.input.line_rating).to_pandas().transpose()
|
rating = xr.open_dataarray(snakemake.input.line_rating).to_pandas().transpose()
|
||||||
s_max_pu = snakemake.config["lines"]["s_max_pu"]
|
s_max_pu = snakemake.config["lines"]["s_max_pu"]
|
||||||
correction_factor = line_rating_config['correction_factor']
|
correction_factor = line_rating_config["correction_factor"]
|
||||||
max_voltage_difference = line_rating_config['max_voltage_difference']
|
max_voltage_difference = line_rating_config["max_voltage_difference"]
|
||||||
max_line_rating = line_rating_config['max_line_rating']
|
max_line_rating = line_rating_config["max_line_rating"]
|
||||||
|
|
||||||
attach_line_rating(
|
attach_line_rating(
|
||||||
n,
|
n,
|
||||||
rating,
|
rating,
|
||||||
s_max_pu,
|
s_max_pu,
|
||||||
correction_factor,
|
correction_factor,
|
||||||
max_voltage_difference,
|
max_voltage_difference,
|
||||||
max_line_rating
|
max_line_rating,
|
||||||
)
|
)
|
||||||
|
|
||||||
add_nice_carrier_names(n, snakemake.config)
|
add_nice_carrier_names(n, snakemake.config)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# SPDX-FileCopyrightText: : 2017-2020 The PyPSA-Eur Authors
|
# SPDX-FileCopyrightText: : 2017-2020 The PyPSA-Eur Authors
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
@ -50,21 +51,23 @@ the maximal possible capacity factor "s_max_pu" for each transmission line at ea
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from _helpers import configure_logging
|
|
||||||
|
|
||||||
import pypsa
|
|
||||||
import pandas as pd
|
|
||||||
import numpy as np
|
|
||||||
import geopandas as gpd
|
|
||||||
from shapely.geometry import Point, LineString as Line
|
|
||||||
import atlite
|
|
||||||
import xarray as xr
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import atlite
|
||||||
|
import geopandas as gpd
|
||||||
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
import pypsa
|
||||||
|
import xarray as xr
|
||||||
|
from _helpers import configure_logging
|
||||||
|
from shapely.geometry import LineString as Line
|
||||||
|
from shapely.geometry import Point
|
||||||
|
|
||||||
|
|
||||||
def calculate_resistance(T, R_ref, T_ref=293, alpha=0.00403):
|
def calculate_resistance(T, R_ref, T_ref=293, alpha=0.00403):
|
||||||
"""
|
"""
|
||||||
Calculates the resistance at other temperatures than the reference temperature.
|
Calculates the resistance at other temperatures than the reference
|
||||||
|
temperature.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@ -86,7 +89,8 @@ def calculate_resistance(T, R_ref, T_ref=293, alpha=0.00403):
|
|||||||
|
|
||||||
def calculate_line_rating(n, cutout):
|
def calculate_line_rating(n, cutout):
|
||||||
"""
|
"""
|
||||||
Calculates the maximal allowed power flow in each line for each time step considering the maximal temperature.
|
Calculates the maximal allowed power flow in each line for each time step
|
||||||
|
considering the maximal temperature.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
Loading…
Reference in New Issue
Block a user