一维对流扩散问题求解

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Subjects :

A property φ is transported by means of convection and diffusion through the one-dimensional domain. The governing equation is ()()d d d u dx dx dx φρφ=Γ; boundary conditions are 01φ= at x=0 and 0L φ= at x =L. Using five equally spaced cells and the central differencing scheme for convection and diffusion calculate the distribution of φas a function of x for

(i)Case 1: u=0.1 m/s,

(ii) Case2: Case 1: u=2.5 m/s, and compare the results with the analytical solution 00exp(/)1exp(/)1L ux uL φφρφφρ-Γ-=-Γ-.

(iii)Case 3: recalculate the solution for u=2.5m/s with 20 grid nodes and compare the results with the analytical solution, the following date apply: length L=1.0 m,31.0/,//kg m kg m s ρ=Γ=.

ϕ=1

x=0ϕ=0x=L u

Solution:

Programming language:

File name:二维稳态导热模拟.cpp

Compile software: Microsoft Visual C++ 6.0

Code:

#include

#include

#include

using namespace std;

#define Gn1 5 //网格节点数.

#define Gn2 20 //网格节点数.

#define P 1 //流体密度,单位:kg/m/m/m.

#define ProA 1 //A端传递特性.

#define ProB 0 //B端传递特性.

//////FDD///////追赶法过程

void TDMA1(double a[],double b[], double c[] ,double f[],double *p) { //矩阵形式

//b0 c0 0 0 //=f0

//a0 b1 c1 0 //=f1

//... ... ... ... ...

//0 0 ... b(N-1) c(N-2) //=f(N-1)

double d[Gn1-1],u[Gn1],ll[Gn1-1], y[Gn1],X[Gn1];

int i;

for(i=0; i<=Gn1-2;i++)

{

d[i] = c[i];

}

u[0] = b[0];

for(i=1; i<=Gn1-1;i++)

{

ll[i-1]=a[i-1]/u[i-1];

u[i]=b[i]-ll[i-1]*c[i-1];

}

y[0]=f[0];

for(i=1; i<=Gn1-1;i++)

{

y[i]=f[i]-ll[i-1]*y[i-1];

}

X[Gn1-1]=y[Gn1-1]/u[Gn1-1];

for (i=Gn1-2; i>=0;i--)

{

X[i]=(y[i]-c[i]*X[i+1])/u[i];

}

for (i=0; i<=Gn1-1;i++)

*(p+i)=X[i];

}

void TDMA2(double a[],double b[], double c[] ,double f[],double *p) {

double d[Gn2-1],u[Gn2],ll[Gn2-1], y[Gn2],X[Gn2];

int i;

for(i=0;i<=Gn2-2;i++)

{

d[i]=c[i];

}

u[0] = b[0];

for(i=1;i<=Gn2-1;i++)

{

ll[i-1]=a[i-1]/u[i-1];

u[i]=b[i]-ll[i-1]*c[i-1];

}

y[0] = f[0];

for(i=1;i<=Gn2-1;i++)

{

y[i]=f[i]-ll[i-1]*y[i-1];

}

X[Gn2-1]=y[Gn2-1]/u[Gn2-1];

for (i=Gn2-2;i>=0;i--)

{

X[i]=(y[i]-c[i]*X[i+1])/u[i];

}

for (i=0;i<=Gn2-1;i++)

*(p+i)=X[i];

}

void main()

{

double u,L=1,T=0.1,min_x,F,D,aW,aE,m,n;

double a[Gn2],b[Gn2],c[Gn2],f[Gn2],X[Gn2];

int serial_number1, serial_number2,i;

printf("There are four methods to solve these cases:\n");

printf("1.The central differencing scheme.\n");

printf("2.The upwind differencing scheme.\n");

printf("3.The hybrid differencing scheme.\n");

printf("4.The power-law scheme.\n");

相关文档
最新文档