诸位大神,下面是我编的一段计算一维流场的程序。不知道什么原因计算结果不收敛,显示[NaN + NaNi;NaN + NaNi;NaN + NaNi],我排查了好久都没有发现问题。看到论坛里藏龙卧虎,希望有大神可以帮忙订正一下。本人MATLAB小白,希望各位大神批评指正,万分感谢。
主函数
%%This is main program 1 for CFD assignment
%% Section used to give entrance boundary condition, etc
Min=1.5; Pin=47892.40; Dstin=1.2218; %% entrance boundary condition
X0=0; X1=10;
paceX=0.1;
A=@(x)(1.398+0.347*tanh(0.8*x-4)); %% expression of Area
alpha=0.18; %% artificial viscosity coefficient
gamma=1.4;
MpathT=10000; %% Max time steps
acousV=@(P,Dst)((gamma*P/Dst)^(1/2)); %%expression of acoustic velocity
acousV_in=acousV(Pin,Dstin); Uin=acousV_in*Min; %%calculate entrance velocity
paceT=@(U,acousV)(0.9*(paceX/(U+acousV)));
%% Section used to give initia