15
AEM 620 - Computational Fluid Dynamics Instructor: Dr. M. A. R. Sharif ASSIGNMENT: 05 ONE DIMENSIONAL BURGER’S EQUATION: FOR IRROTATIONAL INCOMPRESSIBLE FLOW by Parshant Dhand October 18, 2000

Homework 05

Embed Size (px)

Citation preview

Page 1: Homework 05

AEM 620 - Computational Fluid Dynamics Instructor: Dr. M. A. R. Sharif

ASSIGNMENT: 05 ONE DIMENSIONAL BURGER’S EQUATION:

FOR IRROTATIONAL INCOMPRESSIBLE FLOW

by Parshant Dhand October 18, 2000

Page 2: Homework 05

ABSTRACT:

In this paper the scalar navier stokes equation or so called famous Burger’s equation in one dimension is analyzed and solved numerically by three approaches which are FTCS explicit scheme, MacCormack explicit scheme and BTCS implicit scheme. The equation in itself is important to understand the concept of fluid low with constant pressures and irrotaional flows. Results for various cases analyzed are shown in the form of plots. Errors are calculated in comparison to the exact solution, for all the three methods. Numerical results show that the BTCS Implicit method seems more accurate over the others for the cases discussed. INTRODUCTION:

The Burger’s equation is the special form of the momentum equation for irrotational, incompressible flows in which pressure gradients are neglected. Dimensional form: Here a is the speed of sound.

2

2

xu

xu

atu

∂∂

=∂∂

+∂∂

ν -1

Non dimensional form: This is the non dimensional form of the equation used in the analysis here.

2

2

xu

xE

tu

∂∂

=∂∂

+∂∂

ν -2

where 2

21

uE = -3

These equations are of mixed type, means may be hyperbolic,

parabolic, and elliptic. Is steady state is considered then they become mixed hyperbolic and elliptic equation. Because of these properties various solution schemes have been suggested to solve these equations. MATHEMATICAL FORMULATION: Following is the problem solved here and the mathematical formulat ion is also shown. PROBLEM:

Page 3: Homework 05

Non dimensional Burger’s equation is considered and solved for the values of velocity. Given below are the equations, methods, initial and boundary conditions and cases analyzed. INITIAL AND BOUNDARY CONDITIONS:

Initial Distribution is given by the following equation.

TeXX

U−−

