MATPOWER / matpower

MATPOWER – steady state power flow simulation and optimization for MATLAB and Octave
https://matpower.org
Other
417 stars 151 forks source link

DC power flow converge, but DCOPF diverge #153

Closed yanda1234 closed 1 year ago

yanda1234 commented 1 year ago

Hi,

I encountered a weird issue. The DC power flow can converge, but the DC OPF cannot, even after all branches' rate_A have been set as 0 (i.e no limit). How could this happen? (I have checked that there is no island.)

image image image

In addition, I saved the case into psse and rerun dc power flow there, then I got a different result from DC power flow in matpower. Is there any default setting should be changed? (power flow from 200034-200065). I got around 1000MW in psse, but got over 30000 MW in matpower.

image image

Kindly advise. Many thanks!

Best, Yanda

rdzman commented 1 year ago

First of all, which solver are you using?

I'm not recognizing the cause of the warning message you are getting, but I am suspicious about whether the modeling is valid given the range of voltage angles coming out of the DC PF (from -20 deg to 327 deg).

I'm also not sure what is causing the difference with PSS/E. It's possible they have controls that are active by default during the power flow run that MATPOWER does not include. I'm pretty sure that's the case for AC power flow, but I don't know about DC.

yanda1234 commented 1 year ago

First of all, which solver are you using?

I'm not recognizing the cause of the warning message you are getting, but I am suspicious about whether the modeling is valid given the range of voltage angles coming out of the DC PF (from -20 deg to 327 deg).

I'm also not sure what is causing the difference with PSS/E. It's possible they have controls that are active by default during the power flow run that MATPOWER does not include. I'm pretty sure that's the case for AC power flow, but I don't know about DC.

**Hi Dr. Zimmerman,

Thanks for your prompt reply. The DC power flow solver I used is just default choice. Is there any specific solver to recommend? Besides, could you please clarify a little bit about your concern of model's validity? What kind of system model can be judged as invalid? Below is the screenshot while I tried to run DC OPF. I went back and forth, but still cannot figure out why this DCopf doesn't converge. image In addition, after I set too large (>=1) and too small (<=0) impedances all be 1e-4, the DC OPF got converged. However, before convergence, it showed some ill-conditioned warnings. Is this because the sharp difference in impedances' values? Then I am curious if the convergence is reliable or not. image

Btw, if DC power flow is solved, does that mean DCopf should have a feasible solution? Or if DCopf can converge or not is totally independent from DC power flow has a solution.

Kindly advise.

Best, Yanda**

rdzman commented 1 year ago

The DC power flow simply solves an A * x == b problem, so the default solver for that is fine if A is non-singular. I was referring to the solver for the DC OPF. And the default depends on what solvers you have installed. If you are able to take advantage of their free academic license, I recommend Gurobi. MOSEK and CPLEX are also good options. If those are not available, MATLAB's linprog (requires Optimization Toolbox) or possibly GLPK.

In terms of the model's validity, the DC power flow model may be a reasonable approximation to the full non-linear AC model if the simplifying assumptions are valid (see Section 3.7 in the MATPOWER User's Manual). One of them is that branch angle differences are small enough that the sine of the angle can be approximated by the angle itself in radians. If the DC power flow is producing large angle differences, then it is not a very good approximation to the original AC model.

From the new warning message, it looks like there may be an issue with gencost. You may want to double-check to be sure you are specifying valid linear, quadratic or piecewise linear costs for each generator.

The ill-conditioning could be from impedances with very small absolute value ... or possibly (not sure) from the cost issue above.

As long as there are no branch flow limits, a solved DC power flow will be a feasible solution for the OPF if and only if all of the generators were set to feasible dispatches and the solved slack generator dispatch is also within its bounds.

yanda1234 commented 1 year ago

Thanks a lot, Dr. Zimmerman. Is there any manual to explain how to connect Gurobi with matpower? I tried many times, but didn't make it yesterday.

rdzman commented 1 year ago

Nothing special for MATPOWER. Simply install Gurobi according to their instructions for the Matlab interface. Then restart MATLAB for MATPOWER to recognize it.

Maybe this link will help.

If you're still having trouble, let me know.

yanda1234 commented 1 year ago

Thanks, Dr. Zimmerman. I have found the problem is due to the solver. When the system size reaches certain level, glpk cannot solve DCOPF correctly, while linprog of matlab can. I am curious if this difference is due to algorithm itself or some default settings. Is it possible I can solve this via resetting parameters of glpk? I might have to use Octave due to license issue and Gurobi doesn't have interface with Octave. It seems Mosek has an interface, but not sure if Mosek is as capable as matlab's linprog. Kindly advise.

