PowerFlows.jl icon indicating copy to clipboard operation
PowerFlows.jl copied to clipboard

How to update the PowerFlowData for multiple periods after solving an UC problem

Open eeliubin opened this issue 7 months ago • 5 comments

As indicated in the title, if an optimization problem is solved, how can I update the PowerFlowData, i.e. updating the PowerFlowData().bus_activepower_injection and PowerFlowData().bus_activepower_withdrawals based on the optimisation results?

It looks like both PowerFlowData().bus_activepower_injection and PowerFlowData().bus_activepower_withdrawals are not mutable.

eeliubin avatar Apr 14 '25 03:04 eeliubin

Hi @eeliubin ,

It should be possible to change the values of bus_activepower_injection and bus_activepower_withdrawals, as long as you change the values in the arrays (as opposed to reassigning the attributes of PowerFlowData), e.g. bus_activepower_withdrawals .= new_values.

Alternatively, if you execute the UC with PowerSimulations, you can specify that the power flow calculation is executed after a successful optimization:

https://github.com/NREL-Sienna/PowerSimulations.jl/blob/ba846178b5c4dc377f9bbc655bc725ee30f06db3/test/test_simulation_results.jl#L1035

rbolgaryn avatar Apr 14 '25 15:04 rbolgaryn

Thank you, @rbolgaryn & The approach you mentioned for setting bus_activepower_injection and bus_activepower_withdrawals works.

For the other approach, I wonder if there are any documents discussing how to define the keyword: power_flow_evaluation. Also, does the power flow evaluation perform the same process as if I run solve_powerflow(ACPowerFlow(), sys)? I noticed that that latter does not support PhaseShiftingTX for ACPowerFlow().

eeliubin avatar Apr 14 '25 23:04 eeliubin

You are welcome! The PowerFlows project is presently in active development, and we haven't yet gotten to writing a proper documentation. The latter power flow calculation is applied directly to the PowerFlowData instance, and consequently the results are not written back to data. Rather, they are included in the auxiliary variables after the optimization step. In other words, it uses the function solve_powerflow!(data::PowerFlowData; pf::ACPowerFlow). I am not sure about the phase shifter, I will need to check it. If you already have an example with the phase shifter, could you provide it for testing?

rbolgaryn avatar Apr 15 '25 01:04 rbolgaryn

I tested the 5-bus system in pss/e format under "....\PowerSystemsTestData\psse_raw\case5.raw" with the following codes: sys_path = joinpath([to define], "psse_raw", "case5.raw") sys = System(sys_path; runchecks=false, frequency=50 pf_res = solve_powerflow(ACPowerFlow(), sys)

The error showed that ERROR: Systems with PhaseShiftingTransformer not supported yet.

eeliubin avatar Apr 16 '25 00:04 eeliubin

I tested the 5-bus system in pss/e format under "....\PowerSystemsTestData\psse_raw\case5.raw" with the following codes: sys_path = joinpath([to define], "psse_raw", "case5.raw") sys = System(sys_path; runchecks=false, frequency=50 pf_res = solve_powerflow(ACPowerFlow(), sys)

The error showed that ERROR: Systems with PhaseShiftingTransformer not supported yet.

Can you please test it in the following way:

data = PowerFlowData(ACPowerFlow(), sys)
solve_powerflow!(data)

The results are written to the following fields:

bus_activepower_injection::Matrix{Float64}
bus_reactivepower_injection::Matrix{Float64}
bus_activepower_withdrawals::Matrix{Float64}
bus_reactivepower_withdrawals::Matrix{Float64}
branch_activepower_flow_from_to::Matrix{Float64}
branch_reactivepower_flow_from_to::Matrix{Float64}
branch_activepower_flow_to_from::Matrix{Float64}
branch_reactivepower_flow_to_from::Matrix{Float64}

rbolgaryn avatar Apr 17 '25 15:04 rbolgaryn

I am going to close this in favor of a more detailed one

jd-lara avatar Aug 04 '25 22:08 jd-lara