MATPOWER / matpower

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

Matpower 3.2, issue with network with more than 1 swing/slack bus #205

Closed JasonMic97 closed 7 months ago

JasonMic97 commented 1 year ago

Hi team MATPOWER My name is Jason Michael and I'm a Master's student in Electrical Engineering. I am currently finishing my degree and working on Optimal Power Flow. I'm using version 7.1 and for a specific case of Optimal Reactive Power Dispatch, I'm also using version 3.2. I am writing to you to ask for some clarification. I'm working on a network with 3 slack buses and the power flow process with version 7.1 works perfectly, but with version 3.2, I'm encountering the following problem:

Matrix dimensions must agree.

Error in pfsoln (line 39) refgen = find(gbus == ref); %% which is(are) the reference gen(s)?

Error in runpf (line 146) [bus, gen, branch] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref, pv, pq);

So, with all due respect, I would like you to help me with a solution to this problem. Very respectfully

JasonMic97 commented 1 year ago

Well guys, happily the AI chatgbt helped me, now it is working. this is the solution : %% Update Pg for swing bus for k = 1:length(ref) refgen = find(gbus == ref(k)); %% Determine which generators are connected to the reference bus for j = 1:length(refgen) %% Iterate through generators at the reference bus gen(on(refgen(j)), PG) = real(Sg(refgen(j))) * baseMVA + bus(ref(k), PD); %% Compute generator real power output end end

rdzman commented 1 year ago

Ok.

I'm just curious ... what is the reason behind using MATPOWER 3.2 (released ~16 years ago)? I'm a little surprised that it even runs on modern versions of MATLAB.

JasonMic97 commented 1 year ago

Hi Professor.

My reason for using this version is that I use matlab code from Optimal Reactive Power Dispatch with metaheuristic Particle Swarm Optimization (found on Matlab File Exchange); This code works with version 3.2, I remodified it to use it with version 7.1, but there were some variable declarations that didn't match and so I opted for 3.2 for this ORPD work. Otherwise finally I found the solution to the multi swing bus problem thanks to ChatGBT. I am using Matlab version 2020ra

Le lun. 2 oct. 2023 à 17:59, Ray Zimmerman @.***> a écrit :

Ok.

I'm just curious ... what is the reason behind using MATPOWER 3.2 (released ~16 years ago)? I'm a little surprised that it even runs on modern versions of MATLAB.

— Reply to this email directly, view it on GitHub https://github.com/MATPOWER/matpower/issues/205#issuecomment-1743491180, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCFYUQXLVV3NPHGGNTBNOV3X5L6JHAVCNFSM6AAAAAA5NVFJF6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBTGQ4TCMJYGA . You are receiving this because you authored the thread.Message ID: @.***>