导读以前工作中编写过一些一维定常绝热流动气动函数的matlab代码,这里把它们贴出来,这些程序都可以在matlab里面直接调用,有需要的人可以自取使用。
说明
这里分享的是一些最简单的气动函数互相换算的程序,都做成了matlab函数的形式,可直接调用。
举一个简单的例子如下:
已知总温和静温计算马赫数:
TtTs2Ma.m
% TtTs2Ma
% function Ma = TtTs2Ma(Tt,Ts,k)
% if k not provided, use default value 1.4
function Ma = TtTs2Ma(Tt,Ts,k)
if nargin<3
k=1.4;
end
Ma=sqrt((Tt/Ts-1)*(2/(k-1)));
可以在命令行用,也可以在程序中用,命令行使用截图如下:
即总温为300K,静温为273K时,对应的马赫数为0.7032。其它的程序用法类似,都很简单,不再赘述。
源代码
1. 已知速度系数计算马赫数
lamda2Ma.m
% lamda2Ma
% function Ma = lamda2Ma(lamda,k)
% if k is not provided, then use the default value 1.4
function Ma = lamda2Ma(lamda,k)
if nargin<2
k=1.4;
end
Ma=sqrt(2/(k 1)*lamda*lamda/(1-(k-1)/(k 1)*lamda*lamda));
2. 已知速度系数计算流量函数
lamda2qlamda.m
% lamda2qlamda
% function qlamda = lamda2qlamda(lamda,k)
% if k is not provided, then use the default value 1.4
function qlamda = lamda2qlamda(lamda,k)
if nargin<2
k=1.4;
end
qlamda=((k 1)/2)^(1/(k-1))*lamda*(1-(k-1)/(k 1)*lamda*lamda)^(1/(k-1));
3. 已知马赫数计算速度系数
Ma2lamda.m
% Ma2lamda
% function lamda = Ma2lamda(Ma,k)
% if k is not provided, then use the default value 1.4
function lamda = Ma2lamda(Ma,k)
if nargin<2
k=1.4;
end
lamda=sqrt((k 1)/2*Ma*Ma/(1 (k-1)/2*Ma*Ma));
4. 已知静压和马赫数计算总压
PsMa2Pt.m
% PsMa2Pt
% function Pt = PsMa2Pt(Ps,Ma,k)
% if k is not provided, then use the default value 1.4
function Pt = PsMa2Pt(Ps,Ma,k)
if nargin<3
k=1.4;
end
Pt=Ps*(1 (k-1)/2*Ma*Ma)^(k/(k-1));
5. 已知总压和马赫数计算静压
PtMa2Ps.m
% PtMa2Ps
% function Ps = PtMa2Ps(Pt,Ma,k)
% if k is not provided, then use the default value 1.4
function Ps = PtMa2Ps(Pt,Ma,k)
if nargin<3
k=1.4;
end
Ps=Pt/(1 (k-1)/2*Ma*Ma)^(k/(k-1));
6. 已知总压和静压计算速度系数
PtPs2lamda.m
% PtPs2lamda
% function lamda = PtPs2lamda(Pt,Ps,k)
% if k is not provided, then use the default value 1.4
function lamda = PtPs2lamda(Pt,Ps,k)
if nargin<3
k=1.4;
end
lamda=sqrt((1-(Ps/Pt)^((k-1)/k))*(k 1)/(k-1));
7. 已知总压和静压计算马赫数
PtPs2Ma.m
% PtPs2Ma
% function Ma = PtPs2Ma(Pt,Ps,k)
% if k is not provided, then use the default value 1.4
function Ma = PtPs2Ma(Pt,Ps,k)
if nargin<3
k=1.4;
end
Ma=sqrt(((Pt/Ps)^((k-1)/k)-1)*2/(k-1));
8. 已知流量函数计算速度系数
qlamda2lamda.m
(这个用的是二分法,缺省最多循环200次,精度10e-12。同时给出亚声速和超声速两个值。)
% qlamda2lamda
% function [lamdaa,lamdab] = qlamda2lamda(qlamda,k)
% if k is not provided, then use the default value 1.4
function [lamdaa,lamdab] = qlamda2lamda(qlamda,k)
if nargin<2
k=1.4;
end
if qlamda>1
lamdaa=0;
lamdab=0;
fprintf('qlamda>1! ---- printed from function qlamda2lamda\n');
return;
end
nn=200;
err=1e-12;
lamda1=0.0;
lamda2=1.0;
qlamda1=((k 1)/2)^(1/(k-1))*lamda1*(1-(k-1)/(k 1)*lamda1*lamda1)^(1/(k-1));
qlamda2=((k 1)/2)^(1/(k-1))*lamda2*(1-(k-1)/(k 1)*lamda2*lamda2)^(1/(k-1));
for i=1:nn
if abs(lamda1-lamda2)<=err;
break;
end
lamdai=(lamda1 lamda2)/2;
qlamdai=((k 1)/2)^(1/(k-1))*lamdai*(1-(k-1)/(k 1)*lamdai*lamdai)^(1/(k-1));
if (qlamda1-qlamda)*(qlamdai-qlamda)>0
lamda1=lamdai;
else
lamda2=lamdai;
end
end
lamdaa=lamdai;
lamda1=1.0;
lamda2=sqrt((k 1)/(k-1));
qlamda1=((k 1)/2)^(1/(k-1))*lamda1*(1-(k-1)/(k 1)*lamda1*lamda1)^(1/(k-1));
qlamda2=((k 1)/2)^(1/(k-1))*lamda2*(1-(k-1)/(k 1)*lamda2*lamda2)^(1/(k-1));
for i=1:nn
if abs(lamda1-lamda2)<=err;
break;
end
lamdai=(lamda1 lamda2)/2;
qlamdai=((k 1)/2)^(1/(k-1))*lamdai*(1-(k-1)/(k 1)*lamdai*lamdai)^(1/(k-1));
if (qlamda1-qlamda)*(qlamdai-qlamda)>0
lamda1=lamdai;
else
lamda2=lamdai;
end
end
lamdab=lamdai;
9. 已知总压、总温、面积和流量函数,计算流量
Qm_comp.m
% Qm_comp
% function Qm = Qm_comp(Pt,Tt,A,qlamda,k)
% if k is not provided, then use the default value 1.4
function Qm = Qm_comp(Pt,Tt,A,qlamda,k)
if nargin<5
k=1.4;
end
R=287.06;
K=sqrt(k/R*(2/(k 1))^((k 1)/(k-1)));
Qm=K*Pt/sqrt(Tt)*A*qlamda;
10. 已知总压、总温、面积和流量,计算流量函数
Qm2qlamda.m
% Qm2qlamda.m
% function qlamda = Qm2qlamda(Pt,Tt,A,Qm,k)
% if k is not provided, then use the default value 1.4
function qlamda = Qm2qlamda(Pt,Tt,A,Qm,k)
if nargin<5
k=1.4;
end
R=287.06;
K=sqrt(k/R*(2/(k 1))^((k 1)/(k-1)));
qlamda=Qm/(K*Pt/sqrt(Tt)*A);
11. 已知静温和马赫数计算总温
TsMa2Tt.m
% TsMa2Tt
% function Tt = TsMa2Tt(Ts,Ma,k)
% if k is not provided, then use the default value 1.4
function Tt = TsMa2Tt(Ts,Ma,k)
if nargin<3
k=1.4;
end
Tt=Ts*(1 (k-1)/2*Ma*Ma);
12. 已知总温和马赫数计算静温
TtMa2Ts.m
% TtMa2Ts
% function Ts = TtMa2Ts(Tt,Ma,k)
% if k is not provided, then use the default value 1.4
function Ts = TtMa2Ts(Tt,Ma,k)
if nargin<3
k=1.4;
end
Ts=Tt/(1 (k-1)/2*Ma*Ma);
13. 已知总温和静温计算速度系数
TtTs2lamda.m
% TtTs2lamda
% function lamda = TtTs2lamda(Tt,Ts,k)
% if k is not provided, then use the default value 1.4
function lamda = TtTs2lamda(Tt,Ts,k)
if nargin<3
k=1.4;
end
lamda=sqrt((1-Ts/Tt)*(k 1)/(k-1));
14. 已知总温和静温计算马赫数
TtTs2Ma.m
% TtTs2Ma
% function Ma = TtTs2Ma(Tt,Ts,k)
% if k is not provided, then use the default value 1.4
function Ma = TtTs2Ma(Tt,Ts,k)
if nargin<3
k=1.4;
end
Ma=sqrt((Tt/Ts-1)*(2/(k-1)));
15. 已知总静温比计算总静压比
TtTs2PtPs.m
% TtTs2PtPs
% function PtPs = TtTs2PtPs(TtTs,k)
% if k is not provided, then use the default value 1.4
function PtPs = TtTs2PtPs(TtTs,k)
if nargin<2
k=1.4;
end
PtPs=TtTs^(k/(k-1));
16. 已知总静温比计算总静密度比
TtTs2RhotRhos.m
% TtTs2RhotRhos
% function RhotRhos = TtTs2RhotRhos(TtTs,k)
% if k is not provided, then use the default value 1.4
function RhotRhos = TtTs2RhotRhos(TtTs,k)
if nargin<2
k=1.4;
end
RhotRhos=TtTs^(1/(k-1));
声明:原创文章,欢迎留言与我讨论,如需转载留言