91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4KB
    文件類型: .zip
    金幣: 2
    下載: 3 次
    發(fā)布日期: 2021-06-18
  • 語(yǔ)言: Matlab
  • 標(biāo)簽: 1D??2D??Matlab??Diffusion??Mo??

資源簡(jiǎn)介

該程序采用有限差分方法(隱式和顯式)仿真了一維和二維域擴(kuò)散方程。該程序采用有限差分方法(隱式和顯式)仿真了一維和二維域擴(kuò)散方程。該程序采用有限差分方法(隱式和顯式)仿真了一維和二維域擴(kuò)散方程。

資源截圖

代碼片段和文件信息

%?Simulating?the?1-D?Diffusion?equation?(Fourier‘s?equation)?by?the
...Finite?Difference?Method(a?time?march)
%?Numerical?scheme?used?is?a?first?order?upwind?in?time?and?a?second?order
...central?difference?in?space?(both?Implicit?and?Explicit)

%%
%Specifying?Parameters
nx=50;???????????????%Number?of?steps?in?space(x)
nt=30;???????????????%Number?of?time?steps?
dt=0.1;??????????????%Width?of?each?time?step
dx=2/(nx-1);?????????%Width?of?space?step
x=0:dx:2;????????????%Range?of?x?(02)?and?specifying?the?grid?points
u=zeros(nx1);???????%Preallocating?u
un=zeros(nx1);??????%Preallocating?un
vis=0.01;????????????%Diffusion?coefficient/viscosity
beta=vis*dt/(dx*dx);?%Stability?criterion?(0<=beta<=0.5?for?explicit)
UL=1;????????????????%Left?Dirichlet?B.C
UR=1;????????????????%Right?Dirichlet?B.C
UnL=1;???????????????%Left?Neumann?B.C?(du/dn=UnL)?
UnR=1;???????????????%Right?Neumann?B.C?(du/dn=UnR)?

%%
%Initial?Conditions:?A?square?wave
for?i=1:nx
????if?((0.75<=x(i))&&(x(i)<=1.25))
????????u(i)=2;
????else
????????u(i)=1;
????end
end

%%
%B.C?vector
bc=zeros(nx-21);
bc(1)=vis*dt*UL/dx^2;?bc(nx-2)=vis*dt*UR/dx^2;??%Dirichlet?B.Cs
%bc(1)=-UnL*vis*dt/dx;?bc(nx-2)=UnR*vis*dt/dx;??%Neumann?B.Cs
%Calculating?the?coefficient?matrix?for?the?implicit?scheme
E=sparse(2:nx-21:nx-31nx-2nx-2);
A=E+E‘-2*speye(nx-2);????????%Dirichlet?B.Cs
%A(11)=-1;?A(nx-2nx-2)=-1;?%Neumann?B.Cs
D=speye(nx-2)-(vis*dt/dx^2)*A;

%%
%Calculating?the?velocity?profile?for?each?time?step
i=2:nx-1;
for?it=0:nt
????un=u;
????disp(u)
????h=plot(xu);???????%plotting?the?velocity?profile
??
????axis([0?2?0?3])
????title({[‘1-D?Diffusion?with?\nu?=‘num2str(vis)‘?and?\beta?=?‘num2str(beta)];[‘time(\itt)?=?‘num2str(dt*it)]})
????xlabel(‘Spatial?co-ordinate?(x)?\rightarrow‘)
????ylabel(‘Transport?property?profile?(u)?\rightarrow‘)
????drawnow;?
????refreshdata(h)
????%Uncomment?as?necessary
????%-------------------
????%Implicit?solution
????
????U=un;U(1)=[];U(end)=[];
????U=U+bc;
????U=D\U;
????u=[UL;U;UR];??????????????????????%Dirichlet
????%u=[U(1)-UnL*dx;U;U(end)+UnR*dx];?%Neumann
????%}
????%-------------------
????%Explicit?method?with?F.D?in?time?and?C.D?in?space
????%{
????u(i)=un(i)+(vis*dt*(un(i+1)-2*un(i)+un(i-1))/(dx*dx));
????%}
end

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????2327??2018-10-10?11:06??Diffusion\Diffusion_1D.m
?????文件????????3827??2018-10-10?11:44??Diffusion\Diffusion_2D.m
?????文件????????1110??2018-08-24?10:47??Diffusion\Intro.txt
?????文件????????1334??2018-08-24?10:45??Diffusion\license.txt

評(píng)論

共有 條評(píng)論