Gambit - Generation of Grid for a Flat Plate Boundary Layer
Latest revision, 20 February 2013, 8:30 a.m.
Introduction and Instructions:
In this document is a procedure that enables students to generate a structured (rectangular) grid, which will be used to solve for both laminar and turbulent boundary layer flow over a flat plate with the CFD program, Fluent. Readers should already be familiar with the notation used in this module, as described in the learning module, Fluent and Gambit - Introduction and General Information.
- We will model flow over a flat plate aligned parallel to the freestream flow. Because of the symmetry, only one half (the upper half) of the geometry needs to be generated. The grid will be formed by a simple rectangle as sketched below (not to scale):
- In the sketch, x is the freestream flow direction, parallel to the flat plate. Coordinate y lies normal to the plate ("up" in the figure). The z direction is out of the page. The problem is two-dimensional, so imagine that the plate extends to infinity in the z direction. However, for purposes of calculating drag coefficients, etc., define b as the span (or depth) of the plate in the z direction. b is generally taken to be one unit length (1 m) for convenience, and drag force FD is reported as drag per unit span (or drag per unit depth) in units of N/m.
- The length of the flat plate is L = 0.5 m, and the height of the computational domain is H = 0.40 m.
- The inlet is located far enough upstream of the plate so that uniform freestream flow exists. In this example, the inlet is xleading = 0.1 m upstream of the leading edge of the flat plate.
- The grid in this example starts at 40 by 30, but the grid adaptation feature of Fluent will be utilized to refine the grid where necessary. Other starting grid densities can be generated, of course, by entering different values in the instructions below.
- In order to adequately resolve the boundary layer along the wall, grid points will be clustered near the wall. Far away from walls, where the flow does not have large velocity gradients, the grid points can be very far apart. Grid adaptation will increase the grid density even more near the wall where needed.
Launch Gambit:
- Log on to the CFD computer in the Fluids Lab.
- Create a DOS shell by double clicking the icon on the computer's desktop called Command Prompt.
- From the Command Prompt line, enter "cd c:\temp" to go to the temporary subdirectory, on which you have write access.
- Gambit may now be launched. Enter "gambit -id name", where name is a unique name for the session without any blank spaces, e.g. "flatplate_Smith_Jones_Group_C". After a while, the main Gambit window should appear on your screen.
- In the upper left of the screen, Solver-Fluent 5/6. This selects Fluent as the solver for which Gambit will eventually write the mesh file.
Create some data points (vertices) for the desired geometry:
- First, create a vertex at the origin, which is the leading edge of the flat plate. In Geometry, Vertex Command Button-R-Create Vertex-From Coordinates. In Create Real Vertex-Global, enter 0, 0, and 0 for x, y, and z coordinates respectively. Type an appropriate label for this vertex, e.g., "origin", and Apply. A vertex is created, as indicated by a small plus sign at this location.
- Create another vertex with coordinates (-0.1,0,0). You can call it "lower left" or something like that.
- In similar fashion, enter the coordinates of the other points defining the limits of the computational domain, i.e. (0.5,0,0), (0.5,H,0), and (-0.1,H,0). You can name them appropriately ("lower right", "upper right", and "upper left" are suggested), or you can let Gambit label these vertices for you by default.
- Finally, define a point at the top, but at x = 0 so that the grid can be nice and rectangular. Enter vertex coordinates (0,H,0) and call it "upper middle" or something descriptive of its location.
- At this point, it is wise to zoom in somewhat to see the vertices more clearly. There are two ways to do this. You can zoom in and move with the right mouse and middle mouse, respectively. Or, to fit all the geometry into the available screen space (a very handy tool!), in the Global Control area (near the bottom right of the screen), Fit to Window (the button that looks like two paper airplanes).
- In the main Gambit window near the upper left, File-Save. This will save your work so far. It is a good idea to do this every so often, especially after a major task is completed.
Create edges from these vertices to define the computational domain:
- Now some edges will be created to define the flat plate and the rectangular boundary surrounding the plate. Under Geometry, Edge Command Button. (Note: If the button is already open, clicking it again will make the options disappear! If this happens, click it again.)
- Under Edge, right mouse click the top left icon, which is called Create Edge, and then Straight. (In this learning module from now on, this type of command which requires a right click of the mouse will be denoted by R-Create Edge-Straight.)
- In Create Straight Edge, make sure the text area called Vertices is highlighted - if not, click in that area. Vertices are selected by Shift + left mouse click. Select the two rightmost vertices, first the one we called lower right, and then the one we called upper right.
- Type in an appropriate label for the edge about to be created. I suggest "outlet" or something equally descriptive. Apply. Gambit will create a straight edge between these two vertices. A yellow line should be drawn on the screen connecting the vertices.
- In similar fashion, create two separate edges along the top, one along the top right of the computational domain, and one along the top left of the computational domain. If desired, label these "top right" and "top left" respectively.
- Generate an edge along the left side of the domain, and call it "inlet".
- For the bottom of the domain, create two separate edges - one from the lower left vertex to the origin (leading edge of the flat plate), and one from the origin to the lower right vertex. Recommended labels are "leading" and "flat plate" or "bottom left" and "bottom right".
- Now Close the Create Straight Edge window.
- In the main Gambit window near the upper left, File-Save. This will save your work so far. It is a good idea to do this every so often, especially after a major task is completed.
Generate a face above the flat plate from the available edges:
- Under Geometry, Face Command Button-R-Form Face-Wireframe.
- It is important to select the edges in order when creating a face from existing edges. (I like to select them in mathematically positive counterclockwise order). Select the rightmost edge first, followed by the top right edge, the top left edge, the leftmost edge, the edge upstream of the flat plate, and then finally the edge representing the plate itself. These edges outline a closed face.
- In Create Face From Wireframe, type in a label for this face if desired ("domain" is suggested), and Apply. If all went well, a pretty blue outline of the face should appear on the screen; this is a face, which is now ready to be meshed.
Define node points along the edges:
- In Operation, Mesh Command Button-Edge Command Button. Mesh Edges should be the default window that opens; if not, Mesh Edges.
- Select the leftmost (inlet) edge, and in Mesh Edges, change the Spacing option from Interval Size to Interval Count. Enter the number 30 as the Interval Count. It is desirable to cluster or bunch nodes close to the plate. This is accomplished by changing Ratio (in the Grading section of the Mesh Edges window). A Ratio of 1.05 is recommended so that the nodes are clustered near the bottom. Hit the Enter key on the keyboard to preview the node distribution. If the clustering is backwards from the way you desire, click on the Reverse button. Apply. Blue circles should appear at each created node point along that edge.
- Put the same node distribution on the rightmost edge (the outlet). You may or may not have to Reverse the distribution, depending on the direction in which you created the edge. Don't forget to Apply; otherwise the node distribution is not saved.
- Select the left portion of the bottom edge (the part upstream of the plate). Change Interval Count to 10. This time, we want to cluster the nodes near the leading edge of the plate. This time, set Ratio to 1.10, and Reverse if necessary so that the clustering is in the correct direction. Apply.
- Similarly, define 30 node points along the plate itself, clustered near the leading edge of the plate.
- Define the same distribution on the two top edges as on the two bottom edges so that the mesh lines will be vertical. This is not necessary, but makes the mesh look nicer, and rectangular cells lead to better convergence. Don't forget to Apply each time, or the nodes will not actually be saved.
- When all edges have been assigned nodes, Close the Mesh Edges window.
Specify the boundary types on all edges:
- In order for the mesh to be properly transferred to Fluent, the edges must be assigned boundary types, such as wall, inlet, outlet, etc. Actual numerical values, such as inlet velocity, will be specified as boundary conditions from within Fluent itself. In Operation, Zones Command Button-Specify Boundary Types Command Button.
- In the Specify Boundary Types window, change Entity to Edges (the default is usually Faces). In this problem, which is 2-D, boundary conditions will be applied to edges rather than to faces.
- Select the left-most edge of the computational domain, which will become an inlet. Change Type to Velocity_Inlet, and type in the name "inlet". Apply. Some words indicating this boundary condition will appear on the Transcript (located in the lower left portion of the screen).
- Select the right-most edge. In similar fashion, make this a Pressure Outlet named "outlet". Be sure to Apply, or the boundary condition will not actually be changed.
- Select both of the top-most edges. These two edges will be combined into one boundary for Fluent, which will also be a pressure outlet. The label "top" is suggested. Apply.
- Select the horizontal edge running from the lower left to the origin (the one called "leading"). Select its Type as Symmetry, and label it "leading". Apply.
- Finally, Select the edge defining the flat plate itself. Name this boundary "flat_plate" or "plate", and change Type to Wall. Apply.
- To verify that all the boundary conditions have been entered correctly, turn on Show Labels, and zoom out (drag right mouse button up) to see all the boundary condition labels.
- Close the Specify Boundary Types window.
Generate the mesh on the face:
- Under Operation, Mesh Command Button-Face Command Button. The default window that pops up should be Mesh Faces. If not, Mesh Faces.
- Select the face by shift clicking on one of its edges. Elements should be Quad by default; if not, change it. Also change Type to Map if necessary. Turn the Spacing option off since nodes have already been defined on all edges of this face.
- Generate the mesh by Apply. If all goes well, a structured mesh should appear. Zoom in to see how the cells are nicely clustered near the leading edge of the flat plate. This will help Fluent to resolve the boundary layer along the flat plate.
- Zoom back out so that the entire mesh can be clearly seen. This is most easily accomplished by clicking on Fit to Window in the Graphics/Windows Control (the button that looks like two paper airplanes near the bottom right of the screen).
- Close the Mesh Faces window.
Write out the mesh in the format used by Fluent, and then exit Gambit:
- In the main Gambit window, File-Export-Mesh. Turn on Export 2d mesh, and Accept. (The default file name can be changed here if desired, but the default name is acceptable in this case.)
- When the Transcript informs you that the mesh is done, File-Exit-Yes.
- When Gambit exits, the DOS shell will re-appear. Enter "dir *.msh" to see the mesh files created by Gambit. There should be a file with today's date and time called "name.msh", where name is the name you previously chose for the title of this session, e.g. "flatplate_Smith_Jones_Group_C". This is the mesh file to be used by Fluent.
- The mesh file should now be ready for use by Fluent. You may move on to the next learning module, Fluent - Laminar Flat Plate Boundary Layer, which describes how to run this case with the CFD solver, Fluent.
Fluent - Laminar Flat Plate Boundary Layer
Latest revision, 26 February 2004, 4:00 p.m.
Introduction and Instructions:
This learning module contains a procedure to solve for the laminar boundary layer on a flat plate with the CFD program, Fluent.
Note: This set of instructions assumes that the student has already run Gambit, and has generated a grid for the flow: file name.msh, where name is a file name given previously.
Launch Fluent:
- If a DOS shell is not already open, create a DOS shell by double clicking the icon on the computer's desktop called Command Prompt.
- From the Command Prompt line, enter "cd c:\temp" to go to the temporary subdirectory, on which you have write access.
- From the Command Prompt line, enter "fluent 2d". After a few seconds, the main Fluent window should appear on your screen.
Read the grid points and geometry of the flow domain:
- Select File-Read-Case. The file you created in Gambit (name.msh) should appear. Highlight this file, and OK. Fluent will read in the grid geometry and mesh that was previously created by Gambit. Some information is displayed on the main screen. If all is read well, it should give no errors, and the word "Done" should appear.
Note - If you have trouble reading your grid, you probably made a mistake in Gambit somewhere. You may need to repeat the Gambit session before continuing. - Check the validity of the grid: Grid-Check. If the grid is valid, no errors should appear. If there are errors, you may have done something wrong in the grid generation, and will have to go back and regenerate the grid.
- Look at the grid to make sure it is correct. Display-Grid-Display. A new graphical display window opens up showing the grid. If this window is too big, re-scale it by dragging the edges of the window. It is best if the graphical display window is small enough that both it and the Fluent window are visible simultaneously. The Fluent window and/or the graphical display window may need to be moved to accomplish this.
- The graphical display can be zoomed-in or zoomed-out with the middle mouse button. If you start on the lower left and draw a rectangle with the middle mouse button towards the upper right, the display will zoom in on what is included in the rectangle. Meanwhile, the left mouse button can be used to drag the image to a new location. If you draw a rectangle backwards with the middle mouse button, i.e. from right to the left, it will zoom out. Zoom in if necessary until the grid is shown nicely in the window. Close the Grid Display window; the display itself will remain.
Generate lines at x = 0.10 m and at x = 0.30 m:
- The boundary layer profile will be examined in detail at three x locations along the flat plate, namely at x = 0.10 m, 0.30 m, and 0.50 m. The last of these is the outlet of the domain, but lines need to be defined within Fluent for the first two.
- In the main Fluent window, Surface-Line/Rake. Type in the desired starting and ending x and y locations of the vertical line, i.e. a vertical line going from (0.10,0) to (0.10,H).
- The New Surface Name should be assigned at this point. It is suggested that this line be called "profile0.10" or something descriptive of its intended purpose.
- Click on Create to create the line.
- Similarly, create a line at x = 0.30; a suggested label is "profile0.30".
- To view these newly created lines, return to the main Fluent window, and Display-Grid. Unselect (by left mouse click) the default interior, and select the newly created lines instead. Display. The lines should be visible at the appropriate locations. If not, create them again more carefully.
- Now Close both the Line/Rake Surface window and the Grid Display window.
Define the fluid as liquid water:
- The default fluid is air, which must be changed to water. In the main Fluent window, Define-Materials-Database. Select water-liquid from the Fluid Materials drop down list. Copy.
- Write down the density and viscosity of liquid water, which are needed later to calculate Reynolds numbers, etc. Close.
- Now Close the Materials window. Caution: This has added liquid water into the list of fluids available as boundary conditions, but has not actually changed the fluid from air to water. This will be done when specifying the boundary conditions.
Define the boundary conditions:
- Now the boundary conditions need to be specified. In Gambit, the boundary conditions were declared, i.e. wall, velocity inlet, etc., but actual values for inlet velocity, etc. were never defined. This must be done in Fluent. In the main Fluent window, click on Define-Boundary Conditions, and a new Boundary Conditions window will pop up.
- Select fluid and Set. Choose water-liquid as the Material Name from the drop-down list of material names. OK.
- The default boundary condition for the flat plate (wall) is okay (stationary wall), so nothing needs to be done to it.
- Likewise, the default boundary conditions for the symmetry plane (symmetry) and the two pressure outlets (outlet and top) are okay, so nothing needs done to them.
- Select inlet, which is the left side of the computational domain. Set. The Velocity Specification Method should be Magnitude and Direction by default. If not, change it. Change the Velocity Magnitude to 0.10 m/s. The default is normal to the boundary, which is what is desired here, so OK.
- Boundary conditions are complete, so Close the Boundary Conditions window.
Set up some parameters and initialize:
- In the main Fluent window, Define-Models-Viscous. Laminar flow is the default, so we really don't need to do anything here. Later on, however, you may need to specify turbulent flow calculations; this is where the turbulence models are specified in Fluent. OK.
- Now the convergence criteria need to be set. As the code iterates, "residuals" are calculated for each flow equation. These residuals represent a kind of average error in the solution - the smaller the residual, the more converged the solution. In the main Fluent window, Solve-Monitors-Residual. In the Residual Monitors window that pops up, turn on Plot in the Options portion of the window. The Print option should already be on by default. Here, Print refers to text printed in the main Fluent window, and Plot causes the code to plot the residuals on the screen while the code is iterating.
- Since there are three differential equations to be solved in a two-D incompressible laminar flow problem, there are three residuals to be monitored for convergence: continuity, x-velocity, and y-velocity. The default convergence criteria are 0.001 for all three of these. Experience has shown that this value is generally not low enough for proper convergence. Change the Convergence Criterion for all three residuals from 0.001 to 1.E-06 (highlight the number, and then type in the new value).
- To apply the changes, OK, which will also close the Residual Monitors window.
- Experience has shown that for most problems, the solution converges better if the under-relaxation factors are reduced from their default values. Without going into a lot of detail, reduced under-relaxation factors sort of "damp out" changes in the solution as it iterates. Sometimes these changes are too aggressive, and adversely affect convergence. In the main Fluent window, Solve-Controls-Solution. Reduce the Under-Relaxation Factors for pressure and momentum by a factor of two from their default values. OK.
- In the main Fluent window, Solve-Initialize-Initialize. The default initial values of velocity and gage pressure are all zero. These are good enough for this problem. Init and Close.
- At this point, and every so often, it is wise to save your work. In the main Fluent window, File-Write-Case & Data. In the Select File window which pops up, the default file name is acceptable. Note that Case & Data refers to both the case (the grid plus all boundary conditions and other specified parameters) and the data (the velocity and pressure fields calculated by the code). The code will actually write out two files, name.cas and name.dat, where name is the name you previously assigned.
- If not on by default, turn on the option to Write Binary Files (to save disk space). To save even more disk space, the files can be compressed by adding a "gz" at the end of the file name. The complete file name should be "name.cas.gz". OK to write the file onto your directory.
Iterate towards a solution:
- In the main Fluent window, Solve-Iterate to open up the Iterate window. Change Number of Iterations to 200, and Iterate. The main screen will list the residuals after every iteration, while the graphical display window will plot the residuals as a function of iteration number. The residuals may rise at first, but should slowly start to fall. It is normal for the residuals to fluctuate up and down. Do not be concerned if there are reverse flow warnings; these will disappear in time.
- At the end of 200 iterations, check to see how the solution is progressing. In the main Fluent window, Display-Vectors-Display. The graphical display window will show the velocity vectors. Zoom in with the middle mouse, as described above, to view the velocity field in more detail if desired. In particular, view the boundary layer near the end of the plate. Is it starting to look like a boundary layer profile?
- Iterate some more - (To restart the iteration, either find the Iterate window, which is probably hidden under some other windows at this point, or click again on Solve-Iterate to re-open the Iterate window.) In the Iterate window, set Number of Iterations to 100, Apply, and Iterate.
- Check the velocity vectors, as described above after another 100 iterations. It is wise to move the Iterate window someplace out of the way of the other windows so you can easily restart the iteration. The residuals may go up sometimes. This is normal, as the code attempts to zero in on a solution - after a while the residuals should again decay or level off. If the residuals all go below the convergence criteria, the calculations will stop. In some cases, however, the residuals reach a lower limit, and further iterations don't improve the solution.
- 200 to 300 iterations should be sufficient for the first attempt. Before iterating further, the grid must be refined.
Refine the grid:
- Our grid is not tight enough near the wall to accurately resolve the boundary layer, especially near the front of the flat plate where the boundary layer is very thin. Fortunately, Fluent has an "Adapt" feature that automatically adds grid points where needed for better resolution. There are several options for grid adaptation - we shall adapt by velocity gradient.
- In the main Fluent window, Adapt-Gradient. In the new Gradient Adaption window, select Gradients of Velocity.
- Select the Compute option. Minimum and maximum velocity gradients will appear in the window.
- As a good rule of thumb, set the Refine Threshold to about 1/10 of the maximum gradient, and the Coarsen Threshold to about 1/1000 of the Refine Threshold. Enter these values in the appropriate text boxes.
- Now select Mark. The main Fluent window will display how many cells have been selected for refining and coarsening. The coarsening cells can be ignored since Fluent is unable to coarsen the original grid - it can only refine the original grid.
- Optional: If you want to see where the grid will be adapted, click Manage-Display. Areas destined for grid refinement will be highlighted. (You may need to zoom out to see this better.)
- Back in the Gradient Adaption window, Adapt. You will be prompted about hanging-node mode. Answer Yes to continue. The main Fluent window will display some information about the grid adaptation.
- Optional: To see what the refined grid looks like, you can select Display-Grid from the main Fluent window, highlight default-interior, and Display. (You may need to zoom in close to the wall to see more clearly.) You should see some new cells near the wall (especially near the leading edge of the flat plate) where velocity gradients are highest.
- The Gradient Adaption window can be closed at this point. Or, better yet - move it somewhere on the screen where it can be accessed again, since we will need it again later.
Iterate some more:
- If the Iterate window is still available, go to it. If not, Solve-Iterate from the main Fluent window to re-open the Iterate window. Change Number of Iterations to about 500, Apply, and Iterate.
- At the end of these iterations, check to see how the solution is progressing. In the main Fluent window, Display-Vectors-Display. The graphical display window will show the velocity vectors.
- Under Surfaces, select only inlet, profile0.10, profile0.30, and outlet. Display.
- Zoom out and move as necessary to see all four velocity profiles.
- Change the velocity vector scale to about 10 to see the profiles more clearly. Display. The growth of the boundary layer should be apparent.
Examine the velocity profiles in detail:
- At this point, the velocity profile at three desired downstream locations (x = 0.10, 0.30, and 0.50 m) will be plotted and examined in detail.
- In the main Fluent window, select Plot-XY Plot. A window called Solution XY Plot will open up. In this window, at the lower right corner, select (highlight) the surfaces we created above, i.e. the ones called profile0.10 and profile0.30. Also select outlet, which is at x = 0.50 m.
- In the upper left corner of the window, turn off Position on X Axis, and turn on Position on Y Axis. This will make the vertical axis the y position on the plot, as desired.
- In the upper middle part of that window, set Plot Direction to X = 0 and Y = 1. This will make the y-coordinate position appear on the vertical axis, as desired for a standard velocity profile plot.
- The upper right part of the window selects the variable to be plotted. The Y Axis Function will be set automatically to Direction Vector, and should be left alone. For the X Axis Function, select Velocity and (just below that) X-Velocity. Plot.
- The boundary layer profiles should be there, but may be hard to see since the vertical axis extends all the way to the upper boundary of the computational domain. The axes limits can be changed as follows: Axes. Choose X if necessary (X should already be the default). Unselect Auto Range, and select Major Rules. Set Range from 0 to 0.11 m/s. Apply. (Nothing will happen to the plot yet, so don't panic.)
- Now choose the Y (vertical) axis. Unselect Auto Range and select Major Rules for this axis as well. Set the range from 0 to around 0.04 m or so, such that the entire boundary layer is visible on the plot.
- To make the scale more readable, change the Number Format to Type = Float and Precision = 3. Apply. Close.
- Back in the Solution XY Plot window, Plot. Adjust the axes and/or number format as desired to obtain a nice plot of the boundary layer profiles. If done correctly, all three profiles should be visible on the plot, and the growth of the boundary layer with downstream distance should be apparent.
Iterate towards a final solution:
- At this point, the boundary layer should be reasonable, but more grid refinement and iteration may be required. If there are less than about 10 data points within the thickness of the boundary layer at any of the three profile locations, the grid should be refined again.
- Refine the grid and re-iterate as necessary to obtain a final solution. Each time you adapt the grid, you must re-calculate the gradients (Compute), re-adjust the refine threshold (again, it should be set to about 1/10 of the maximum gradient), Mark, and Adapt-Yes.
- Iterate at least 300 to 500 iterations after each grid adaption. The residuals will rise dramatically after an adaption, but will decay as the solution adjusts itself to the newly refined grid.
- Caution: Don't adapt too much, or the computations will take too much CPU time. Note that every time you refine the grid, the computer must calculate the flow field at more grid points, requiring longer for each successive iteration.
- After refinement and iteration, look at the velocity profiles (Plot-XY Plot-Plot from the main Fluent window, or simply Plot if the Solution XY Plot window is still available).
- Adapt several times until there are at least 8 to 10 data points within each boundary layer. You may need to lower the Refine Threshold to about 1/100 or even 1/1000 of the maximum gradient value in order to do any significant adaption.
- When finished adapting, run several hundred iterations until the residuals level off, or until the convergence criteria are reached.
Save your velocity profiles and your calculations:
- In the main Fluent window, File-Write-Case & Data. In the Select File window which pops up, the default file name should be "name.cas.gz", as previously entered. OK to write the file onto your directory. OK again since it is okay to overwrite these files.
- From the Solution X-Y Plot window, Plot. When the plot is to your liking, the plot of the boundary layer profiles will be saved as a tif file.
- Before saving the plot, your name and a short description should be added to the title. Click with the left mouse button just below the existing title ("X Velocity") in the bottom left of the plot. A cursor should appear. Type your names and Group letter on the plot title.
- In the main Fluent window, File-Hardcopy, select TIFF, and Save. Give a unique, descriptive name to the file (something like "laminar_profiles_Smith_Jones_Group_C.tif" is appropriate), OK, and Close. The tif file just generated can be inserted into a Microsoft Word document later.
- The data points along the x = 0.50 m line will now be saved to an ASCII file for further analysis and comparison to predictions. From the Solution XY Plot window, select only the outlet line. Write to File, and Write. Name the file, and OK.
- Finally, save a plot of the residuals. In the main Fluent window, Plot-Residuals-Plot. Then, File-Hardcopy. It is suggested that Coloring be changed to Monochrome since the printer prints in black and white only. Save, name the file, OK, and Close.
Calculate the drag force and drag coefficient on the body:
ME 83 Students do not need to do this section - skip to the next section.
- In order to calculate drag coefficient correctly, the proper reference values for area, velocity, etc. need to be defined. In the main Fluent window, Report-Reference Values. A window called Reference Values will open. The proper reference area to use is the planform area of the plate. Planform area is defined as the area seen from above, in this case L times b, where L is the plate length and b is the depth or span of the plate. Assume unit depth (b = 1.0 m) for convenience so that drag force is per unit depth. Depth should already be set to 1.0 m by default.
- Change Area to L times b, change Velocity to the freestream velocity of the flow, and change Length to L, the length of the flat plate.
- Unfortunately, the reference values for density and viscosity are those of air, the default fluid, even though we defined our working fluid as liquid water. (This is apparently a bug in Fluent.) Change Density and Viscosity to their proper values. (These values for liquid water were written down previously, but can also be found from Define-Materials, and selecting water-liquid under Fluid Materials.) All other reference values should be okay, so OK.
- In the main Fluent window, Report-Forces. In the window which pops up, the only available Wall Zone is flat-plate, which is the surface of the flat plate, so the default is okay. You will need to enter the components of the force vector, however. These are simply the x and y components of a unit vector pointing in the direction of the desired force. For example, setting the x-component to 1 and the y-component to 0 would cause Fluent to calculate the force acting on the wall in the x-direction. In our problem, we want drag force, which is defined as parallel to the freestream direction. Enter the appropriate x and y components so that the result is the drag force. Note that the calculated force will actually be in units of N/m since this is a 2-D problem (force per unit span).
- Click on Print to perform the calculation. The results will be printed to the main Fluent window. You may need to widen that window to see the entire length of the line. Notice that the force is broken into a pressure component and a viscous component. The pressure component is zero. Why?
- Write down the total drag force and drag coefficient. (Remember that this is the drag on one side (the top) of the plate, all the way to the end of the computational domain, i.e. from x = 0 m to x = 0.50 m.) Does the calculated drag coefficient at this Reynolds number agree with published data?
- To exit the Force Reports window, Close.
Save your calculations and exit Fluent:
- In the main Fluent window, File-Write-Case & Data. OK. It is okay to overwrite the files, so OK again.
- Exit Fluent by File-Exit. This will return you to the DOS shell.
Fluent - Turbulent Flat Plate Boundary Layer
Introduction and Instructions:
This learning module contains a procedure to solve for the turbulent boundary layer on a flat plate with the CFD program, Fluent.
Note: This set of instructions assumes that the student has already run Fluent for the laminar flat plate boundary layer, and has generated case and data files for the laminar case. The files laminar_bl.cas (or laminar_bl.cas.gz) and laminar_bl.dat (or laminar_bl.dat.gz) are assumed to exist on the user's Fluent directory.
It is assumed that the student is already logged on to a Unix computer, and that the Fluent directory is set as the working directory.
Launch Fluent and read the case file from the laminar boundary layer run:
- From the Fluent subdirectory, enter "fluent 2d &". After a few seconds, the main Fluent window should appear on your screen.
- Select File-Read-Case. There should be a file shown on the right side called laminar_bl.cas (or laminar_bl.cas.gz if the file was saved in compressed format), which is the case file for the laminar flat plate boundary layer. Highlight this file (i.e. click on it), and OK. Fluent will read in the grid geometry, mesh, and boundary conditions, etc. that were previously created by Gambit and Fluent. Some information is displayed on the main screen. If all is read well, it should give no errors, and the word "Done" should appear.
Define the model as turbulent:
- The default model is laminar, but we wish to run a turbulent case this time. Define-Models-Viscous- k-epsilon (2 eqn). Under Near Wall Treatment, select Two-Layer Zonal Model, which is Fluent's version of integration of a turbulent flow to the wall without wall functions.
- Click the Help button to read about the wall function options. In our case, we do not want to use any wall functions, since we have a grid that will be highly resolved near the wall. Close the Help Viewer window.
- In the Viscous Model window, OK to set the model and close the Viscous Model window.
Define the boundary conditions:
- Most of the boundary conditions from the laminar case are still valid, but we will specify a higher freestream velocity, and we need to specify some of the turbulence properties as well. In the main Fluent window, click on Define-Boundary Conditions - the Boundary Conditions window will pop up.
- Select the Zone called inlet, and Set. The "Velocity Specification Method" should be "Magnitude and Direction". The Velocity Magnitude should still be 2.0 m/s, and the direction to the right, as were set in the laminar case. Leave the freestream velocity at 2.0 m/s. This will enable us to directly compare a laminar and turbulent boundary layer at the same Reynolds number.
- Additional turbulence parameters, namely Turb. Kinetic Energy and Turb. Dissipation Rate now appear since we are using the k-epsilon turbulence model. We will assume a very low turbulence level in the freestream. Change Turb. Kinetic Energy to 1.E-02 m2/s2, and change Turb. Dissipation Rate to 1.E-02 m2/s3. OK.
- In like manner, select the Zone called outlet, and Set. Change Backflow Turb. Kinetic Energy to 1.E-02 m2/s2, and change Backflow Turb. Dissipation Rate to 1.E-02 m2/s3. OK. (This ensures that any backflow that comes into the computational domain has a low turbulence intensity as well.)
- The boundary condition for the top of the computational domain should be changed from pressure outlet to symmetry to produce better convergence. (For some unknown reason, the pressure outlet boundary condition at the top does not lead to a converged solution for this turbulent boundary layer). The symmetry boundary condition will make the top of the domain like the center of a channel, ensuring no flow through the top of the domain.
- Boundary conditions are complete, so Close the Boundary Conditions window.
Set up some parameters and initialize:
- The convergence criteria need to be checked. In the main Fluent window, Solve-Monitors-Residual. In the Residual Monitors window that pops up, make sure that both Print and Plot are on in the Options portion of the window. Here, Print refers to text printed in the main Fluent window, and Plot causes the code to plot the residuals on the screen while the code is iterating.
- There were three differential equations to be solved in the two-D incompressible laminar flow problem, and thus three residuals to be monitored for convergence: continuity, x-momentum, and y-momentum. With the k-epsilon turbulence model, there are five differential equations, and thus five residuals to be monitored. The default convergence criteria are 0.001 for the two new ones. There is no need to change any of these, since continuity usually has the highest residual, and it's convergence criterion was previously set to 1.E-06. OK to exit the Residual Monitors window.
- In the main Fluent window, Solve-Controls-Solution. Reduce the Under-Relaxation Factors for Turbulence Kinetic Energy and Turbulence Dissipation Rate by factors of 2 to ensure better convergence (the factors for pressure and momentum had already been reduced previously in the laminar flow solution, so these don't need to be changed here). OK.
- In the main Fluent window, Solve-Initialize-Initialize. Gage Pressure, X Velocity, and Y Velocity should be set to 0.0 pascal, 2.0 m/s, and 0.0 m/s respectively. Note that we will try to speed up convergence by setting the x-component of velocity to the freestream value everywhere, since the flow will be nearly equal to the freestream throughout most of the computational domain.
- In addition, we must initialize the turbulence properties. Scroll down and change Turbulence Kinetic Energy to 1.E-02 m2/s2, and change Turbulence Dissipation Rate to 1.E-02 m2/s3. Init and Close.
- At this point, and every so often, it is wise to save your work. In the main Fluent window, File-Write-Case & Data. In the Select File window which pops up, the default file name is laminar_bl.cas, which must be changed to something more descriptive of the turbulent flow case being calculated. ("turbulent_bl.cas" is suggested to distinguish this case from the laminar flat plate case already calculated). Note that Case & Data refers to both the case (the grid plus all boundary conditions and other specified parameters) and the data (the velocity and pressure fields calculated by the code. The code will actually write out two files, turbulent_bl.cas and turbulent_bl.dat.
- If not on by default, turn on the option to Write Binary Files (to save disk space). To save even more disk space, the files can be compressed by adding a "gz" at the end of the file name, if not already present. The complete file name should be "turbulent_bl.cas.gz". OK to write the file onto your directory.
Iterate towards a solution:
- In the main Fluent window, Solve-Iterate to open up the Iterate window. The turbulent case will converge more slowly than did the laminar case. Change Number of Iterations to about 600. Iterate. The main screen will list the residuals after every iteration, while the graphical display window will plot the residuals as a function of iteration number. The residuals may rise and fall as the code seeks a solution, but should slowly start to fall. Do not be concerned if there are reverse flow warnings; these will disappear in time. Also, do not worry about messages concerning the turbulent viscosity limit, which occur because velocity gradients are so small in the freestream portion of the flow.
- At the end of these iterations, check to see how the solution is progressing. In the main Fluent window, Display-Velocity Vectors-Display. The graphical display window will show the velocity vectors. Zoom in with the middle mouse, as described above, to view the velocity field in more detail if desired. In particular, view the boundary layer near the end of the plate. Is it starting to look like a turbulent boundary layer profile?
- Iterate some more if necessary. (To restart the iteration, either find the Iterate window, which is probably hidden under some other windows at this point, or click again on Solve-Iterate to re-open the Iterate window.) Iterate.
- Check the velocity vectors, as described above after another 500 or 600 iterations. It is wise to move the Iterate window someplace out of the way of the other windows so you can easily restart the iteration. The residuals may go up sometimes. This is normal, as the code attempts to zero in on a solution - after a while the residuals should again decay or level off. If the residuals all go below the convergence criteria, the calculations will stop. In most cases, however, the residuals reach a lower limit, and further iterations don't improve the solution.
- 1000 iterations should be sufficient for the first attempt. Before iterating further, we will examine the boundary layer profiles more closely.
Examine the velocity profiles in detail:
- At this point, the velocity profiles at three desired downstream locations (x = 0.10 m, x = 0.30 m, and x = 0.50 m) will be plotted and examined in detail, as was done previously in the laminar flow case.
- In the main Fluent window, select Plot-XY Plot. In the Solution XY Plot window, at the lower right corner, select (highlight) the three surfaces where the boundary layer profiles will be compared, i.e. profile0.10, profile0.30, and outlet.
- In the upper left corner of the window, turn off Position on X Axis, and turn on Position on Y Axis. This will make the y-axis the y position on the plot, as desired.
- In the upper middle part of that window, set Plot Direction to X = 0 and Y = 1. This will make the y-coordinate position appear on the y-axis, as desired for a standard velocity profile plot.
- The upper right part of the window selects the variable to be plotted. The Y Axis Function will be set automatically to Position, and should be left alone. For the X Axis Function, select Velocity and X-Velocity. Plot.
- The axes limits can be changed as follows: Axes. Choose X if necessary (X should already be the default). Unselect Auto Range. Set the range from 0 to 2.2 m/s. Select Major Rules. Apply.
- Now choose the Y axis. Unselect Auto Range and select Major Rules for this axis as well. Set the range from 0 to around 0.01 m or so, such that the entire boundary layer will be visible on the plot.
- To make the scale more readable, change the Number Format to Type = Float and Precision = 3. Apply.
- Back in the Solution XY Plot window, Plot. Adjust the axes and/or number format as desired to obtain a nice plot of the three boundary layer profiles.
Iterate towards a final solution:
- At this point, the boundary layer should be reasonable, but more grid refinement and iteration may be required. If there are less than about 10 data points within the thickness of any of the three boundary layers, the grid should be refined again.
- Refine the grid and re-iterate as necessary to obtain a final solution. See the laminar flow learning module for details about how to adapt the grid. You may adapt either by the gradient method or by the boundary method.
- Iterate for several hundred iterations after each grid adaption. The residuals will rise dramatically after an adaption, but will decay as the solution adjusts itself to the newly refined grid.
- After refinement and iteration, look again at the velocity profiles (Plot-XY Plot-Plot from the main Fluent window, or simply Plot if the Solution XY Plot window is still available on the screen).
Save your velocity profile and your calculations:
- In the main Fluent window, File-Write-Case & Data. In the Select File window which pops up, the default file name should be "turbulent_bl.cas.gz", as previously entered. OK to write the file onto your directory. OK again since it is okay to overwrite these files.
- From the Solution X-Y Plot window, Plot. When the plot is to your liking, the plot of the boundary layer profile will be saved. In the main Fluent window, File-Hardcopy-Save, name the file (something like "turbulent_profiles.ps" is appropriate), OK, and Close. The postscript file generated can be printed out from the Unix shell later.
- The data points along the x = 0.50 m line (the outlet) will now be saved to an ASCII file for further analysis and comparison to predictions. From the Solution XY Plot window, select only the outlet line. Write to File, and Write. Name the file something ("turbulent_profile.txt" is suggested) and OK.
- Finally, save a plot of the residuals. In the main Fluent window, Plot-Residuals-Plot. Then, File-Hardcopy. It is suggested that Coloring be changed to Monochrome since the printer prints in black and white only. Save, name the file (something like "turbulent_residuals.ps" is appropriate), OK, and Close.
Calculate the drag force and drag coefficient on the body:
- Follow the directions for calculating drag and drag coefficient from the laminar flow learning module.
- Record the drag and drag coefficient for this turbulent case. The drag coefficient will be compared to empirical equations obtained from the literature.
Examine the turbulent kinetic energy (k) profile in detail:
NOTE: ME 83 students - This portion is not necessary for your lab. Include it only if you have time.
- Go to the Solution XY Plot window if it is still visible on the screen. (If not, re-open it: in the main Fluent window, select Plot-XY Plot.)
- Change the X Axis Function to Turbulence and Turbulent Kinetic Energy. Plot.
- Adjust the axes limits as necessary to create nice-looking profiles: Axes. Choose X. Set the Maximum Range to something that will yield a nice k profile. Apply. The Y axis limits and other parameters should be okay as set previously.
- Back in the Solution XY Plot window, Plot. Adjust the axes and/or number format as desired to obtain a nice plot of the turbulent kinetic energy profiles at the three x locations.
- NOTE: Turbulent kinetic energy must go to zero at the wall, due to the no-slip condition at the wall. If the solution is converged well enough, with good enough grid resolution near the wall, the turbulent kinetic energy should drop off towards zero very near the wall. If it does not, but rather starts off at some high value and decays from there, your grid is probably not refined enough. Adapt the grid and iterate further as needed until k approaches zero near the wall.
- When the plot is to your liking, the plot of turbulent kinetic energy profiles will be saved. In the main Fluent window, File-Hardcopy-Save, name the file (something like "tke_bl.ps" is appropriate), OK, and Close. The postscript file generated can be printed out from the Unix shell later.
- The data points along the outlet (x = 0.50 m) line will now be saved to an ASCII file for further analysis and comparison to predictions. From the Solution XY Plot window, select only the outlet line. Write to File, and Write. Name the file something ("tke_bl.txt" is suggested) and OK.
- If you had to do some more grid adaption and iteration, re-plot and re-save the velocity profiles as well.
Save your calculations and exit Fluent:
- In the main Fluent window, File-Write-Case & Data-OK. It is okay to overwrite the files. OK.
- Exit Fluent by File-Exit. This will return you to the Unix shell.
- To logout completely from the computer, in the Global window on the upper left of the screen, Choose Desktop-Log Out, and answer Yes.
No comments:
Post a Comment