diff --git a/edisgo/network/overlying_grid.py b/edisgo/network/overlying_grid.py index 77c9ccadd..241768a20 100644 --- a/edisgo/network/overlying_grid.py +++ b/edisgo/network/overlying_grid.py @@ -385,6 +385,16 @@ def distribute_overlying_grid_requirements(edisgo_obj): scaling_df_min = ( edisgo_obj.dsm.p_min.transpose() / edisgo_obj.dsm.p_min.sum(axis=1) ) + # in case p_max/p_min of all DSM loads is zero in an hour but there is + # positive/negative DSM from the overlying grid, this is not correctly + # distributed and may lead to large errors in the time series with the + # distributed DSM + # in the following this is corrected by assuming an equal distribution + # during those hours + equal_dist_factor = 1 / len(dsm_loads) + scaling_df_max.fillna(equal_dist_factor, inplace=True) + scaling_df_min.fillna(equal_dist_factor, inplace=True) + edisgo_copy.timeseries._loads_active_power.loc[:, dsm_loads] = ( edisgo_obj.timeseries._loads_active_power.loc[:, dsm_loads] + ( diff --git a/edisgo/opf/eDisGo_OPF.jl/src/core/data.jl b/edisgo/opf/eDisGo_OPF.jl/src/core/data.jl index 1063cc1f4..f180f831a 100644 --- a/edisgo/opf/eDisGo_OPF.jl/src/core/data.jl +++ b/edisgo/opf/eDisGo_OPF.jl/src/core/data.jl @@ -1,7 +1,4 @@ function set_ac_bf_start_values!(network::Dict{String,<:Any}) - for (i,bus) in network["bus"] - bus["w_start"] = bus["w"] - end for (i,gen) in network["gen_nd"] gen["pgc_start"] = gen["pgc"] diff --git a/edisgo/opf/eDisGo_OPF.jl/src/form/bf.jl b/edisgo/opf/eDisGo_OPF.jl/src/form/bf.jl index e1db2d1bb..1245fe7bf 100644 --- a/edisgo/opf/eDisGo_OPF.jl/src/form/bf.jl +++ b/edisgo/opf/eDisGo_OPF.jl/src/form/bf.jl @@ -118,6 +118,23 @@ function constraint_max_line_loading(pm::AbstractSOCBFModelEdisgo, n::Int) end +function constraint_max_line_loading(pm::AbstractNCBFModelEdisgo, n::Int) + p = PowerModels.var(pm, n, :p) + q = PowerModels.var(pm, n, :q) + ll = PowerModels.var(pm, 1, :ll) + s_nom = Dict(i => get(branch, "rate_a", 1.0) for (i,branch) in PowerModels.ref(pm, n, :branch)) + + for (i,branch) in PowerModels.ref(pm, n, :branch) + f_bus = branch["f_bus"] + t_bus = branch["t_bus"] + f_idx = (i, f_bus, t_bus) + if !(branch["storage"]) + JuMP.@constraint(pm.model, (p[f_idx]^2 + q[f_idx]^2)/s_nom[i]^2 <= ll[f_idx]) + end + end +end + + function constraint_power_balance(pm::AbstractBFModelEdisgo, n::Int, i, bus_gens, bus_gens_nd, bus_gens_slack, bus_loads, bus_arcs_to, bus_arcs_from, bus_lines_to, bus_storage, bus_pg, bus_qg, bus_pg_nd, bus_qg_nd, bus_pd, bus_qd, branch_r, branch_x, bus_dsm, bus_hps, bus_cps, bus_storage_pf, bus_dsm_pf, bus_hps_pf, bus_cps_pf, bus_gen_nd_pf, bus_gen_d_pf, bus_loads_pf, branch_strg_pf) pt = get(PowerModels.var(pm, n), :p, Dict()); PowerModels._check_var_keys(pt, bus_arcs_to, "active power", "branch") qt = get(PowerModels.var(pm, n), :q, Dict()); PowerModels._check_var_keys(qt, bus_arcs_to, "reactive power", "branch")