# PowerModels active and reactive power demand

**URL:** <https://discourse.julialang.org/t/powermodels-active-and-reactive-power-demand/119787>\
**Category:** Optimization (Mathematical)\
**Created:** [September 24, 2024, 3:52am UTC](https://discourse.julialang.org/t/powermodels-active-and-reactive-power-demand/119787 "2024-09-24T03:52:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glon](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@Glon](https://discourse.julialang.org/u/Glon)\
**Post date:** [September 24, 2024, 3:52am UTC](https://discourse.julialang.org/t/powermodels-active-and-reactive-power-demand/119787/1 "2024-09-24T03:52:45Z")

</div>

Hello all,

I am new to Julia and I am trying to run an acopf problem, but having trouble on how to loop it for a whole day. I have the active and reactive power demand at each bus for every 30 minutes. Below is the code I have for allocating the same Pb and Qb at each node.

n=24  
Pb = 7.75_ones(n-1,1)  
Qb = Pb_tan(acos(0.97))\*ones(1,n-1)

Please help.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 24, 2024, 5:06am UTC](https://discourse.julialang.org/t/powermodels-active-and-reactive-power-demand/119787/2 "2024-09-24T05:06:16Z")

</div>

Hi @Glon, welcome to the forum 😄

By default, PowerModels.jl builds single-period models.

Solving a multi period problem depends on how you want to solve it.

You could write a `for`-loop that loops over your data, modifies the network data struct in PowerModels, and solves a new problem for each 30 minute block.

Here’s the documentation for PowerModels: [Getting Started · PowerModels](https://lanl-ansi.github.io/PowerModels.jl/stable/quickguide/)

You might also want to consider something like this:

> **[Rolling horizon problems · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/algorithms/rolling_horizon/)**
>
> Documentation for JuMP.

---

<div class="post-metadata">

**Author:** ![Glon](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@Glon](https://discourse.julialang.org/u/Glon)\
**Post date:** [September 24, 2024, 6:27am UTC](https://discourse.julialang.org/t/powermodels-active-and-reactive-power-demand/119787/3 "2024-09-24T06:27:14Z")

</div>

Thank you!

I will give it a try and see how it goes.
