Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/optimisation fixes #414

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions edisgo/network/overlying_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
+ (
Expand Down
3 changes: 0 additions & 3 deletions edisgo/opf/eDisGo_OPF.jl/src/core/data.jl
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
17 changes: 17 additions & 0 deletions edisgo/opf/eDisGo_OPF.jl/src/form/bf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading