add_electricity: fix minor bug and clip s_max_pu_cap values

This commit is contained in:
Philipp Glaum 2022-02-17 14:50:11 +01:00
parent 1d975bb814
commit 86942b0afc

View File

@ -526,13 +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, s_max_py_factor):
def attach_line_rating(n, fn, s_max_pu_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)
x = n.lines.type.map(n.line_types["x_per_length"])*n.lines.length/(n.lines.v_nom**2)
s_max_pu_cap = (np.pi / (6 * x * n.lines.s_nom)).clip(lower=1) # need to clip here as cap values are below 1 -> would mean the line cannot be operated at actual given pessimistic ampacity
n.lines_t.s_max_pu = n.lines_t.s_max_pu.clip(upper=s_max_pu_cap, lower=1, axis=1)*s_max_pu_factor
def add_nice_carrier_names(n, config):
carrier_i = n.carriers.index