フィルターのクリア

How do I plot eta only when it's then 0?

4 ビュー (過去 30 日間)
Paul Rogers
Paul Rogers 2019 年 10 月 17 日
コメント済み: Paul Rogers 2019 年 10 月 17 日
Hi everybody, and thanks for your help.
I need some help for the gollowing code:
  • print rendimento only when eta>0
  • evalute p02 p2 =((1+((eta.*deltaideal)/(T01*cp))).^(k/(k-1))); when m>0 and with p02=m^2 when m<0
while N<Nmax+1
U1 = (D1*pi.*N)/60;
U2 = (D2*pi.*N)/60;
alfa2b = atan((D1*tan(beta1b))/(sigma*D2));
deltaideal = sigma*(U2^2);
deltahii = 0.5.*((U1-((cot(beta1b).*m)/(ro1*Ai))).^2);
deltahid = 0.5.*(((sigma*D2*U1)/D1)-((m.*cot(alfa2b))/(ro1*Ad))).^2;
deltahfi = kf.*(m.^2);
deltahfd = kfd.*(m.^2);
deltan = deltanbf+deltanv+deltanc+deltand;
deltaloss = deltahii+deltahid+deltahfi+deltahfd;
eta = ((deltaideal)./(deltaideal+deltaloss))-deltan;
p2 =((1+((eta.*deltaideal)/(T01*cp))).^(k/(k-1)));
figure(1);
title('Rendimento')
xlabel('Mass Flow [kg/s]')
ylabel('eta')
grid on
plot(m,eta);
hold on
figure(2);
title('Pressione')
xlabel('Mass Flow [kg/s]')
ylabel('p02')
grid on
plot(m,p2);
hold on
N=N+Nincr
end
  1 件のコメント
prasanth s
prasanth s 2019 年 10 月 17 日
write the plot function inside the if condition
if eta>0
plot(m,eta);
end

サインインしてコメントする。

回答 (1 件)

Paul Rogers
Paul Rogers 2019 年 10 月 17 日
Thank prasanth, I did it before, but it's not working properly, it only plots 2 of the 3 desired lines if I put the plot in the if condition.
Here all the code:
%Gas properties
a01 = 340; %speed of sound in gas(m/s)
p01 = 1e5; %Compressor inlet pressure(Pa)
T01 = 303.35; %Compressor inlet temperature(K)
cp = 1005; %specific heat capacity for constant pressure, property of gas(J/(kg*K))
ro1 = 1.15; %Gas density(kg/m^3)
Re = 100000; %Reynolds number()
k = 1.4; %Gas constant ratio, cp/cv()
%Compressor characteristics
L = 1.253; %Length of compressor and duct(m)
Vp = 0.21; %Plenum volume(m^3)
kl = 0.0008; %Throttle gain, proportional to the throttle opening
Dt1 = 0.074; %Impeller diameter at inducer tip(m)
Dh1 = 0.032; %Impeller diameter at hub casing(m)
D1 = 1/sqrt(2)*sqrt((Dt1)^2+(Dh1)^2); %Average diameter(m)
Di = 0.02; %Mean hydraulic diameter of impeller(m)
Dd = 0.02; %Mean hydraulic diameter of impeller(m)
I = 0.001; %Moment of inertia for the compressor spool(kg*m^2)
alfa1 = pi/2; %Flow angle at inducer, for alpha1 = pi/2 rad, assumed no pre-whirl
A = ((pi*D1^2)/4)*4;
Ai = ((pi*D1^2)/4); % Cross section area impeller(m^2)
Ad = ((pi*D1^2)/4); % Cross section area diffuser(m^2)
deltanbf = 0.05; %Back flow loss()
deltanv = 0.035; %Volute loss()
deltanc = 0; %Clearance loss()
deltand = 0; %Diffusion loss()
li = 0.053; %Mean channel length(m)
ld = 0.053; %Mean channel length(m)
beta1b = 0.61; %Impeller blade inlet angle()
Ch = 4*0.3164*(Re)^-0.25; %Friction loss coefficient()
kf = (Ch*li)/(2*Di*ro1^2*Ai^2*(sin(beta1b))^2)*4; %Friction loss impeller
kfd = (Ch*ld)/(2*Dd*ro1^2*Ad^2*(sin(beta1b))^2);%Friction loss diffuser
sigma = 0.9; %Slip factor()
D2 = 0.128; %Diameter of impeller tip(m)
m = [-0.2:0.01:0.8]; % [kg/s] Mass Flow
Nmin = 20000; %Desired setpoint for engine revolution(rpm)
Nmax = 50000; %Maximum setpoint for engine revolution(rpm)
Nincr=15000; %Incremento numero di giri
N=Nmin;
while N<Nmax+1
U1 = (D1*pi.*N)/60;
U2 = (D2*pi.*N)/60;
alfa2b = atan((D1*tan(beta1b))/(sigma*D2));
deltaideal = sigma*(U2^2);
deltahii = 0.5.*((U1-((cot(beta1b).*m)/(ro1*Ai))).^2);
deltahid = 0.5.*(((sigma*D2*U1)/D1)-((m.*cot(alfa2b))/(ro1*Ad))).^2;
deltahfi = kf.*(m.^2);
deltahfd = kfd.*(m.^2);
deltan = deltanbf+deltanv+deltanc+deltand;
deltaloss = deltahii+deltahid+deltahfi+deltahfd;
eta = ((deltaideal)./(deltaideal+deltaloss))-deltan;
p2 =((1+((eta.*deltaideal)/(T01*cp))).^(k/(k-1)));
if eta>0
figure(1);
title('Rendimento')
xlabel('Mass Flow [kg/s]')
ylabel('eta')
grid on
plot(m,eta);
hold on
end
figure(2);
title('Pressione')
xlabel('Mass Flow [kg/s]')
ylabel('p02')
grid on
plot(m,p2);
hold on
N=N+Nincr
end
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 10 月 17 日
eta is a vector. What does it mean to print rendimento only when eta>0 ? Do you want non-positive values to be skipped in the plot?
Paul Rogers
Paul Rogers 2019 年 10 月 17 日
exacly, when eta is negative I don't want to be plotted

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by