# Sequential AC power flow using PowerModels.jl

**URL:** <https://discourse.julialang.org/t/sequential-ac-power-flow-using-powermodels-jl/96183>\
**Category:** Optimization (Mathematical)\
**Created:** [March 16, 2023, 1:05pm UTC](https://discourse.julialang.org/t/sequential-ac-power-flow-using-powermodels-jl/96183 "2023-03-16T13:05:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sstroemer](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@sstroemer](https://discourse.julialang.org/u/sstroemer)\
**Post date:** [March 16, 2023, 1:05pm UTC](https://discourse.julialang.org/t/sequential-ac-power-flow-using-powermodels-jl/96183/1 "2023-03-16T13:05:09Z")

</div>

I am trying to run repeated AC power flow calculations for a large grid using [PowerModels.jl](https://lanl-ansi.github.io/PowerModels.jl/stable/). Digging through [the code](https://github.com/lanl-ansi/PowerModels.jl/blob/master/src/prob/pf.jl#L137) revealed that there is some way to efficiently run successive power flow solves, but I couldn’t really figure out in the documentation what the most efficient way of doing this is.

Basically, I have a grid topology with buses, branches, loads, and generators fixed, but with varying setpoints for loads and generators for each timestep. After creating the initial `data` dictionary that describes the model, what is the best way to (1) run a power flow, (2) extract the loading factors of the branches (probably `calc_branch_flow_ac`), (3) update the setpoints for all loads/generators and restart with (1)?

---

<div class="post-metadata">

**Author:** ![ccoffrin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ccoffrin/32/400_2.png) [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Post date:** [March 16, 2023, 6:22pm UTC](https://discourse.julialang.org/t/sequential-ac-power-flow-using-powermodels-jl/96183/2 "2023-03-16T18:22:43Z")

</div>

This documentation provides a discussion of the tradeoffs of different Power Flow methods in PowerModels,

[https://lanl-ansi.github.io/PowerModels.jl/stable/power-flow/](https://lanl-ansi.github.io/PowerModels.jl/stable/power-flow/)

I suggest starting there. Most likely, switching from `solve_pf` to `compute_ac_pf` will give you the bulk of the runtime benefits for fast solving AC Power Flows. Going deeper into memory allocation savings in `compute_ac_pf`, as per the code you reference, I expect is no more than a 2x runtime improvement over the basic implementation that is provided.