−=)cosh(

)sinh(2 -4

At T = 0.1 And X varies from -2.0 – 2.0 Boundary Conditions:

At X = - 9.0 U = 2.0 At X = 9.0 U = -2.0

Step Size: Dx = 0.2 and Dt = 0.01 CASES ANALYSED:

Four main cases are analyzed and discussed here. These are for four different times. i.e.

T = 0.1 T = 0.4 T = 0.7 T = 1.0

METHODS:

1. FTCS EXPLICIT METHOD:

When an explicit scheme is used, the non linear term is evaluated at the known time step and hence there is no need of linearization. However for an implicit method the linearization term is required and solved sometimes using the Jcobian Matrix. The formulation for the FTCS explicit method is give as below.

Page 4: Homework 05

2

11

111

11

11

1

)(2

2 dxuuu

dxuu

Adt

uu ni

ni

ni

ni

nin

i

ni

ni

+−

+++

+−

++

+ +−=

−+

− -5

In this equation the term niA is just taken as the value of U at the

previous time step. To start the solution initial condition is specified as described earlier.

2. MACCORMACK EXPLICIT METHOD: This is the corrector predictor method. Equation 6 and 7 represent the predictor part and the equation 8 represent the corrector part.

)2()(

)( 1121ni

ni

ni

ni

ni

ni uuu

dxdt

EEdxdt

u −++ +−+−−=∆ -6

ni

nii uuu ∆+=* -7

)(21 **1

inii

ni uuuu ∆++=+ -8

3. BTCS IMPLICIT METHOD:

In Implicit method the solution can be obtained using lagging of the Jacobian matrix for the linearization. Howev er for this case as shown in the equation, the jacobian has been replaced by the value of velocity at the previous time step and the resulting finite difference equation becomes,

2

11

111

11

11

1

)(2

2 dxuuu

dxuu

Adt

uu ni

ni

ni

ni

nin

i

ni

ni

+−

+++

+−

++

+ +−=

−+

− -9

Which can be rearranged as follows:

ni

ni

ni

ni

ni

ni uu

dxdt

Adxdt

udxdt

udxdt

Adxdt

=

+−+

++

+− +

+++

−1

121

21

12 2)()(21

2)( -10

and now it can be solved using the tridiagonal method for the value of u at new time step.

Page 5: Homework 05

ERROR:

Errors for various methods are calculated by just subtracting the values of velocities for different methods from the exact solution and the plots are shown in results and discussion section. RESULTS AND DISCUSSION:

The results are shown in the plots for various times for all the three methods. Plot 1 shows the comparison of all the methods for time = 0.4 sec. It seems that all the methods behave almost similarly and deviate from the exact solution from -2>x>2. Plot 2 shows the FTCS Explicit method for all the times i.e. T=0.1, 0.4, 0.7, 1.0. Similarly plot 3 and plot 4 shows the BTCS implicit method and MacCormack method for all the times. Then the plot for the error calculates by subtracting the values for exact solution from the different methods for each time. It seems that the BTCS Implicit method is giving more accurate results for time 0.7 and 1.0. However at the time 0.1 all methods behave in a similar manner and deviate a lot for x lies between -0.5 – 0.5. At time 0.4 MacCormack methods seems to be more accurate. Study of varying time steps is also done. Besides the Dx is also be varied and studied. In order plots appear they are numbered as 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and11.

Page 6: Homework 05

BTCS IMPLICIT METHOD FOR DT=0.01 AND DX = 0.2

-5

-4

-3

-2

-1

0

1

2

3

4

5

-9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0

LENGTH(X)

VE

LOC

ITY

T=0.1

T=0.4T=0.7T=1.0

FTCS EXPLICIT METHOD FOR DX=0.2 DT=0.01

-5

-4

-3

-2

-1

0

1

2

3

4

5

-9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0

LENGTH(X)

VE

LOC

ITY

T=0.1

T=0.4T=0.7

T=1.0

Page 7: Homework 05

MACCORMACK METHOD FOR DT=0.01 DX=0.2

-5

-4

-3

-2

-1

0

1

2

3

4

5

-9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0

LENGTH(X)

VE

LOC

ITY T=0.1

T=0.4T=0.7

T=1.0

ERROR PLOT TIME = 0.1

-1

-0.5

0

0.5

1

1.5

2

2.5

3

3.5

4

-8.2 -7.2 -6.2 -5.2 -4.2 -3.2 -2.2 -1.2 -0.2 0.8 1.8 2.8 3.8 4.8 5.8 6.8 7.8

LENGTH(X)

ER

RO

R FTCSBTCSMACCO

Page 8: Homework 05

ERROR PLOT TIME = 0.4

-1.5

-1

-0.5

0

0.5

1

1.5

2

-9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0

LENGTH(X)

ER

RO

R FTCSBTCSMACCO

ERROR PLOT TIME = 0.7

-4

-3

-2

-1

0

1

2

3

4

5

-9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0

LENGTH(X)

ER

RO

R FTCSBTCSMACCO

Page 9: Homework 05

ERROR PLOT TIME = 1.0

-2

-1.5

-1

-0.5

0

0.5

1

1.5

-9 -8.4

-7.8 -7.2

-6.6 -6 -5.4 -4.

8-4.

2-3.6 -3 -2.

4-1.8 -1.

2-0.

6

-3.02E

-140.6 1.2 1.8 2.4 3 3.6 4.2 4.8 5.4 6 6.6 7.2 7.8 8.4

LENGTH()

ER

RO

R FTCSBTCSMACCO

EXACT, FTCS, MACC AND BTCS PLOTTED TOGETHER FOR T=0.4

-4

-3

-2

-1

0

1

2

3

4

-9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0

LENGTH(X)

VE

LO

CIT

Y EXACT

FTCSBTCS

MACC

Page 10: Homework 05

FTCS EXPLICIT METHOD FOR DT=0.2 AND DX=0.5

-3

-2

-1

0

1

2

3

1 4 7 10 13 16 19 22 25 28 31 34 37

LENGTH(X)

VE

LO

CIT

Y

t=0.4t=0.7t=1.0

MACCORMACK METHOD FOR DT = 0.02 AND DX=0.5

-3

-2

-1

0

1

2

3

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

LENGTH(X)

VE

LO

CIT

Y

T=0.4T=0.7T=1.0

Page 11: Homework 05

BTCS IMPLICIT METHOD FOR DT=0.02 AND DX = 0.5

-3

-2

-1

0

1

2

3

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

LENGTH(X)

VE

LO

CIT

Y

T=0.4T=0.7T=1.0

CONCLUSIONS:

It can be concluded based on these results that the BTCS implicit method is more accurate for time 0.7 sec and MacCormack is better for time 0.4. However all the methods behave in a similar manner for the value of x from -2.0 – 2.0 and deviate a lot. REFERENCES:

1. Chung T. J., January 15, 2002, “Computational Fluid Dynamics”, Cambridge University Press; ISBN: 0521594162; 1st edition, pp 63-67.

2. Hoffmann K., June 1989, “Computational Fluid Dynamics for Engineers”, Engineering Education System, Kansas ASIN: 0962373141.

3. Karr C.L., 2000, “Partial Differential Equations for Engineers” Library of Congress, BCD technologies Tuscaloosa.

APPENDIX:

Page 12: Homework 05

COMPUTER PROGRAMS IN FORTRAN FOR THREE METHODS:

1. FTCS EXPLICIT METHOD: !__ HOMEWORK 5 ONE DIMENSIONAL BURGER'S EQUATION. !__ FTCS EXPLICIT SCHEME PROGRAM FTCS DIMENSION UOLD(100),UNEW(100) REAL:: DX,DT,TMAX,T,XMAX,XMIN DX = 0.20 DT = 0.02 TMAX = 1.00 XMIN =-9.00 XMAX = 9.00 T = 0.10 !__ BOUNDARY AND INITIAL CONDITIONS. X = XMIN DO I = 1,91 X=X+DX UOLD(I)=( -2.0*SINH(X))/(COSH(X)-EXP(-T)) END DO WRITE(*,*)UOLD,X,XMAX,XMIN,DX,DT,T PAUSE !__ MAIN LOOP TO CALCULATE VELOCITY T = 0.1 DO WHILE (T.LE.TMAX) T = T+DT UOLD(1) = 2.0 UOLD(91)=-2.0 DO I=2,90 UNEW(I) =UOLD(I) + (DT/DX**2)*(UOLD(I+1)-2.0*UOLD(I)+UOLD(I-1)) - (DT*UOLD(I)/2*DX)*(UOLD(I+1)-UOLD(I-1)) UOLD(I)=UNEW(I) END DO WRITE (1,10) (UOLD(I),I=1,91) 10 FORMAT (91F10.4) END DO END PROGRAM

2. MACCORMACK EXPLICIT METHOD:

Page 13: Homework 05

!__ HOMEWORK 5 ONE DIMENSIONAL BURGER'S EQUATION. !__ MACCORMACK EXPLICIT SCHEME PROGRAM MAC DIMENSION UOLD(100),UNEW(100),UP(100) REAL:: DX,DT,TMAX,T,XMAX,XMIN DX = 0.20 DT = 0.01 TMAX = 1.00 XMIN =-9.00 XMAX = 9.00 T = 0.10 !__ BOUNDARY AND INITIAL CONDITIONS. X = XMIN DO I = 1,91 X=X+DX UOLD(I)=( -2.0*SINH(X))/(COSH(X)-EXP(-T)) END DO !__ MAIN LOOP TO CALCULATE VELOCITY T=0.1 DO WHILE (T.LT.TMAX) T= T + DT UOLD(1) = 2.0 UOLD(91)=-2.0 DO I=2,90 UP(I)= (-DT/DX)*(UOLD(I)-UOLD(I-1)) + (DT/DX**2)*(UOLD(I+1)-2*UOLD(I)+UOLD(I-1)) END DO DO I = 2,90 UNEW(I) = 1/2.0*(2*UOLD(I)+2*UP(I)) END DO DO I = 2,90 UOLD(I)=UNEW(I) END DO WRITE (1,10) (UOLD(I),I=1,91) END DO 10 FORMAT (91F10.4) END PROGRAM

Page 14: Homework 05

3. BTCS IMPLICIT METHOD: !__ HOMEWORK 5 ONE DIMENSIONAL BURGER'S EQUATION. !__ BTCS IMPLICIT SCHEME PROGRAM BTCSIMP DIMENSION UOLD(400),A(400),B(400),C(400),D(400) REAL:: DX,DT,TMAX,T,XMAX,XMIN DX = 0.20 DT = 0.01 TMAX = 1.00 XMIN =-9.00 XMAX = 9.00 T = 0.10 !__ BOUNDARY AND INITIAL CONDITIONS. X = XMIN DO I = 1,91 X=X+DX UOLD(I)=( -2.0*SINH(X))/(COSH(X)-EXP(-T)) END DO UOLD(1) = 2.0 UOLD(91)=-2.0 !__ MAIN LOOP TO CALCULATE VELOCITY T = 0.1 DO WHILE (T.LE.TMAX) T = T+DT DO I=1,91 A(I) = -DT/DX**2 -UOLD(I)*(DT/2.0*DX) B(I) = 1+(2.0*DT)/DX**2 C(I) = -DT/DX**2 +UOLD(I)*(DT/2*DX) END DO DO I = 2, 90 D(I) = UOLD(I) END DO CALL TRDIAG (A,B,C,UOLD,D) WRITE (1,10) (UOLD(I),I=1,91) 10 FORMAT (91F10.4) END DO END PROGRAM

Page 15: Homework 05

! SUBROUTINE TRIDIAGONAL SUBROUTINE TRDIAG (A,B,C,UOLD,D) DIMENSION UOLD(400),G(400),H(400),A(400),B(400),C(400),D(400) NX=91 H(1)=0.0 G(1)=2.0 DO I=2,NX-1 H(I) = C(I)/(B(I)-A(I)*H(I-1)) G(I) = (D(I)-A(I)*G(I-1))/(B(I)-A(I)*H(I-1)) END DO DO I=NX-1,2,-1 UOLD(I) = -(H(I)*UOLD(I+1))+G(I) END DO RETURN END