obtaining p-v curves using Matlab
이전 댓글 표시
hi, everyone, I am trying to Obtain P-V curves using Matlab can anyone help me through it, please
댓글 수: 4
Shahabullah Amin
2018년 4월 26일
편집: Walter Roberson
2018년 4월 27일
Walter Roberson
2018년 4월 27일
What difficulty are you observing?
Shahabullah Amin
2018년 4월 28일
Shahabullah Amin
2018년 4월 28일
답변 (2개)
Walter Roberson
2018년 4월 28일
clc;
clear all
syms X
z=0.1+0.5*1j;
Vs=1;
A=1;
a1=real(A); a2=imag(A);
A=a1+a2*1j;
B=z;
b1=real(B); b2=imag(B);
C=0;
D=A;
fi=acos(1);
K1=a1*(b2-b1*tan(fi))+a2*(b1+b2*tan(fi));
K2=a1*(b1+b2*tan(fi))+a2*(b1-b2*tan(fi));
deltarcrit=(pi/4)+0.5*atan(K2/-K1);
Vrcrit=Vs/(2*(a1*cos(deltarcrit)+a2*sin(deltarcrit)));
K3=b1*cos(deltarcrit)+b2*sin(deltarcrit);
K4=a1*cos(deltarcrit)+a2*sin(deltarcrit);
Prcrit=((Vs^2)*(2*K3*K4-(a1*b1+a2*b2)))/((b1^2+b2^2)*4*K4);
Vr=[];
for P=0.1:0.01:1
Qr=P*tan(fi);
P1=a1^2+a2^2;
P2=2*P*(a1*b1+a2*b2)+2*Qr*(a1*b2+a2*b1)-Vs^2;
P3=((b1+b2).^2)*(P^2+Qr^2);
equation=P1*(X^2)+P2*X+P3;
these_roots = roots([P1 P2 P3]);
mask = any(imag(these_roots) ~= 0,2);
these_roots(mask,:) = nan;
Vr=[Vr these_roots];
end
Pr=(0.1:0.01:1);
plot(Pr,Vr.')
display(Prcrit)
댓글 수: 1
Walter Roberson
2018년 4월 28일
The area that it does not draw is the area where the roots go complex.
If you change the P loop to
syms P
Qr=P*tan(fi);
P1=a1^2+a2^2;
P2=2*P*(a1*b1+a2*b2)+2*Qr*(a1*b2+a2*b1)-Vs^2;
P3=((b1+b2).^2)*(P^2+Qr^2);
equation=P1*(X^2)+P2*X+P3;
Vr = solve(equation, X);
then because you do not change anything other than P in the loop, you can get the general form, which is
equation = (9*P^2)/25 + X^2 + X*(P/5 - 1)
and then Vr is
1/2 - (5^(1/2)*(-(7*P - 5)*(P + 1))^(1/2))/10 - P/10
(5^(1/2)*(-(7*P - 5)*(P + 1))^(1/2))/10 - P/10 + 1/2
That has a term
(-(7*P - 5)*(P + 1))^(1/2)
so the equation is real-valued if -(7*P - 5)*(P + 1) is positive. When P is positive (as is the case in your for loop), P+1 is always positive. So real or imaginary is going for the root is going to have a boundary when 7*P - 5 becomes 0, which is P = 5/7 which is about 0.714285714285 . Below that you have real roots; above that you have only imaginary roots.
Shahabullah Amin
2018년 4월 29일
0 개 추천
댓글 수: 1
Walter Roberson
2018년 4월 29일
Use a higher resolution on P.
Or use the symbolic form I showed, and then
fplot(Vr, [0 0.75])
The code you posted certainly does not have real-valued solutions as far out as 2.7
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

