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

Support in the loop PowerFlow evaluation #1040

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1c30601
add PFS deps
jd-lara Jan 9, 2024
0bcb68e
make time_steps consistent
jd-lara Jan 9, 2024
cac31f2
add PowerFlows
jd-lara Jan 9, 2024
1b7d415
add new aux variables for power flow
jd-lara Jan 9, 2024
02c52ed
make time steps consistent
jd-lara Jan 9, 2024
1e71c06
fix failing test
jd-lara Jan 9, 2024
a94defb
add power flow evaluator to model and container
jd-lara Jan 9, 2024
d1336c0
add evaluation in initialization
jd-lara Jan 9, 2024
7d1b0d2
add code for evaluation
jd-lara Jan 9, 2024
c4071f4
add missing kwarg
jd-lara Jan 9, 2024
61ee4b5
fix incorrect var type
jd-lara Jan 9, 2024
3b31d02
fix old bug
jd-lara Jan 9, 2024
347b67c
update aux vars for power flow evaluation
jd-lara Jan 9, 2024
5606f65
WIP: function for the power flow evaluation
jd-lara Jan 9, 2024
e8caaca
whitespace
jd-lara Jan 9, 2024
198e7b4
Merge branch 'main' into jd/pf_integration
jd-lara Jan 23, 2024
bf872ca
bump deps
jd-lara Jan 23, 2024
4e0f8ee
change to varnames
jd-lara Jan 23, 2024
7a2555a
add auxiliary variables
jd-lara Jan 23, 2024
d95ef9e
add wrapper for power flow data
jd-lara Jan 24, 2024
d2b26ac
use wrapper
jd-lara Jan 24, 2024
ddb92e3
add powerflow wrapper
jd-lara Jan 24, 2024
33bd977
power flow rename
jd-lara Jan 24, 2024
2645ced
file rename
jd-lara Jan 24, 2024
c997e2f
add evaluation to the container
jd-lara Jan 25, 2024
1ba76cb
WIP: add functions to map results to pf
jd-lara Jan 25, 2024
c11f4cf
Merge branch 'psy4' into jd/pf_integration
jd-lara Mar 6, 2024
4fcfa16
Merge branch 'main' into jd/pf_integration
GabrielKS Aug 19, 2024
b26e2b0
Remove redundant code
GabrielKS Oct 15, 2024
54e4859
Rewrite power flow evaluation to support more types of power flow
GabrielKS Oct 15, 2024
1e714ac
Support evaluation of multiple power flows in the loop
GabrielKS Oct 15, 2024
508db25
Better accommodate `PSSEExporter` in the loop, reduce duplication
GabrielKS Oct 16, 2024
b6fc453
Trait-based special behavior for power flow aux vars
GabrielKS Oct 17, 2024
eb51cfb
Scaffold subtype-based updating of power flow aux vars
GabrielKS Oct 17, 2024
dfd7405
Update power flow aux vars from `PowerFlowData`
GabrielKS Oct 17, 2024
c0ac0be
Complete prototype power flow in the loop -> export implementation
GabrielKS Oct 17, 2024
9e1f30a
Power flow in the loop: handle load special cases
GabrielKS Oct 28, 2024
1507b14
Power flow in the loop: support multi period export
GabrielKS Oct 28, 2024
9ec1356
Misc code cleanup following self-review
GabrielKS Oct 28, 2024
ad25918
Add basic tests of power flow in the loop
GabrielKS Nov 4, 2024
958e68d
Update `DISABLED_TEST_FILES`
GabrielKS Nov 4, 2024
187f473
Merge branch 'main' into jd/pf_integration
GabrielKS Nov 4, 2024
e016521
PERF: don't use `get_bus(sys, number)`, it's O(n)
GabrielKS Nov 19, 2024
30454e6
Add aux vars, infrastructure to receive results from AC power flow
GabrielKS Jan 16, 2025
a242ddf
Fix `bus_activepower_withdrawals` sign error
GabrielKS Jan 17, 2025
f5eb983
Merge branch 'main' into jd/pf_integration
jd-lara Jan 20, 2025
670d4fc
Fix merge, update dependencies
GabrielKS Jan 21, 2025
3e091c4
Power flow in the loop: support `exporter` kwarg interface
GabrielKS Jan 21, 2025
d5e6fab
Rewrite PSI -> PF mapping for more flexibility
GabrielKS Jan 22, 2025
b0ba0d6
Add `TimerOutputs.@timeit` for PF in the loop
GabrielKS Jan 22, 2025
7050684
Code cleanup, accommodate fine-tuned exporter interface
GabrielKS Jan 31, 2025
6f8a897
Clean up TODOs
GabrielKS Jan 31, 2025
9d4c2c6
Merge branch 'main' into jd/pf_integration
GabrielKS Jan 31, 2025
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
Prev Previous commit
Next Next commit
Power flow in the loop: support multi period export
  • Loading branch information
