Aliakbar Kabir CFD Project

Embed Size (px)

Citation preview

Term Project

Computational Fluid DynamicsProf. S.SaidiSharif University of Technology International Campus Kish Island

Students name: Aliakbar kabir Students ID.: 89250861

Winter 2012

1.

Definitions

First step of solving the problem is to describe the definitions of the problem requirement, to have better understanding of the problem. 1.1. Staggered Grid

The solution procedure for the transport of a general property developed in without presenting pressure will of course be enlisted to solve the momentum equations. Matters are, however, not completely straightforward since there are problems associated with the pressure source terms of the momentum equations that need special treatment. The finite volume method starts, as always, with the discretization of the flow domain and of the relevant transport equations. First we need to decide where to store the velocities. It seems logical to define these at the same locations as the scalar variables such as pressure, temperature etc. However, if the velocities and pressures are both defined at the nodes of an ordinary control volume a highly non-uniform pressure field can act like a uniform field in the discretized momentum equations. This can be demonstrated with the simple two-dimensional situation shown in Figure 1.1, where a uniform grid is used for simplicity.

Fig. 1.1 A 'checker-board' pressure fiel

Let us assume that we have somehow obtained a highly irregular 'checkerboard' pressure field with values as shown in Figure 1.1.1|Page

If the pressures at 'e' and 'w' are obtained by linear interpolation the pressure gradient term dp/dx in the u-momentum equation is given by

1.1.1

Similarly, the pressure gradient dp/dy for the v-momentum equation is evaluated as:

1.1.2

The pressure at the central node (P) does not appear in (1.1.1) and (1.1.2). Substituting the appropriate values from the 'checker-board' pressure field in Figure 1.1 into formulae (1.1.1-1.1.2) we find that all the discretized gradients are zero at all the nodal points even though the pressure field exhibits spatial oscillations in both directions. As a result, this pressure field would give the same (zero) momentum source in the discretized equations as a uniform pressure field. This behavior is obviously nonphysical. It is clear that, if the velocities are defined at the scalar grid nodes, the influence of pressure is not properly represented in the discretized momentum equations. A remedy for this problem is to use a staggered grid for the velocity components (Harlow and Welch, 1965). The idea is to evaluate scalar variables, such as pressure, density, temperature etc., at ordinary nodal points but to calculate velocity components on staggered grids centered on the cell faces. The arrangement for a two-dimensional flow calculation is shown in Figure 1.2.

2|Page

The scalar variables, including pressure, are stored at the nodes marked (). The velocities are defined at the (scalar) cell faces in between the nodes and are indicated by arrows. Horizontal ( ) arrows indicate the locations for uvelocities and vertical ( ) ones denote those for v-velocities. In addition to the E,W, N,S notation Figure 1.2 also introduces a new system of notation based on a numbering of grid lines and cell faces. For the moment we continue to use the original E, W, N, S notation the uvelocities are stored at scalar cell faces e and w and the v-velocities at faces 'n' and 's'.

Fig. 1.2

We observe that the control volumes for u and v are different from the scalar control volumes and different from each other. The scalar control volumes are sometimes referred to as the pressure control volumes because, as we shall see later, the discretized continuity equation is turned into a pressure correction equation, which is evaluated on scalar control volumes.3|Page

In the staggered grid arrangement, the pressure nodes coincide with the cell faces of the u-control volume. The pressure gradient term dp/dx is given by

1.1.3

Where , is the width of the u-control volume. Similarly dp/dy for the v-control volume shown is given by

1.1.4

where

, is width of the v-control volume.

If we consider the 'checker-board' pressure field again, substitution of the appropriate nodal pressure values into equations (1.1.3) and (1.1.4) now yields very significant non-zero pressure gradient terms. The staggering of the velocity avoids the unrealistic behavior of the discretized momentum equation for spatially oscillating pressures like the 'checker-board' field. A further advantage of the staggered grid arrangement is that it generates velocities at exactly the locations where they are required for the scalar transport convection diffusion - computations. Hence, no interpolation is needed to calculate velocities at the scalar cell faces. 1.2. SIMPLE Family Algorithm

The acronym SIMPLE stands for Semi-Implicit Method for PressureLinked Equations. The algorithm was originally put forward by Patankar and Spalding (1972) and is essentially a guess-and-correct procedure for the calculation of pressure on the staggered grid arrangement introduced above. The method is illustrated by considering the two-dimensional laminar steady flow equations in Cartesian co-ordinates. The SIMPLE algorithm gives a method of calculating pressure and velocities. The method is iterative and when other scalars are coupled to the momentum equations, the calculation needs to be done sequentially.4|Page

1.3.

SIMPLER

The SIMPLER (SIMPLE Revised) algorithm of Patankar (1980) is an improved version of SIMPLE. In this algorithm the discretized continuity equation:

1.3.1

is used to derive a discretized equation for pressure, instead of a pressure correction equation as in SIMPLE. Thus the intermediate pressure field is obtained directly without the use of a correction. Velocities are, however, still obtained through the velocity corrections of SIMPLE.

1.3.2

1.3.3

1.3.4 1.3.5

