Returns an array of tuples containing branch indices of branches with a minimum loading of min_loading and their actual loading (considering the power flow type pf_type). Choosing min_loading = 1. yields overloaded branches.
=#
function get_branches(
network_data::Dict{String,<:Any};
min_loading=0.0,# minimum loading of branches
pf_type="MVA-loading"# or "MW-loading", "Mvar-loading"
Deactivates branches that have been overloaded due to a power flow redistribution (flow/capacity > 1.). The branches are identified by their string indices in branch_ids. The status of these branches is set to 0 in network_data. Parallel branches are not automatically deactivated.
Calculates the total impact of a hurricane given the time series of damaged transmission lines. Each time a transmission line is destroyed, the AC power flow equations are solved and failure cascades may unfold. The output of the solver is saved in a .txt file.
=#
function calc_total_impact!(
network_data::Dict{String,<:Any},
tl_damage::Array{Tuple{String,Int64},1},# time series of tl damage
### Go through frames in which transmission lines were destroyed
forfinunique_frames
destroyed_tl=[dmg[1]fordmgintl_damageifdmg[2]==f]
destroy_tl!(network_data,destroyed_tl)
### Resolve AC-PF and see whether a cascade unfolds
_calc_cascade!(network_data,method,print_level)
end
returnnothing
end
#=
Calculates whether a cascading failure unfolds in a damaged network. If any network contained in network_data misses a slack bus, the largest generator is selected in each connected component. Additionally, the active power balance is restored for each connected component in every step, if it is violated.
Ideas for treating grid partitioning during cascading failures
---
-> Start by deactivating transmission line(s) that are the first destroyed by the hurricane
-> Run simplify_network! to update the grid topology
- save any deactivated load buses, since they contribute to the overall power outage!
-> Calculate connected components via calc_connected_components and check whether there are more than one connected component
-> If there is only one connected component: Jump to power flow calculation
-> If there are more than one connected component: Use correct_reference_buses! to define new slack buses for all components (uses "pmax" to find generator with largest capacity). Check whether active power balance is violated in any component and if so correct it! Jump to power flow calculation
-> Calculate AC power flow using run_ac_pf (JuMP model), since it tries to solve all connected components in parallel (NLsolve does not do that).
Question: Still use previous voltage magnitudes and angles as starting values after a graph partition happened??
MONITOR VOLTAGES DURING A CASCADE!? (reactive power imbalance may lead to voltage instability)
CALCULATE TOTAL FLOW CHANGES IN BRANCHES DURING CASCADES