Computational Fluid Dynamics Course Notes

Computational Fluid Dynamics Course Notes

Computational Fluid Dynamics Course Notes

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

1. Computational Fluid Dynamics Course Notes Original notes: Dr PK Dyson, modified by: Dr. Ashwini K. Otta Sep 2004

2. What is Computational Fluid Dynamics ?

3. What are the elements of CFD? • Mathematical description of the fluid behaviour • Numerical discretisation • Solution of the discretised problem • Visualisation of the result

4. Mathematical description …. A few basic terms: Velocity Vector Steady and unsteady flow Point (Eulerian) and Lagrangian velocity Streamlines

5. Mathematical description …. Basic equations governing the fluid behaviour Equation of continuity Equation of momentum Property of fluid Transport of temperature Variables: density (ρ), velocity ( u,v,w), pressure (P), temperature (T)

6. The mathematical description … No knowledge can be certain, if it is not based upon mathematics or upon some other knowledge which is itself based upon the mathematical sciences. Leonardo da Vinci (1425-1519)

7. General Principles - Revision Mass Continuity u2 u1 Momentum net force acting on a fluid (control) volume = rate of change of momentum + net momentum flux through the surface how?

8. Mass Continuity Equation (1) mass-velocity = u y y,v x z,w v x,u Net rate of outflow of mass = rate of depletion of mass in control volume

9. Mass Continuity Equation (2) Substantial derivative For incompressible flow, this becomes:

10. Force on Control Volume = Rate of Change of Momentum in the volume +net momentum flux through the surface Momentum Equation (1) Velocity Changes across Control Volume u y x v

11. Momentum Equation (2) Forces Acting in x-Direction on Control Volume X y x Forces: Body: acting over the volume (X) Surface: Normal (Pressure) Tangential (shear)

12. Momentum Equation (3) Net Momentum Flux in x-direction (for a 2D fluid motion)

13. Momentum Equation (4) Net force in x-direction • Body force in X-direction: usually zero • Normal force: pressure  • Tangential surface force 

14. The Navier-Stokes Equations For: • steady state • 2-dimensional • incompressible Where, X,Y: body forces per unit volume in x and y direction respectively μ: coefficient of viscosity (dynamic)

15. Incompressible flow: (Navier-Stokes in Vector Notation) This now has four equations altogether for the four variables (u,v,w) and pressure P. But, we are not there yet in having a complete mathematical model for CFD!