1.3.6

The discretized momentum equations are re-arranged as:

5|Page

1.3.7

1.3.8

In the SIMPLER algorithm pseudo-velocities and are now defined as follows:

1.3.9

1.3.10

Equations (1.3.7) and (1.3.8) can now be written as:1.3.11 1.3.12

The definition for d, introduced in (1.3.6), is applied in (1.3.11-1.3.12). Substituting for and , from these equations into the discretized continuity equation (1.3.1), using similar forms for and results in:

1.3.13

Equation (1.3.13) may be re-arranged to give a discretized pressure equation:6|Page

1.3.14

Note that the coefficients of equation (1.3.14) are the same as those in the discretized pressure correction equation, with the difference that the source term b is evaluated using the pseudo-velocities. Subsequently, the discretized momentum equations:

are solved using the pressure field obtained above. This yields the velocity components u* and v*. The velocity correction equations (1.3.2-1.3.5) are used in the SIMPLER algorithm to obtain corrected velocities. Therefore, the p'-equation

must also be solved to obtain the pressure corrections needed for the velocity corrections. The full sequence of operations is described in Figure 1.3.1.

7|Page

Fig 1.3.1

8|Page

2.

Assessment of the hybrid differencing scheme

The hybrid difference scheme exploits the favorable properties of the upwind and central differencing schemes. It switches to the upwind differencing when the central differencing produces inaccurate results at high Pe numbers. The scheme is fully conservative and since the coefficients are always positive it is unconditionally bounded. It satisfies the transportiveness requirement by using an upwind formulation for large values of Peclet number. The scheme produces physically realistic solutions and is highly stable when compared with the higher order schemes. Hybrid differencing has been widely used in various computational fluid dynamics (CFD) procedures and has proved to be very useful for predicting practical flows. The disadvantage is that the accuracy in terms of Taylor series truncation error is only firstorder.

2.1. diffusion

Hybrid differencing scheme for multi-dimensional convection-

The hybrid differencing scheme can easily be extended to two- and three dimensional problems by repeated application of the derivation in each new coordinate direction. The discretized equation that covers all cases is given by:

with central coefficient

and the coefficients of this equation for the hybrid differencing scheme are as follows:

9|Page

In the above expressions the values of F and D are calculated with the following formulae:

10 | P a g e

3. Results Part B: Cavity Problem

o Grid of cavity problem

11 | P a g e

o Residual-Iteration Plot

12 | P a g e

o Velocity and Pressure Contour

Pressure contour

U-component

13 | P a g e

V-component

Velocity contour with u-v Vectors

14 | P a g e

U-component with Stream lines Part C: Channel Problem o Pressure Grid

15 | P a g e

o Residual-Iteration Plots

16 | P a g e

o Velocity and Pressure Contour

Pressure Contour

17 | P a g e

U-Component

V-Component

18 | P a g e

o Velocity Profiles along the Symmetry Line at Different Levels

19 | P a g e

o Pressure Drop

Pressure Drop along X-axis

20 | P a g e

4.

Code 4.1. Main code

// Kabir.cpp : Defines the entry point for the console application. // #include #include #include #include #include #include "stdafx.h" "Mesh.h" "discrete_func.h" "assemblage.h" "Solver.h" "Results.h" mesh u_mesh,v_mesh,p_mesh,mesh; FILE *pp; int Nx,Ny,i,j=0,k,n_repeat,n_p,n_v,n_run,project; double *p_prine; double *u_prine; double *v_prine; double L,H,Rx,Ry,U0,u,v,rho,vis,eror_u,eror_v,eror_p,alfa_p,alfa_u,max_u_pr=1,max_v_pr=1,b_prin1=1,ma x_b_pr,r_b,u_prin1=1,v_prin1=1; int _tmain(int argc, _TCHAR* argv[]) { pp=fopen("E:\Residuals.dat","wb"); if (pp==NULL) { printf("Cannot open file.\n"); exit(1); } project=2; if (project==1) { L=1; H=1; Nx=30; Ny=30; n_run=0; Rx=1; Ry=1; rho=23; vis=1; U0=1; n_p=5; n_v=20; n_repeat=50000; alfa_p=.3; alfa_u=.6; } else if(project==2) { L=5; H=1; Nx=60; Ny=15; n_run=0; Rx=1; Ry=1; rho=1; vis=.01; U0=1.8; n_p=30; n_v=6; n_repeat=12000; alfa_p=.5; alfa_u=1; } p_mesh=p_mesh.mesh_generate(L,H,Rx,Ry,Nx,Ny);

21 | P a g e

v_mesh=v_mesh.v_mesh_generate(p_mesh,Nx,Ny); u_mesh=v_mesh.u_mesh_generate(p_mesh,Nx,Ny); p_prine=new double[p_mesh.n_cv]; v_prine=new double[p_mesh.n_cv]; u_prine=new double[p_mesh.n_cv]; fprintf(pp,"%s\t%s\t%s\t%s\t%s\t\n","variables=","\"repeat\"","\"continuity\"","\"uvelocity\"","\"v-velocity\""); //initial guess// for (i=0;i