rdzman commented 1 year ago

Overall, I think MOSEK may be better than linprog, but my experience is rather limited.

I have also run into problems with GLPK on some problems and have encountered cases where it helps to turn off the scaling and or pre-solve options.

yanda1234 commented 1 year ago

Thanks, Dr. Zimmerman. I tried turning off scaling and pre-solve options, but they don't work for me. I will try to get linprog or Mosek. Thanks a lot for helping me go through this. Deeply appreciated!

rdzman commented 1 year ago

I've not used MOSEK with Octave in MATPOWER, so that interface is untested. If you do get MOSEK working with Octave, please share your experience as I'd like to give it a try too. Do you know if they provide the MEX interface or do you have to build your own?

yanda1234 commented 1 year ago

Hi Dr. Zimmerman,

I am still waiting for my colleague's response. If they can get matlab license, I would use matlab directly. Or I would try Mosek. Here is a link which claims having Mosek-Octave interface, but I didn't test it yet. https://github.com/MOSEK/octmosek

Best, Yanda

rdzman commented 1 year ago

Yeah, it looks like that interface is about 9 or 10 years old and only works for MOSEK 6. Hopefully, you can get a Matlab license.

yanda1234 commented 1 year ago

I just got it this morning. Thx, Dr. Zimmerman!

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Ray Zimmerman @.> Sent: Tuesday, November 15, 2022 1:55:55 PM To: MATPOWER/matpower @.> Cc: Jiang, Yanda [E CPE] @.>; State change @.> Subject: Re: [MATPOWER/matpower] DC power flow converge, but DCOPF diverge (Issue #153)

Yeah, it looks like that interface is about 9 or 10 years old and only works for MOSEK 6. Hopefully, you can get a Matlab license.

— Reply to this email directly, view it on GitHubhttps://github.com/MATPOWER/matpower/issues/153#issuecomment-1315795796, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2PANVRV5LJ4LYPRIYA3A63WIPTEXANCNFSM6AAAAAAR2RYZE4. You are receiving this because you modified the open/close state.Message ID: @.***>

yanda1234 commented 1 year ago

The DC power flow simply solves an A * x == b problem, so the default solver for that is fine if A is non-singular. I was referring to the solver for the DC OPF. And the default depends on what solvers you have installed. If you are able to take advantage of their free academic license, I recommend Gurobi. MOSEK and CPLEX are also good options. If those are not available, MATLAB's linprog (requires Optimization Toolbox) or possibly GLPK.

In terms of the model's validity, the DC power flow model may be a reasonable approximation to the full non-linear AC model if the simplifying assumptions are valid (see Section 3.7 in the MATPOWER User's Manual). One of them is that branch angle differences are small enough that the sine of the angle can be approximated by the angle itself in radians. If the DC power flow is producing large angle differences, then it is not a very good approximation to the original AC model.

From the new warning message, it looks like there may be an issue with gencost. You may want to double-check to be sure you are specifying valid linear, quadratic or piecewise linear costs for each generator.

The ill-conditioning could be from impedances with very small absolute value ... or possibly (not sure) from the cost issue above.

As long as there are no branch flow limits, a solved DC power flow will be a feasible solution for the OPF if and only if all of the generators were set to feasible dispatches and the solved slack generator dispatch is also within its bounds.

Hi Dr. Zimmerman,

Do you know if pyomo has a good solver for DCOPF?

Best, Yanda

rdzman commented 1 year ago

I'm afraid I'm not really familiar with pyomo, but I would guess that it has interfaces to at least some of the major solvers like Gurobi, CPLEX, MOSEK.

yanda1234 commented 1 year ago

I see. Thanks, Dr. Zimmerman. I misunderstood my colleague's meaning as pyomo has solvers by itself.


From: Ray Zimmerman @.> Sent: Monday, November 21, 2022 11:08 AM To: MATPOWER/matpower @.> Cc: Jiang, Yanda [E CPE] @.>; State change @.> Subject: Re: [MATPOWER/matpower] DC power flow converge, but DCOPF diverge (Issue #153)

I'm afraid I'm not really familiar with pyomo, but I would guess that it has interfaces to at least some of the major solvers like Gurobi, CPLEX, MOSEK.

— Reply to this email directly, view it on GitHubhttps://github.com/MATPOWER/matpower/issues/153#issuecomment-1322387958, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2PANVRYHJWEI63F3QLXW7DWJOUCHANCNFSM6AAAAAAR2RYZE4. You are receiving this because you modified the open/close state.Message ID: @.***>