Function: Series addition implementation
Show older comments
Hello
I am trying to solve an equation of which i need to be using the new values of V and delta as an update in equations (1).The closed equation (1) when expanded will be in the form of equation (2) for i = 2 and j is between 1 -5.
% P(i) = sum(j=1->n) |Vi||Vj|(Gij * cos(delta_i - delta_j) + Bij * sin(delta_i - delta_j) EQUATION (1) % The formula for calculating the P
Implementation of P(2) for example:
P(2) = P(2) + V(2)*V(1)*(G(2,1)*cos(delta(2)-delta(1)) + B(2,1)*sin(delta(2)-delta(1))) + V(2)*V(2)*(G(2,2)*cos(delta(2)-delta(2)) + B(2,2)*sin(delta(2)-delta(2))) + V(2)*V(3)*(G(2,3)*cos(delta(2)-delta(3)) + B(2,3)*sin(delta(2)-delta(3))) + V(2)*V(4)*(G(2,4)*cos(delta(2)-delta(4)) + B(2,4)*sin(delta(2)-delta(4))) + V(2)*V(5)*(G(2,5)*cos(delta(2)-delta(5)) + B(2,5)*sin(delta(2)-delta(5))) EQUATION (2)
Please is the below program good enough to represent the expansion of P(2) in equation (2) as an example ?
% Program
P = zeros(nbus,1);
Q = zeros(nbus,1);
V = zeros(nbus,1);
% B and G are constants
% Computing P
% nbus = 5
for i = 1:nbus
for j = 1:nbus
if type(i) == 2 % Computing Pi & Qi for Droop bus
P(i) = V(i)*V(j)*(G(i,j)*cos(delta(i)-delta(j)) + ...
B(i,j)*sin(delta(i)-delta(j)))+ PO(i)-PL(i);
Q(i) = V(i)*V(j)*(G(i,j)*sin(delta(i)-delta(j)) - ...
B(i,j)*cos(delta(i)-delta(j)))+ QO(i)-QL(i);
end
end
end
5 Comments
Dyuman Joshi
on 30 Jan 2023
It's not clear as to what exactly you want to do.
Do you only want to calculate the value of P(2)?
"%B and G are constants"
Are B and G arrays of compatible size?
What are PO, PL, QO and QL? They are not part of the original equation.
Torsten
on 30 Jan 2023
As long as you are unable to write down the equations you want to solve and name the unknowns you want to solve for, how should we be able to help you ? Worse: how should you be able to properly implement your problem ?
Kamilu Sanusi
on 30 Jan 2023
Edited: Kamilu Sanusi
on 30 Jan 2023
Dyuman Joshi
on 31 Jan 2023
Edited: Dyuman Joshi
on 31 Jan 2023
Okay. But still have not answered my other queries.
The equation in the link do not contain PO, PL, QO and QL, where as your code does.
Walter Roberson
on 2 Feb 2023
for i = 1:nbus
for j = 1:nbus
if type(i) == 2 % Computing Pi & Qi for Droop bus
That is inefficient. type(i) does not change according to changes in j, so you should be testing type(i) outside the for j loop, only executing the for j loop if type(i) == 2
P(i) = V(i)*V(j)*(G(i,j)*cos(delta(i)-delta(j)) + ...
B(i,j)*sin(delta(i)-delta(j)))+ PO(i)-PL(i);
Q(i) = V(i)*V(j)*(G(i,j)*sin(delta(i)-delta(j)) - ...
B(i,j)*cos(delta(i)-delta(j)))+ QO(i)-QL(i);
P(i) does not depend upon P(i) or Q(i) so at each different j you completely overwrite P(i) and Q(i) and the final result will be the same as if you had only done the final j=nbus .
Answers (0)
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!