GabrielKS committed Oct 28, 2024
commit 1507b14720fd43370421e8f0931412acd7e3603c
39 changes: 32 additions & 7 deletions src/network_models/power_flow_evaluation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,27 +248,44 @@ _update_component(::Type{PowerFlowVoltageAngle}, comp::PSY.Component, value) =
_update_component(::Type{PowerFlowVoltageMagnitude}, comp::PSY.Component, value) =
comp.magnitude = value

function update_pf_system!(sys::PSY.System, container::OptimizationContainer, input_map)
TIME = 1 # TODO figure out how to handle multiple time periods here
function update_pf_system!(
sys::PSY.System,
container::OptimizationContainer,
input_map::Dict{<:OptimizationContainerKey, <:Any},
time_step::Int,
)
for (key, component_map) in input_map
result = lookup_value(container, key)
for (device_id, _) in component_map
injection_values = result[device_id, :]
comp = _lookup_component(get_component_type(key), sys, device_id)
val = jump_value(injection_values[TIME])
val = jump_value(injection_values[time_step])
_update_component(get_entry_type(key), comp, val)
end
end
end

"""
Update a `PowerFlowEvaluationData` containing a `PowerFlowContainer` that does not
`supports_multi_period` using a single `time_step` of the `OptimizationContainer`. To
properly keep track of outer step number, time steps must be passed in sequentially,
starting with 1.
"""
function update_pf_data!(
pf_e_data::PowerFlowEvaluationData{PFS.PSSEExporter},
container::OptimizationContainer,
time_step::Int,
)
pf_data = get_power_flow_data(pf_e_data)
input_map = get_input_key_map(pf_e_data)
update_pf_system!(PFS.get_system(pf_data), container, input_map)
isnothing(pf_data.step) || (pf_data.step += 1)
update_pf_system!(PFS.get_system(pf_data), container, input_map, time_step)
if !isnothing(pf_data.step)
outer_step, _ = pf_data.step
# time_step == 1 means we have rolled over to a new outer step
# (TODO it works but seems a little brittle, consider redesigning)
(time_step == 1) && (outer_step += 1)
pf_data.step = (outer_step, time_step)
end
return
end

Expand All @@ -281,8 +298,16 @@ end
function solve_powerflow!(
pf_e_data::PowerFlowEvaluationData,
container::OptimizationContainer)
update_pf_data!(pf_e_data, container)
PFS.solve_powerflow!(get_power_flow_data(pf_e_data))
pf_data = get_power_flow_data(pf_e_data)
if PFS.supports_multi_period(pf_data)
update_pf_data!(pf_e_data, container)
PFS.solve_powerflow!(pf_data)
else
for t in get_time_steps(container)
update_pf_data!(pf_e_data, container, t)
PFS.solve_powerflow!(pf_data)
end
end
pf_e_data.is_solved = true
return
end
Expand Down