Two-Dimensional Unsteady Flow in a Lid Driven Cavity with Constant Density and Viscosity ME 412 Project 5 Jingwei Zhu May 14, 2014 Instructor: Surya Pratap Vanka 1 Project Description The objective of this project is to develop and apply a computer program to solve the twodimensional unsteady Navier-Stokes equations for an elliptic flow in a square cavity with top wall sliding at a given velocity. We assume that the fluid is incompressible and has constant viscosity. The two-dimensional unsteady Navier-Stokes equations for flow with constant density and viscosity are listed as follows: u x + v y = 0 (1) ρ( u t + u u x + v u y ) = P x + µ( 2 u x 2 + 2 u y 2 ) (2) ρ( v t + u v x + v v y ) = P y + µ( 2 v x 2 + 2 v y 2 ) (3) where u and v are the two Cartesian velocities, x and y are spatial coordinates, t is the time, ρ is the density, P is the static pressure, and µ is the dynamic viscosity. The side length of the square cavity is set to 1 meter and a 42 42 grid is used in the numerical computation. The grid layout is shown in Figure 1. There are ghost nodes located outside the domain of interest. The boundary conditions are that v velocity at all the domain boundaries is zero, while u velocity of the flow near the top wall equals the top wall velocity and it remains zero at other boundaries. Numerical results for different Reynolds numbers of 50, 100 and 200 will be shown. The Reynolds number is based on the side length of the square cavity, top wall velocity and the kinematic viscosity 1
Figure 1: Grid layout of the fluid, as is shown in Equation 4: Re = ρ V L µ (4) where V is the top wall velocity and L is the side length. The time step size t yields to the following stability limit: 1 t u x + v y + (5) 2ν + 2ν x 2 y 2 In our project, a time step of 0.002s is used in all cases which always yields above stability limit given that flow density ρ = 1kg/m 3, dynamic viscosity µ = 0.001kg/m s, x = y = 0.025m. A collocated scheme is used for velocity discretizations and pressure-poisson equations are formulated to avoid checker-board splitting. 2 Differencing Scheme 2.1 Discretization First order time and second order space discretizations are used in this project. An explicit time discretization scheme has been used for both convection and diffusion, and pressure-poisson equations are formulated for determining the pressure field at the new time step. Relevant discretizations are shown as follows: ( u x )n un i+1/2,j un i 1/2,j x (6) 2
( v y )n vn i,j+1/2 un i,j 1/2 y ( u t )n un+1 i,j u n i,j t ( v t )n vn+1 i,j vi,j n t (u u x )n u n u n i+1,j un i 1,j i,j 2 x (v u y )n vi,j n u n i,j+1 un i,j 1 2 y (u v x )n u n vi+1,j n vn i 1,j i,j 2 x (v v y )n vi,j n vi,j+1 n vn i,j 1 2 y ( P x )n P i+1,j n P i 1,j n 2 x ( P y )n P i,j+1 n P i,j 1 n 2 y (7) (8) (9) (10) (11) (12) (13) (14) (15) 2.2 Collocated Fractional Step Algorithm ( 2 u x 2 )n = un i+1,j 2un i,j + un i 1,j x 2 (16) ( 2 u y 2 )n = un i,j+1 2un i,j + un i,j 1 y 2 (17) ( 2 v x 2 )n = vn i+1,j 2vn i,j + vn i 1,j x 2 (18) ( 2 v y 2 )n = vn i,j+1 2vn i,j + vn i,j 1 y 2 (19) A collocated fractional step algorithm is used in the simulation. Main procedures of this algorithm can be shown as follows: Prescribe domain size Prescribe solution and flow parameters 3
Initialize flow variables Start time loop The following steps will be executed inside each time loop: Solve for û, ˆv at each node (i, j) inside the domain ρûi,j u n i,j t = C n x + D n x = = ρ un i,j 2 x (un i+1,j u n i 1,j) ρ vn i,j 2 y (un i,j+1 u n i,j 1) + µ x 2 (un i+1,j 2u n i,j + u n i 1,j) + µ y 2 (un i,j+1 2u n i,j + u n i,j 1) (20) ρ ˆv i,j v n i,j t = C n y + D n y = Evaluate û, ˆv at midpoints = ρ un i,j 2 x (vn i+1,j v n i 1,j) ρ vn i,j 2 y (vn i,j+1 v n i,j 1) + µ x 2 (vn i+1,j 2v n i,j + v n i 1,j) + µ y 2 (vn i,j+1 2v n i,j + v n i,j 1) (21) û i+1/2,j 1 2 (û i,j + û i+1,j ) (22) û i 1/2,j 1 2 (û i,j + û i 1,j ) (23) ˆv i,j+1/2 1 2 (ˆv i,j + û i,j+1 ) (24) ˆv i,j 1/2 1 2 (ˆv i,j + û i,j 1 ) (25) Discrete Pressure-Poisson Equations ρ t U = ρ û i 1/2,j t (ûi+1/2,j x + ˆv i,j+1/2 ˆv i,j 1/2 ) y = ( P i+1,j n+1 n+1 2Pi,j + Pi 1,j n+1 x 2 ) + ( P i,j+1 n+1 n+1 2Pi,j + Pi,j 1 n+1 y 2 ) (26) Note that on the domain boundary since u 1.5,j and u nx+1/2,j are fixed for all j, v i,1.5 and u i,ny+1/2 are fixed for all i, small adjustment needs to be made to the original pressure- 4
Poisson equation. For example at (nx, j): {u nx+1/2,j [û nx 1/2,j t n+1 nx,j (P P n+1 ρ x nx 1,j )]}/ x +[ˆv nx,j+1/2 ˆv nx,j 1/2 t n+1 (P ρ nx,j+1 P nx,j n+1 y ) + t n+1 (P ρ nx,j P n+1 y nx,j 1 )]/ y = 0 (27) The discrete pressure-poisson equations will be solved by SOR or other iterative solvers. Correct grid node velocities u n+1 i,j, v n+1 i,j with û i,j, ˆv i,j and P n+1 i 1,j, P n+1 i+1,j, P n+1 i,j+1, P n+1 i,j 1 : u n+1 i,j v n+1 i,j = û i,j t ρ = ˆv i,j t ρ n+1 i+1,j (P P i 1,j n+1 2 x n+1 i,j+1 (P P i,j 1 n+1 2 y ) (28) ) (29) Modify the velocities at the ghost nodes outside the domain so that they can be used at the beginning of next time loop. (End of the time loop) In this project, we use SOR with an over-relaxation factor of 1.4 to solve the pressure-poisson equations. Convergence is assumed to be reached when error residual is less than 0.001. Error residual is defined as: E = D (LHS RHS)2 nx ny where LHS and RHS are the left-hand side and the right-hand side of the pressure-poisson equation at each node and D denotes the sum of all the square of difference between LHS and RHS at each node within the domain. nx ny is the number of nodes within the domain. Similarly, we assume that steady state is reached when convergence residuals for both u and v velocities are less than 1e-6. Convergence residual is defined as: C = D (OLD NEW )2 nx ny where OLD and NEW are respectively the old value from last loop and the new value calculated in current loop and D denotes the sum of all the square of difference between OLD and NEW at each node within the domain. nx ny is the number of nodes within the domain. 5
3 Results and Discussion Figure 2 shows the contours of u velocity for Re=50 at 4 time intervals (time steps = 500, 1000, 2000, and 5000; time step size equals 0.002s). Figure 3 shows the contours of v velocity for Re=50 at 4 time intervals (time steps = 500, 1000, 2000, and 5000; time step size equals 0.002s). Figure 4 shows the streamlines of velocity vector for Re=50 at 4 time intervals (time steps = 500, 1000, 2000, and 5000; time step size equals 0.002s). It can be clearly observed that there is a vortex formed inside the square cavity and its center moves downward until the flow field becomes steady. The rotational direction of the vortex is clockwise, which is in accord with the moving direction of the top wall. (a) t=1s Figure 2: (a)(b)(c)(d): Contours of u velocity for Re=50 at 4 time intervals 6
(a) t=1s Figure 3: (a)(b)(c)(d): Contours of v velocity for Re=50 at 4 time intervals (a) t=1s Figure 4: (a)(b)(c)(d): Streamlines of velocity vector for Re=50 at 4 time intervals 7
Figure 5, 6 and 7 show respectively the contours of u velocity, contours of v velocity and streamlines of velocity vector for Re=100 at 4 time intervals (time steps = 500, 1000, 2000, and 5000; time step size equals 0.002s). (a) t=1s Figure 5: (a)(b)(c)(d): Contours of u velocity for Re=100 at 4 time intervals 8
(a) t=1s Figure 6: (a)(b)(c)(d): Contours of v velocity for Re=100 at 4 time intervals (a) t=1s Figure 7: (a)(b)(c)(d): Streamlines of velocity vector for Re=100 at 4 time intervals 9
Figure 8, 9 and 10 show respectively the contours of u velocity, contours of v velocity and streamlines of velocity vector for Re=200 at 4 time intervals (time steps = 500, 1000, 2000, and 5000; time step size equals 0.002s). (a) t=1s Figure 8: (a)(b)(c)(d): Contours of u velocity for Re=200 at 4 time intervals 10
(a) t=1s Figure 9: (a)(b)(c)(d): Contours of v velocity for Re=200 at 4 time intervals (a) t=1s Figure 10: (a)(b)(c)(d): Streamlines of velocity vector for Re=200 at 4 time intervals 11
Numbers of iterations it takes to reach steady state for different Reynolds numbers and the corresponding time costed are shown in Table 1. Reynolds Number Iterations Time (s) Residual of u velocity Residual of v velocity 50 2632 5.264 9.9995e-7 6.1809e-7 100 5160 10.32 9.9989e-7 7.9401e-7 200 12431 24.862 9.9992e-7 8.6143e-7 Table 1: Important parameters when steady state is reached for different Reynolds numbers As can be observed from Table 1, for Re=50 and 100, at t=10s (5000 time steps) the flow inside the cavity is already or very close to steady. But for Re=200, it takes as long as 24.9s (12431 time steps) to reach steady state. Figure 11 displays a comparison of contours of u and v velocity at steady state for different Reynolds numbers. Figure 12 shows the u velocity profiles at the vertical centerline and v velocity profiles at the horizontal centerline at steady state for different Reynolds numbers. Figure 13 displays the streamlines of velocity vector at steady state for different Reynolds numbers. When Re=200, at steady state one major vortex whose rotational direction is clockwise is at the middle of the cavity. Two vortices whose rotational direction is counterclockwise are observed at two bottom corners of the cavity (Figure 13 (c1)(c2)). No obvious vortices can be observed at the corners for lower Reynolds numbers, even at steady state. In Figure 14 the profiles of u velocity at the vertical centerline and v velocity at the horizontal centerline we generated for Re=100 at steady state are compared with those generated by Omari[2]. They are in good agreement with each other. In Figure 15 the streamlines of velocity vector we generated for Re=200 at steady state are compared with those generated by Baloch et al.[3]. Good agreement can be clearly observed. 12
(a1) Re=50, u velocity (a2) Re=50, v velocity (b1) Re=100, u velocity (b2) Re=100, v velocity (c1) Re=200, u velocity (c2) Re=200, v velocity Figure 11: (a)(b)(c): Contours of u and v velocity at steady state for different Reynolds numbers 13
(a1) Re=50, vertical centerline u velocity (a2) Re=50, horizontal centerline v velocity (b1) Re=100, vertical centerline u velocity (b2) Re=100, horizontal centerline v velocity (c1) Re=200, vertical centerline u velocity (c2) Re=200, horizontal centerline v velocity Figure 12: (a)(b)(c): Profiles of u and v velocity at the centerline at steady state for different Reynolds numbers 14
(a) Re=50 (b) Re=100 (c1) Re=200 (c2) Re=200, detail of left bottom corner Figure 13: (a)(b)(c): Streamlines of velocity vector at steady state for different Reynolds numbers 15
(a1) Our u velocity profile (a2) Omari[2] (b1) Our v velocity profile (b2) Omari[2] Figure 14: (a)(b): Comparison of profiles of u velocity at the vertical centerline and v velocity at the horizontal centerline generated by our codes and by Omari[2] for Re=100 at steady state (a) Our result (b) Baloch et al.[3] Figure 15: (a)(b): Comparison of streamlines of velocity vector generated by our codes and by Baloch et al.[3] for Re=200 at steady state 16
4 Summary In this project, we successfully developed a program to solve the two-dimensional unsteady Navier- Stokes equations for an elliptic flow in a square cavity with top wall sliding at a given velocity. Numerical results for flow of different Reynolds numbers at different time intervals and steady state have been shown. Satisfactory agreement with results from other literatures has been achieved. References [1] Joel H. Ferziger and Milovan Peric, Computational Methods for Fluid Dynamics, 3rd edition. [2] Omari R., CFD Simulations of Lid Driven Cavity Flow at Moderate Reynolds Number, European Scientific Journal, 2013, 9(15). [3] Baloch Z. A. K., Baloch M. E., Shaikh H., Computer Simulation of Lid Driven shallow Cavity Flows: Effects of Fluid Inertia and Aspect Ratios. 17