资源描述:
《相变传热与流体流动数值分析作业》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、相变传热与流体流动数值分析作业3相变传热与流体流动数值分析作业3学院(系):能源与动力学院专业:能源与动力工程学生姓名:王佳琪学号:21110060指导教师:宋永臣教授完成日期:大连理工大学DalianUniversityofTechnologyTheFiniteVolumeMethodforConvection-DiffusionProblemsSubject:ApropertyΦistransportedbymeansofconvectionanddiffusionthroughtheone-dimensionaldomainsketchedinFigure1.Thegove
2、rningequationisρuΦ=dxdddx(ΓdΦdx;boundaryconditionsareΦ0=1atx=0andΦL=0atx=L.UsingfiveequallyspacedcellsforconvectionanddiffusioncalculatethedistributionofΦafunctionofxforcase:(i)(ii)Case1:u=0.1m/s;Case2:u=2.5m/s;(iii)Case3:u=2.5m/swith20gridnodes;Thefollowingdataapply:LengthL=1.0m,ρ=1.0kg/m3,Γ
3、=0.1kg/m/s.Φ=1Φ=0Solution:(I)Thecentraldifferencingscheme://王佳琪-作业-中心差分.cpp:定义控制台应用程序的入口点。//#include<stdafx.h>#include<iostream>#include<math.h>#include<stdlib.h>#include<cstdlib>#include<iomanip>#include<fstream>#include<sstream>#include<str
4、ing>#defineN5usingnamespacestd;inti;doubleaw[N],b[N],ae[N],f[N],x[N];/*-------追赶法求解数组-------*/voidtdma(){doublel[N],u[N],y[N];for(i=1;i<N;i++){u[0]=b[0];l[0]=0;l[i]=aw[i]/u[i-1];u[i]=b[i]-l[i]*ae[i-1];}y[0]=f[0];for(i=1;i<N;i++)y[i]=f[i]-l[i]*y[i-1];x[N-1]=y[N-1]/u[N-1];for(i=N-2;i&g
5、t;=0;i--)x[i]=(y[i]-ae[i]*x[i+1])/u[i];}voidmain(){voidOutput();/*---------定义变量及边界条件---------*/doubleF,D,u,ρ,Γ,x,L,φA,φB,Sp[N];u=0.1;ρ=1;Γ=0.1;L=1;φA=1;φB=0;x=L/N;F=ρ*u;D=Γ/x;/*---------网格离散---------*/for(i=0;i<N;i++){if(i==0){aw[i]=0;ae[i]=-(D-F/2);Sp[i]=-(2*D+F);f[i]=(2*D+F)*φA;}elseif(i
6、==N-1){ae[i]=0;aw[i]=-(D+F/2);Sp[i]=-(2*D-F);f[i]=(2*D-F)*φB;}else{aw[i]=-(D+F/2);ae[i]=-(D-F/2);Sp[i]=0;f[i]=0;}b[i]=-aw[i]-ae[i]-Sp[i];}tdma();Output();}voidOutput(){/*---------后处理文件生成---------*/ostringstreamname;name.str("");name<<"central_.plt";ofstreamout(name.str().c_str());out<
7、;<"Title=central"<<endl<<"VARIABLES=X,Y1,Y2"<<"ZONEI="<<N<<",J="<<1<<",F=POINT"<<endl;for(i=0;i<N;i++){out<<double(0.2*i+0.1)<<""<<x[i]<<""<<(2.7183-exp(0.2