Function: Series addition implementation

1 visualizzazione (ultimi 30 giorni)
Kamilu Sanusi
Kamilu Sanusi il 29 Gen 2023
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 Commenti
Dyuman Joshi
Dyuman Joshi il 31 Gen 2023
Modificato: Dyuman Joshi il 31 Gen 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
Walter Roberson il 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 .

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by