Introduction to ANSYS CFD
How to get started with Computational Fluid Dyamics on ANSYS
In this tutorial we will learn how to simulate flows over bodies using ANSYS CFX fluid modeling. ANSYS also has fluent fluid flow modelling, but CFX is better for aerodynamic properties so that is what we will focus on and use throughout our design process.
The time estimate for this tutorial is 2-2.5 hours, but it could take longer. It is recommended to split up the work over a few days. If you are stuck, please reach out to an airframe director or project lead for assistance.
This tutorial requires a little bit of background knowledge; please make sure that you are familiar with basic aerodynamic principles, have basic SOLIDWORKS training, and have installed ANSYS on your system. If you have not done any of these, please check out the respective link(s) below:
Simulation 1: Flow Over a Cylinder
Creating a Model with SOLIDWORKS
Again, I assuming that you have basic knowledge of how to use SOLIDWORKS to make this first model. Since this tutorial is not about SOLIDWORKS but CFD, I'll go quickly over creating the model that will be used in the first simulation.
Open SOLIDWORKS and create a new part file.
Create a 1m diameter cylinder in the front plane with a length of 1m, shown in Figure 1.
Figure 1: The cylinder we will be simulating flow over
- Next Create a large square in the right plane that will completely encompass the cylinder, leaving plenty of room on the sides as shown in Figure 2.
Figure 2: A square large enough to fit around the cylinder
- Extrude the square to make a rectangular prism, leaving plenty of space between the faces of the prism and the cylinder as shown in Figure 3. Make sure that you uncheck "Merge Result" under the "Direction 1" tab.
Figure 3: The extruded rectangular prism
- Go to Insert > Features > Combine. Select subtract and expand the "Solid Bodies" tab in the feature tree. Select the rectangle as the main body and cylinder as the body to subtract and click the green check mark.
Figure 4: Subtracting the cylinder from the prism
- Your model should now like look Figure 5 on the inside. Save the file as ACIS (.sat) so that it can be used in ANSYS.
Figure 5: Cross-section of the completed model
Working with ANSYS
Search "Workbench 19.1" on your computer and run the program.
On the left side of the window you will see a number of options. Under "Analysis Systems" find "Fluid Flow (CFX)" and drag it into the workspace. Double click on "Geometry" (#2) in the window that appears.
In the new window that opens, go to File > Open and select the model that you made in SOLIDWORKS. You may have to specify that you are searching for a .sat file. The model should appear in the window like in Figure 6. Save the file and close the window.
Figure 6: The imported model you made earlier
Select the "Mesh" (3) option in the workspace from earlier. A new window will open like in the geometry step.
In this new window, find the project tree on the left. Expand the tree and find the "Mesh setting". Right click it and hit "Generate Mesh". A cool design will now appear on your model, just like in Figure 7.
Figure 7: The generated mesh on our model.
Save the project, close the window, and return to the main workspace.
Right Click on the "Mesh" tab and select "Update". A green check should appear where the lightning bolt previously was.
Double Click the "Setup" (4) tab in the workspace. A new window will appear like the other two steps.
On the tree in the left side of the window, double click Simulation > Flow Analysis 1 > Default Domain.
Figure 8: The Simulation Tree
Set the fluid as "Air at 25 C" and select "Fluid 1". Then hit "Apply" and "Close", both at the bottom of the left panel.
Right click on "Default Domain" then go to Insert > Boundary. Name the boundary as "Inlet". In the window that appears, find the location drop down menu and select the front end of the rectangle. Make sure that the Boundary Type is listed as "Inlet". Then click on the "Boundary Details" tab and under "Mass and Momentum" set the speed to 5 m/s and hit "Apply". Your geometry should look like Figure 9. Click "Close" at the bottom of the window.
Figure 9: The geometry with a selected inlet
Repeat what you just did by right clicking on "Default Domain" again and inserting another boundary layer. Name this one "Outlet" and select the face opposite the inlet, again making sure that the Boundary Type is listed as "Outlet". Then click on the "Boundary Details" tab and set the relative pressure to 5 Pa. Hit "Apply" and close the left side window.
This time, right click "Default Domain Default" underneath "Default Domain" and hit "Edit". The location field should automatically populate with the rest of the other faces of the cube and the cylinder. Select only the remaining faces of the cube and NOT the cylinder. Make sure the Boundary Type is set to "Wall" and hit apply. When you return to the main screen, rename the Boundary you just defined as "Wall". Right click it and select "Rename" at the bottom.
Another "Default Domain Default" will appear with the surfaces of the cylinder of selected. Rename the domain as "Cylinder" and double check that the boundary type is "Wall". Your geometry should now look like Figure 10.
Figure 10: The completed boundary geometry
Close out of the big window and return to the Workbench. There should now be a green check next to "Setup". Double click on "Solution" (5) to open the solution executable. Your Firewall may give you warning- just allow access.
A new window will appear. Select the name of your machine (most likely the only one listed) and hit "Start Run". After a few seconds, two panels will appear in the window. The left one will be a graph with several lines, and the right will have tables of numerical values. Let the simulation run until a pop-up window appears saying the solution has completed normally; your screen should look similar to Figure 11. If you get an error, make sure you go back and check that you followed all of the steps. If you're still having issues, send Tom a message on Slack or one of the airframe leads.
Figure 11: The solution to the CFD simulation
This time, leave the solution window open and return to the Workbench. Double-click on the "Results" (6) and allow access if your Firewall tries to block it.
In the new window, find the "Streamline" box at the top (Three over from "Location"). Give the streamlines a name (I just left mine as the default) and look at the box that appears in the bottom left corner. Under the "Start From" option select the inlet, choose "Rectangular Grid" for Sampling, and hit apply. Woah! You can see the streamlines around the cylinder! Your screen should look similar to Figure 12. I encourage you to mess around with the streamline settings to see what looks best to represent the flow and come up with some really cool designs. Save a screenshot of what you come up with so you can send it to Tom, David T or Eric.
Figure 12: Streamlines around the cylinder.
Play around with some of the other plotting tools, like vectors, contours, and particle tracks. You can hide and delete any of the different ones that you make underneath "User Locations and Plots" on the outline tree. Create at least one other plot and take a screenshot for later.
Another really cool thing you can do with ANSYS is animate the flow simulation. On the bar at the top of the screen, find the film track next to the clock. Select it and choose the streamline plot that you made and press the play button. You'll actually be able to see the particles move around the cylinder! I recommend a slower rate (around 650 frames) so that it's easy to see. You can even save the video by clicking on the drop-down arrow in the bottom right corner of the animation window.
Now under "Report" in the Outline tree, expand the "Physics Report" and select "Boundary Physics for CFX". If you go to the "Table View" tab at the bottom of the right panel, a spreadsheet appears with some data. Select an empty cell and go click "Function" next to "Insert" at the top of the panel. In the drop-down menu, go to CFD-Post > force_x. Then go to Location > Cylinder and hit enter. A force value will now appear in the spreadsheet, representing the force in the x-direction on the cylinder. Repeat the same process in another cell, except select force_y.
Figure 13: The calculated forces acting on the cylinder
- I'm going to assume that your geometry is oriented so that the flow is in the x-direction. Therefore, the force_x value calculated corresponds to the drag force and the force_y corresponds to the lift on the cylinder. We can now nondimensionalize these values and calculate lift and drag coefficients for a cylinder. These calculations are shown in Figure 14 (note the density of air at 25 C and sea level is 1.1839 kg/m^3).
Figure 14: Lift and Drag Coefficients for the cylinder
Quick discussion of the results: these values are actually pretty close to what we would expect. For a cylinder, theory predicts that the lift on a cylinder should be equal to 0. In this case, it's pretty close to 0 but not equal due to due to fluctuations in the flow. We do expect a drag force, however, due to a phenomenon known as boundary separation. This occurs because the velocity everywhere on the surface of the cylinder is zero in the case of the stationary cylinder in order to satisfy the no-slip boundary condition. Therefore, a boundary layer with low momentum develops on the surface on the cylinder to meet this criteria. Since the pressure decreases towards the top of the cylinder, the flow accelerates initially due to the Bernoulli equation, but then begins to slow down after reaching the top of the cylinder. Since the boundary layer does not have enough momentum to counter the increase in pressure, the flow separates from the cylinder and forms a viscous wake surrounded by a laminar boundary behind the cylinder, known as the von Karman vortex sheet. Inside the wake the pressure is lower than what the potential flow model would predict so a drag force is created on the cylinder while the lift is still zero unless circulation is present. In fact, about 90% of the drag on a cylinder is due to pressure while the other 10% is due to skin friction.
Congratulations, you just completed your first CFD simulation! Repeat the simulation with a flow velocity of 15 m/s and calculate the corresponding lift and drag coefficients. Send your results along with the two screenshots from before to Tom, David or Eric so we know you completed the first part of the tutorial.
When I wrote this tutorial, I had actually never used ANSYS CFD, only COMSOL. ANSYS is much more prevalent in industry and academia compared to COMSOL and since the overall mission of UAS to learn valuable skills for careers, we decided to use ANSYS. Therefore, I used a lot of online resources in order to figure out how this program works and the wonderful things it can do. Check out some of the videos I used as an outline for this tutorial if you get stuck. If you're still having problems after watching the videos, feel free to reach out to me (Tom) or any of the airframe directors and we'll help you out.
Simulation 2: Flow Over a Symmetric Wing
Now it's time to simulate the flow over a symmetric wing. For this one, we'll be using the NACA 0010 airfoil. NACA (National Advisory Committee for Aeronautics) is an advisory comittee (similar to IEEE) that eventually turned into NASA. The numbers in the airfoil represent physical characteristics of the airfoil and are used in formulas to determine the surface of the airfoil. For more specifics, see the Basic Aerodynamic Theory page.
The process of creating the points by hand is pretty tedious and requires a lot of plug and chug math. For this reason, I've written a program that takes the airfoil number and a few other parameters as input and generates a text file that can be imported into SOLIDWORKS or ANSYS to create the geometry for the simulation. If you would like, I have the source code on our Github which can cloned and built to run on your own machine. However, if you don't want to do this or don't know how you can also find the text files on the Google drive.
Creating The Model With SOLIDWORKS
Download or use the program to create a text file with the coordinates of the NACA 0010 airfoil. If you are using the program, I recommend selecting 100 x-coordinates and an open trailing edge.
In SOLIDWORKS, create a new part. Make sure that are in MKS (Meters, Kilograms, Seconds) mode. Then go to Insert > Curve > Curve Through XYZ Points. Browse your machine for the file and select "OK". The airfoil should appear in your screen like in Figure 15.
Figure 15: The Imported Airfoil Curve
- Right-click on "Front Plane" in the design tree and select "Sketch". Select the airfoil curve and select "Convert Entities". It's a good idea to click on the orginal curve and hide it from view so there's less on your screen. Then click on the airfoil and a new Property Manager window will appear. Right-click the exisiting relation and delete it, then click the green check mark.
Figure 16: Removing the edge constraints
Zoom into the trailing edge of the airfoil and connect the two points with a single line. The curve should now be filled in, showing that it is closed.
Now we're going to create the chord of the airfoil. Go to the line tool and select "Centerline". Draw the centerline from the midpoint of the trailing edge to a point near the leading edge, but not directly on the midpoint. Then create a tangent line that extends off of the airfoil. Press esc to drop the tool- your airfoil should look like Figure 17.
Figure 17: The center and tangent lines.
- Select the two lines, then choose "perpendicular". The centerline will then snap to the exact middle point of the trailing edge. Click on "Smart Dimension and change the length of the centerline to 1 meter. I recommend saving an additional copy of the file now so that it is easy to change the angle of attack when needed.
Figure 18: The 1 meter chord
- To change the angle of attack, go to "Tools" > "Sketch Tools" > "Rotate". Select the outer curve, centerline, perpendicular line, and the trailing edge as the bodies to rotate. Then select either the leading or trailing edge as the center of rotation. If you choose the leading edge, make sure your angle of rotation is negative. I chose 2 degrees to start and will use this throughout the rest of the tutorial.
Figure 19: Rotating the airfoil for an nonzero angle of attack.
- Exit the sketch and extrude the airfoil to make a wing. I used 2 meters for this tutorial.
Figure 20: Extruded Airfoil (wing)
- Similar to the cylinder, create a square around the wing and extrude it into a prism, leaving plenty of room on the sides, top/bottom, and trailing/leading edge. Then subtract the airfoil from the prism to create the flow geometry. Save the part as a ACIS (.sat) file. The model is now ready to be imported into ANSYS.
Working With ANSYS
The process for meshing and running the simulation is almost entirely the same as before. Therefore, these next few steps will be pretty concise because I assume that you have already finished the cylinded tutorial.
Open ANSYS Workbench and drag a new instance of Fluid Flow (CFX) onto the main workspace. Double-click on "Geometry" (2) and import the .sat file you just created. Save and close the window- there should now be a green check mark.
Double-click on "Mesh" (3) and wait for the window to appear. Similar to to before, right-click on mesh and click "Generate Mesh". The geometry should then look like Figure 21. Save and close the window. In the main workspace, right-click on mesh click "Update". After a few seconds, the check mark should turn green.
Figure 21: The meshing of the symmetric wing
- Double-click on "Setup" (4) and wait for the window to open. Following the same steps as with the cylinder, set up the flow to be air at 25 C, with a flow rate of 5 m/s and relative exit pressure of 5 Pa. Select the front face to be the inlet and rear face to be the outlet. Select the remaining 4 faces of the prism and create a wall boundary. Then, with the faces of the wing create another wall boundary and label it "Wing"- just use Default Default Domain. Your setup should look like Figure 22. Save the file and close the window.
Figure 22: The completed boundary setup
- Click on "Solution" (5) and run the simulation to completion just as you did for the cylinder. If you get an error, make sure you followed all the steps. If you're still having issues, check out the additional materials or contact one of the airframe leads.
Figure 23: Streamlines around a symmetric airfoil at a small angle of attack
- After the simulation is complete, double-click on "Results" (6) and play around with some of the plotting tools to make streamlines diagrams, vector fields, and animations. To calculate the lift and drag on the wing, go to "Physics Report" > "Boundary Physics for CFX" and use the same method as described for the cylinder to get the values of the forces. We can then nondimensionalize the values to get the lift and drag coeffcients with the formulas in Figure 24 below.
Figure 24: Lift and drag coefficients for a symmetric wing at a 2 degree angle of attack
- Discussion of the Results: What we expect for a symmetric airfoil is that the lift coefficient should be almost zero at no angle of attack and increase linearly until about 15 degrees where the coefficient will begin to drop due to stalling. In order to see this relationship, compute the lift and drag coefficients at angles of attack equal to 6 and 10 degrees. Plot the results of each along with the values you obtained for 2 degrees on separate graphs as a function of the angle of attack. Send the plot to one of the airframe leads when you are finished so we know you have completed the tutorial.
Here's a good video that I used to learn how to make a wing using a text file with coordinates. It may be helpful if you're having difficulty with the SOLIDWORKS portion. I suspect that the ANSYS meshing and boundary definition should not be too difficult.
Importing airfoil coordinates to Solidworks Skip to 2:00 since I have already created the text file with the coordinates
Simulation 3: Flow Over a Cambered Wing
This assignment doesn't have a tutorial. The process for a cambered wing is pretty much the exact same as a symmetric airfoil, just with different coordinates. Follow the exact same steps above with the coordinates for a NACA 4412 airfoil using the program I wrote or by downloading the textfile from the Google Drive.
Calculate the lift and drag coefficients for the NACA 4412 airfoil at angles of attack equal to 2, 6, and 10 degrees. Plot the values on separate graphs as a function of the angle of attack (in degrees) and send the graphs to one of the airframe leads when you are done.
Congratulations on finishing the tutorial! Let me (Tom) know if you have any questions, concerns, or thoughts about it. This is the first time we are doing something like this and I want to know whether it was helpful, confusing, too hard/easy, too long, etc. I'm open to all criticism so that we can successfully educate our club members to the best of our ability. If you have any questions, please reach out to me or an airframe lead.
Written 07/19/2018 by T. Kantner
Last Edit: 09/10/2018 by T. Kantner