@@ -278,7 +280,7 @@ function restore_p_balance!(network_data::Dict{String,<:Any})
end
#=
Restores active power balance in a connected component identified by the set of buses cc. Depending on whether an overproduction or underproduction exists, generator dispatches may be increased or reduced. If necessary, load can be shed by reducing the demands uniformly until the total demand matches generation. For more details see flow chart.
Restores active power balance (APB) in a connected component identified by the set of buses cc. Depending on whether an overproduction or underproduction exists, generator dispatches may be increased or reduced. If necessary, load can be shed by reducing the demands uniformly until the total demand matches generation. For more details see flow chart.
=#
function _restore_p_balance!(
network_data::Dict{String,<:Any},
...
...
@@ -300,51 +302,62 @@ function _restore_p_balance!(
network_data,active_cc_gens,active_cc_loads,cc
)
info(_LOGGER,"Active power mismatch in CC #$cc_i: $cc_Δp")
ϵ=1e-10# mismatch tolerated for APB
ifisapprox(cc_Δp,0,atol=1e-10)# "sufficient" power balance
nothing# nothing has to be done
elseifcc_Δp>0# overproduction
debug(_LOGGER,"Overproduction in CC #$cc_i: $cc_Δp")
ifcc_Δp>ϵ# overproduction
info(LOGGER,"Detected overproduction in (sub-)grid #$cc_i: $cc_Δp")
ifisapprox(cc_Δp_lim,0,atol=1e-10)# power balance at minimum
### Check how to restore APB (if possible)
ifisapprox(cc_Δp_lim,0,atol=ϵ)# power balance at minimum
info(LOGGER,"Setting dispatches in #$cc_i to their lower bounds!")