Updating an Iteration with new value

Hello everone,
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). Please which one of equations (2 & 3) is the correct updating code for new values;
% 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)))
THANK YOU
Vprev = V;
deltaprev = delta
........................................................................................................
for i = 1:5
for j = 1 : 5
P(i) = P(i) + V(i)*V(j)*(G(i,j)*cos(delta(i)-delta(j)) + B(i,j)*sin(delta(i)-delta(j))) equation (2)
end
end
OR
for i = 1:5
for j = 1 : 5
P(i) = V(i)*V(j)*(G(i,j)*cos(delta(i)-delta(j)) + B(i,j)*sin(delta(i)-delta(j))) equation (3)
end
end

10 Comments

Torsten
Torsten on 28 Jan 2023
Edited: Torsten on 28 Jan 2023
You asked this question before, but it is still unclear what the equations and what the unknowns are.
P(i) = sum(j=1->n) |Vi||Vj|(Gij * cos(delta_i - delta_j) + Bij * sin(delta_i - delta_j) (1<=i<=5)
defines e.g. 5 equations.
What are known values and what are the 5 unknowns ?
@Torsten, thank you for your reply. This question is similar but not the same with the initial post. This is just a question of which one of equations 2 & 3 is correct, e.g
P(i) = formula....
P(i) = P(i) + formula...
if I want to be updating the unknown variables in the formula, do i still need to add P(i) or not necessary
Thank you
Torsten
Torsten on 28 Jan 2023
Edited: Torsten on 28 Jan 2023
please could you send me your email to sanusielect@yahoo.com so that i send the code
Sorry, no.
P(i) = P(i) + formula...
cannot be correct because you add things to (the old) P(i) instead of updating it.
But setting
P(i) = formula ...
is also quite strange as an update because P(i-1) does not appear in the formula.
So I asked you to simply answer the question what your equations are and what variables you want to solve for.
Knowing this is necessary to answer your question.
"i need to be using the new values of V and delta as an update in equations (1)" So, how in your loop are you obtaining new arrays for V and delta? I don't see them changing anywhere in the loop, you're simply accessing different (row, column) entries for the same old V and delta matrices.
You set delta(3) to a logical value (true or false) ?
if i == 3
delta(i) = V_ang(i) == 0;
end
And you modify delta(2) here although you said it is determined by an equation ?
if i == 2 % U may check for possible rror here
delta(i) = delta(i) + delta(4);
end
@Torsten, yes, I set node 3 to 0 as the ground node
Torsten
Torsten on 29 Jan 2023
Edited: Torsten on 29 Jan 2023
So delta(3) should be = 1 if V_ang(3) = 0 and = 0 if V_ang(3) ~= 0 ?
@Torsten, the program is correct uptill the end of
G = real(YBUS); % conductance (G) <- real part of admittance
B = imag(YBUS) % susceptance (B) <- the imaginary part of admittance
The problem may be from the way I am using the constraints and may be initialization
# % Computing V
delta_ij = delta_i - delta_j same with delta(i,j) = delta(i) - delta(j)

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 28 Jan 2023

Commented:

on 29 Jan 2023

Community Treasure Hunt

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

Start Hunting!