16. Navier-Stokes - Summation Convention Taking u = u1 v = u2 w = u3 (separate equation for each of i = 1 to 3 • where • 1, 2, 3 represent x, y, z directions • a subcripted comma and index represents a derivitive • repeated subscript means set it to 1, 2, 3 in turn and sum resulting variables (so what does uj,,j = 0 mean?)

17. The Energy Equation for incompressible fluid(Transport equation for temperature) Internal generation u y x v Convection with mass transfer Conduction by temperature gradient

18. Analytical Example - Couette Flow Moving Plate - vel = us s Infinitely long y Stationary plate x

19. Solutions to the Equations The set of equations for incompressible, viscous, 2D unsteady flow is: Unknowns are u, v, P which are to be solved in terms of x and y - i.e. across flow domain. Solutions are typically plots of velocity vectors, streamlines, pressure contours (and temperature contours if energy equation is added). These may be processed to produce such data as forces (eg lift and drag on a foil) or pressure loss in pipes and fittings.

20. Computational Grid Since analytical solution is available only in simplest of cases, numerical techniques are required; thus a grid across flow domain needs to be defined Unknowns are determined at each grid point Concept may be extended into time domain: t x y

21. Typical Grid Notation i+1, j+1 i-1, j+1 i, j+1 i, j i+1, j i-1, j i, j-1 i+1, j-1 i-1, j-1

22. Solution Techniques • Broadly speaking, one of three techniques is adopted for the solution of the governing equations: • finite difference, in which the differential terms are discretised for each element • finite volume, in which the governing equations are integrated around the mesh elements • finite element, in which variation of variables within elements is approximated by a function, and a residual (or error term) is minimised. • The first of these is perhaps the easiest conceptually, and thus we will use this to outline a typical solution procedure. • CFX uses the finite volume method.

23. Differencing Formulae (1) u ui+1 ui i i+1 x Taylor Expansion (second order central difference)

24. Differencing Formulae (2) Adding the Taylor Series equations: Thus, if we take, say, the x direction N-S equation (steady for simplicity):

25. The Equation Set If we set up this set of equations at each of n interior points in the domain, and we know the boundary conditions (b) at the exterior points …. b b b b b b b b b b b b …. then we will form 3n simultaneous equations in 3n unknowns. Unfortunately, these are non-linear, so an iterative approach is usually employed - eg. guess u, v for the domain and insert as ui,j, vi,j in previous set of equations insert revised values of ui,j,vi,j solve equations for u, v, P check convergence

26. The Pressure Correction Approach Semi-Implicit Method for Pressure Linked Equations - SIMPLE !!!! Guess a pressure field Solve N-S equations (not continuity) for u,v, given these guessed pressures Solution process may be iterative or time marching Use modified continuity equation to calculate a pressure correction Do u, v values satisfy continuity? (convergence criterion) N Y Finish

27. Boundary Conditions (1) • Boundaries must be defined, but care must be taken not to: • under-define boundaries (insufficient data for solution) • over-define boundaries (creating a physically impossible situation) • eg wall u,v u,v, P u, v, P u,v wall ……… is over-defined since velocity and pressure are stipulated at inlet and outlet. Values may thus not satisfy the continuity and momentum equations.

28. Boundary Conditions (2) Boundaries defined will depend on nature of equations to be solved (steady / unsteady, incompressible/compressible, inviscid/viscous) For example, for steady, incompressible, viscous flow, solved by pressure correction method, boundaries conditions may be: P v, P

29. Grids (1) Structured Mesh usually comprising quadrilateral elements Physical Space eg. circular duct Computational Space

30. Grids (2) Aerofoil Section (Example of structured mesh, refined in critical regions)

31. Grids (3) Unstructured Mesh usually based on triangular pyramids (eg CFX 5) • Important Modelling Considerations • Grid refinement in critical areas • Grid independent solution - checks required • Computationally economic model • coarse grid in non-critical areas • make use of symmetry and periodic boundary conditions • use 2-D and axi-symmetric models where possible

32. vel at a point Turbulence u’ time

33. Mathematical Modelling of Turbulence Laminar Flow Momentum diffusion by viscosity Turbulent Flow Additional momentum diffusion due to turbulence Concept of turbulent (or eddy) viscosity, t • t is not a fluid property, but depends on level of turbulence in flow • concept leads to mathematical models to deal with turbulence; each model is an approximation to what is really happening • one popular model (k-epsilon model) introduces two further unknowns:

34. k-  Turbulence Model • requires two further equations, similar to Navier-Stokes equations for k and  • thus requires • inlet values for k and  • initial guesses for k and  • estimates for these may be obtained from equations such as the following, available in the literature • sensitivity to inlet turbulence quantities should be checked, and may point to the need for experimentally derived values for use in the CFD model.

35. Health Warning ! • We have barely scratched the surface of the theory of CFD. A few of the possible areas for further fruitful reading are: • nature of the equations under different conditions - hyperbolic, parabolic, elliptic. • transient problems • choice of boundary and initial conditions • coupling between momentum and energy equations (especially in buoyancy driven flows) • supersonic flows and shock capture • turbulence modelling - what alternative models are available? • wall boundary conditions (log law of the wall) • Treat CFD with respect - a little knowledge is a dangerous thing !

36. ANSYS – CFX Overview (1) Start > University Software > ANSYS > ANSYS CFX CAD2MESH Mesh Control Parameters Geometry ANSYS Workbench (*.wbdb file) DesignModeller (*.agdb file) CFX-Mesh (*.cmdb file) (*.gtm file) Note: CFX-Build has been superseded by DesignModeller and CFX-Mesh. Thus references to CFX-Build in Help pages are no longer relevant.

37. ANSYS – CFX Overview (2) *.gtm file Problem type Start > University Software > CFX Solution control CFX-Pre Case file (*.cfx) Boundary conditions Session file (*.ses) holds record of commands entered during session Fluid properties Journal file (*.jou) holds record of commands for particular database Definition file (*.def)

38. ANSYS – CFX Overview (3) Definition file (*.def) Solver Results file (*.res) Output file (*.out) CFX-Post (numerical data in text file) Velocities Streamlines Pressures Forces Turbulence For further details, see CFX Help page: Installation & Introduction, Overview of CFX5, CFX File types, p193

39. File Management • Create a “MyCFX” folder on the local hard drive and put each job in a different sub-folder. • Do not leave spaces in folder or file names anywhere in the path to your working folder. • Work from the local hard drive (not across the Network from your U: drive) • At the end of the session, drag and drop your entire working folder to your U: drive. • You are strongly advised to back up your work to a CD or memory stick at the end of each session.

40. Exercise 1 • Create folder MyCFX on the hard drive. • Work through Tutorial 1, Static Mixer, starting from page 6, “If you are using ANSYS Workbench ….” • You should follow the particular instructions in brackets for users of ANSYS Workbench 8.0.1, and note that the arrows shown will be reversed. • This will take you through: • Geometry creation using DesignModeller • Mesh generation using CFX-Mesh • After creating the mesh you will need to start CFX, specify your working folder (directory) on the CFX launch panel, and then start CFX-Pre. • Continue working through the tutorial from p 42 of the CFX tutorials, “To create a new simulation”. • This will take you through: • Problem Definition using CFX-Pre • Solution using CFX Solver Manager • Viewing of results using CFX-Post

41. Now make sure you understand ….. • What’s the difference between • Sketching mode and modelling mode • DesignModeller and CFX-Mesh • Surface Mesh and Volume Mesh … and now consolidate what you’ve done by looking through this example …. In ANSYS Workbench go to Help > DesignModeller 8.0 Help > Welcome to the DesignModeller 8.0 Help > Process for Creating a Model Read through the page and run the video sequences to remind yourself of the process of creating a geometry.

42. Exercise 2 Work through Tutorial 2, Static Mixer(Refined Mesh) which will show you more about the mesh generation process. Exercise 3 • Refine the mesh even further in the outlet region of the mixer by inserting a mesh control as follows. • Re-open StaticMixer in CFX-Mesh • Right click Point Spacing > Insert Point Spacing • Click Point Spacing 1 in Detail View and change the settings to: Length scale 0.1 m, Radius of Influence 0.5 m, Expansion Factor 1.2 • Right click Point Spacing > Insert Line Control • Click Line Control 1 • In Detail View, for point 1 click Apply, and accept coordinates as 0,0,0. Repeat for point 2 and make coordinates 0,0,-2. Click in the box next to spacing, then click Point Spacing 1 in Tree View. • Right click Body 1 > Suppress and observe position of Line Control. Unsuppress Body 1. • Generate the surface mesh as before and note the difference around the exit. • Generate Volume Mesh, Run Solver and view results.

43. Finding Out More – The Help Pages Help onANSYS Workbench, DesignModeller and CFX-Mesh is available on the Workbench Help button and the subsequent Folder Tree • Help on CFX Pre, Solver and Post is accessed from the CFX launch panel by clicking: • Help >Master contents • Now click the relevant + sign and then click contents. • Each section heading is a hotlink to take you to the relevant page. Now use the Help pages to answer the following questions.

44. Finding Out More • (ANSYS) Help > CFX-Mesh 2.1 Help • What is the principle type of mesh utilised by CFX? What is its advantage over a quasi-rectangular mesh? • What is mesh control? Why use it? • What is inflation? Why use it? • What is a mesh independent solution? • (CFX) Help > CFX-Pre > Fluid Domains • What options are available for the fluid domain models? • What standard fluids are available? • (CFX) Help > CFX-Pre > Boundary Conditions • What boundary conditions are available? • (CFX) Help > CFX-Pre > Initial Conditions • Why are initial values set? • (CFX) Help > CFX-Pre > Solver Control • What are convergence criteria?

45. Treatment of Walls and Flow Boundaries Further reading from CFX Help pages: Near Wall Modelling (Solver Modelling - Turbulence & Near Wall Modelling - Modelling Flow Near the Wall pp 116-120) Boundary Condition Modelling (Solver Modelling- Boundary Condition Modelling pp 50-82)

46. Exercise 4 y x z Although this is an external flow, (as opposed to the previous pipe example which was internal), we still need to define a limit to the domain. This will effectively be a “wind tunnel” in which the cylinder will be placed. We will treat this as a 2-D example by making the fluid domain thin in the x direction and attaching the cylinder to the wall at each side. You should create a new folder for this problem.

47. 1 2 Using CFX-Build • Sketch surface A (the low-x surface) as a rectangle. • Sketch the circle (rectangle and circle will both be part of sketch 1) • Extrude in the x direction. The 3D body formed by the box with the cylinder cut out, sometimes confusingly referred to as the “solid”, is where the fluid will flow. 0.3 2 10 surface A diameter 0.3 y x z point 0 0 0

48. Using CFX-Mesh If we want, say, around 6 elements in the region with the most coarse mesh (near the exit), then this give a default mesh length of about 0.3 m. Since this is a 2D problem, it needs only to be 1 element thick, which is why we also make the box width 0.3 m. Would making it thicker give any benefit or penalty? • Open CFX-Mesh and create a 2-D region for each of the surfaces (left, right, inlet, outlet, cylinder – leave top & bottom undefined – they will form the “default 2D region”), giving each a suitable name (you will use these later to define boundary conditions). • Set mesh default body spacing to a maximum of 0.3 m. • Set up Inflation parameters (use defaults) and apply inflation to the cylinder with a maximum thickness of 0.03 m.

49. Place mesh controls to refine the mesh in the region of the cylinder and its wake. • Create surface mesh, and check it to ensure it is refined in the appropriate places. • Create the volume mesh (thus writing the .gtm file) and start CFX-Pre.

50. Using CFX-Pre • Create a fluid domain - use standard air or water, select steady state, k- turbulence model, scalable wall function, isothermal, non-buoyant. Set reference pressure at 0 Pa. • In the Object Selector Panel, double click on the material you have chosen (under the “library” tree), and make a note of its density and dynamic viscosity (under “Transport Properties”). • Create boundary conditions: • non-slip smooth wall on the cylinder • free slip wall on top and bottom surfaces (why?) • symmetry on the left surface (why?) • symmetry on the right surface • inlet velocity giving Re=105 based on cylinder diameter • outlet velocity set to “average static pressure” of 0 Pa.