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 comentarios

Dyuman Joshi
Dyuman Joshi el 30 de En. de 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
Torsten el 30 de En. de 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
Kamilu Sanusi el 30 de En. de 2023
Editada: Kamilu Sanusi el 30 de En. de 2023
@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 el 31 de En. de 2023
Editada: Dyuman Joshi el 31 de En. de 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.
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 .

Iniciar sesión para comentar.

Respuestas (0)

Productos

Versión

R2021b

Preguntada:

el 29 de En. de 2023

Comentada:

el 2 de Feb. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by