Function: Series addition implementation

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

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
Torsten 2023년 1월 30일
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
Kamilu Sanusi 2023년 1월 30일
편집: Kamilu Sanusi 2023년 1월 30일
@Dyuman Joshi, No, I want to calculate P(i), I used P(2) to demostrate the expanded form of equation (1). I want to know if the code shown is able to implement the calculation of P(2) as an example. V(1) to V(5) are coming from an iteration and would be updating the value of P(i) untill P(i) converges. P(i) is already initialized to zero
for the equation I am trying to implement for i = 1 to N = 5.
Dyuman Joshi
Dyuman Joshi 2023년 1월 31일
편집: Dyuman Joshi 2023년 1월 31일
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.
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 .

댓글을 달려면 로그인하십시오.

답변 (0개)

제품

릴리스

R2021b

질문:

2023년 1월 29일

댓글:

2023년 2월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by