Homework 4 in 5C11; Part A: Incompressible Navier- Stokes, Finite Volume Methods Consider the incompressible Navier Stokes in two dimensions u x + v y = 0 u t + (u ) x + (uv) y + p x = 1 Re u + f (1) v t + (uv) x + (v ) y + p y = 1 v + g, Re where u and v are the velocity components in x and y direction, p is the pressure, Re is the Reynolds number and f and g are given source functions. Assume that the equations are solved with boundary conditions periodic boundary conditions in x-direction normal derivative of the pressure p y = 0 at y = H no-slip condition on the velocity at y = 0 and y = H Suppose the equations are discretized in space by the finite volume approximation on a staggered grid. The discretized equations are solved in time by the Marker and Cell (MAC) method: u n+1 = u n dt [ (u n ) x + (u n v n ] dt ) y + Re un + f n }{{} F n ] dt + v n+1 = v n dt [ (u n v n ) x + (v n ) y Re vn + g n }{{} G n dtp n+1 x dtp n+1 y By substituting the velocities at t n+1 into the continuity equation, show that the pressure at this time is given by the Poisson equation () p n+1 = 1 dt (F n x + G n y ) (3) Now the procedure to compute the velocities at t n+1 can be given by; 1) Compute F n and G n. ) Solve the Poisson equation for the pressure. 3) Compute u n+1 and v n+1. The second task is to add the energy equation, a temperature dependent density and source functions to simulate natural convection of an ideal gas, see handouts from Numerical Simulations in Fluid Dynamics by Griebel, Dornseifer and Neunhoeffer (GDN). The final form of the equations to be solved numerically is u x + v y = 0 u t + (u ) x + (uv) y + p x = 1 Re u + T T g x v t + (uv) x + (v ) y + p y = 1 Re v + T T g y T t + (ut ) x + (vt ) y = 1 T + Q, Re P r (4)
where g x and g y are the components of the gravitational acceleration, T is the temperature in the gas, P r is the Prandtl number and Q is a heat source. Here we have assumed that the Boussinesq approximation is valid; the density is constant except in the buoyancy terms (source terms in NS). Boundary conditions for the temperature are: 1) periodic in x-direction. ) T y = α(t T wall,u ) on at y = H and T y = α(t T wall,l ) at y = 0. Here α = h/κ with h being the termal heat transfer coefficient and κ the coefficient of heat conduction. Setting h = 0 gives an adiabatic wall, i.e. no heat is exchanged across the wall. If the temperature is defined in the same grid points as the pressure (in the middle of the cell), see the sample MATLAB files NSmain.m and Heatflx.m for a grid description. Show that the discretization of the last equation in (4) becomes T n+1 = T n dt ( u n+1 T n + T i+1j n u n+1 Ti 1j n + T n ) i 1j dx dt ( v n+1 T n + T +1 n v n+1 T 1 n + T n ) 1 dy + dt ( T n i+1j T n + T i 1j Re P r dx + T +1 n T n + T ) 1 dy PS: Note that you are not required to do any simulations in this part of the homework. The aim of the homework is to understand the time updating and the staggered discretization. (5) Homework 4 in 5C11; Part B: COMSOL lab, Finite Element Methods This homework is intended to give a brief introduction to the use of finite element packages for fluids problems. The main parts which should be learnt are the work flow with the GUI and to always check simple flow cases before going on to big complicated geometries. As such, this homework will give you an insight to how the problem is typically set up; from the drawing of the geometry, to the meshing and the set up of the equations and the boundary conditions. Note that a large part of a CFD practitioner s work time is spent meshing. The flow case We are solving the incompressible Navier Stokes for a two-dimensional channel confined by rigid walls at the top and bottom (infinite in the third direction). The equations are solved in dimensional form over a domain of [x y] [0, L 0, h], where L = 1[m] and h = 0.1[m]. We consider air at 0 C, so that the density is ρ = 1.1[kg/m 3 ] and a dynamic viscosity of µ = 1.810 5 [Ns/m ]. A triangle streamwise velocity profile is prescribed at the inflow boundary u(y) = U in h y, y < h/, (6) U in h h y, y h/,
where U in decides the peak of the profile. At the top and bottom boundaries no slip is enforced and a pressure boundary condition at outflow simulates a free boundary (outflow boundary). As the flow developes downstream we expect a parabolic profile to gradually form. The parabolic profile given a pressure gradient dp/dx is of the form u a (y) = dp/dx def y(h y) = 4U max µ h y(h y), (7) so that U max is the peak value of the velocity in the middle of the channel, i.e. at y = h/. The flow rate is defined as Q = h 0 u a dy = 4U max h [ 1 y h 1 ] h 3 y3 = 0 3 U maxh. (8) For an incompressible flow the quantity Q is conserved. The shear stress of the flow is given by so that at the lower wall it can be written as τ 1 = τ 1 = µ u a y = 4U max h (h y) (9) τ w = τ 1 (0) = 4U max h (10) Exercise 1: A simple warm up on basic fluid dynamics Given the triangle inflow (6) and the fact that Q given by (8) is conserved, calculate the relationship between U in the peak velocity at inflow and U max. How is the Reynolds number defined and what is its value for U in = 0.01[m/s]? Getting Started With COMSOL You can start COMSOL by typing bash> comsol & in your terminal. Depending on your system perhaps you might need to first do bash> module add comsol. You will now have a window called MODEL NAVIGATOR. Under the tab NEW you choose SPACE DIMENSION D and click COMSOL MULTIPHYSICS FLUID DY- NAMICS INCOMPRESSIBLE NAVIER STOKES. Click ok. Now you see that you are solving for u, v and p, with quadratic Lagrange elements. We will here mostly consider LAGRANGE LINEAR elements. Note that in general you could start with the general PDE mode and set up your own problem, but here we already have a module for fluid dynamics. We will here consider STATIONARY analysis where COMSOL uses an iterative procedure to obtain a steady state. From this steady state all the analysis will be performed.
Assume that the inflow velocity peak is U in = 0.01[m/s]. To make it easy the geometry can be loaded from www.mech.kth.se/~espena/5c11/channel_3..mph Since COMSOL solves the equations in dimensional form you need to set the constants in the program: OPTIONS CONSTANTS. This includes ρ, µ, the height of the channel h and U in. In addition you should set the scalar expressions that depend on these constants, such as U max and the Reynolds number Re. This is especially important concerning U max, which is used for setting the global nalytical velocity profile necessary to perform a check of the validity of the solution. Now you can use the rightmost seven buttons at the toolbar in the main window. Normally you start from left to right with the DRAW MODE followed by the POINT MODE, BOUNDARY MODE, SUBDOMAIN MODE and the MESH MODE. The DRAW MODE is meant for drawing a geometry, but you have already loaded the geometry. There is no need for setting POINT MODE values for this case. The BOUNDARY MODE settings
are predefined for your convenience, so all you need to do is to check and understand why they are set as they are. It is here the boundary conditions are set. In the SUBDO- MAIN MODE you need to set the values for the density ρ and the dynamic viscosity η (what we have defined as µ) at the PHYSICS tab. For geometries of this size it would perhaps be smart to use a structured grid, but we will use the generic unstructured grid which works for any geometry. A clean way of changing the resolution is to set the maximum allowed element size in MESH->FREE MESH PARAMETERS (MESH- >MESH PARAMETERS in older versions of COMSOL ). In that window you click the tab SUBDOMAIN where you can set the MAXIMUM ELEMENT SIZE. Choose a suitable value, for instance 0.01. Click REMESH. Exercise : Comparing solution to the analytic expressions Run this flow case for different resolutions, i.e starting with MAXIMUM ELEMENT SIZE 0.01 or/and 0.0. You can run the SOLVER by pressing the = (equals) button or click SOLVE - SOLVE PROBLEM. Produce plots of both the centerline velocity (at y = h/) x [0, 1] and the wall shear stress at y = 0 and x [0, 1] for a couple of different resolutions. At which resolution has it converged and at what x position do we have fully developed channel flow? Is the v velocity zero? Help: You can plot these quantities in POSTPROCESSING - CROSS-SECTION PLOT PARAMETERS. Go to the tab LINE-EXTRUSION and as Y-DATA you type in u-uanalytic (remember that uanalytic was predefined in OPTIONS-EXPRESSIONS). Below select x as X-DATA and select suitable ranges for the coordinates. The procedure is similar for the wall shear stress. Exercise 3: A real convergence study Plots as such give you the insight to the physics and the behaviour of the code, and one should always play around and visualize the different quantities from different views using both one and two-dimensional plots. However for a real verification of the code one needs to compare scalar expressions. A possible quantity to look at is the L -norm of the outflow streamwise velocity error h E = 0 (u u a ) dy. (11) Note that in general one should be careful in analysing quantities at outflow boundaries, but in this case the flow is quite simple yielding it relevant to analyse convergence here. The integration can be done in POSTPROCESSING-BOUNDARY INTEGRATION. Here mark the outflow boundary and in EXPRESSION type (u-uanalytic)^), the square root can be taken afterwards. Redo this for at least four different resolution using LAGRANGE LINEAR elements. The output can be plotted in a log log scale with the number of elements on the x-axis and the error on the y-axis. The plotting can be done in the COMSOL SCRIPT found under FILE -> COMSOL SCRIPT, which has a similar behaviour as a MATLAB-window. Fitting a straight line to these points will approximately provide the convergence rate r, with r being the slope of the curve.
To realize this note that we should have the error decaying as E (1/n) r, where n is the number of elements. Applying log to both sides yields log(e) = r log(n). Provide a plot of the error versus the number of elements and give an estimate of r. What value of r is expected for LAGRANGE LINEAR elements? Try to redo this for LAGRANGE P-P1 elements (quadratic). Why can you not gain any clear insight to the convergence rate when using these elements?