Computational fluid dynamic is the tool of choice when dealing with anything involving motion, air, and water. CFD enables highly accurate fluid flow simulations. Unfortunately, this comes at the cost of increase computation requirements. CFD is a low cost alternative to wind-tunnel aircraft testing or captive testing for boats and submarines. It is used in aircraft like the Eurofighter and the B-2 bomber, as well as countless other applications for internal or external fluid flows.
In this article we’ll look at creating a simple aerodynamic simulation. The goal is to demystify the CFD analysis and show that it’s not to difficult to get started. The links for the models and simulations are at the end of the article.
CFD Basics
In Computational Fluid Dynamics, we break up a volume of fluid that we want to study into tiny parcels and then analyze these parcels using a set of equations called the Navier-Stokes equations. These equations adjust the velocity, pressure, and other parameters to ensure that momentum is conserved throughout the entire simulated fluid field.
To perform this analysis we need two parts. First, we need the shape of the fluid volume that we are simulating. We will use the Onshape cloud software so that you can go in and examine the model yourself. The second thing that we need is a program to perform the analysis. For that we will use Simscale as it is a cloud-hosted tool that is based on the popular OpenFoam software package. I’ve used the OpenFoam software for analysis in the past, but Simscale allows me to share the simulations with you with an easy-to-understand graphical interface.
For our airfoil simulation the results that we want from the simulation is how the shape of the airfoil affects the pressure distribution of the air that is moving around it. This pressure data is used to calculate the aerodynamic forces that the airfoil generates.
Airfoil Creation in Onshape
Once we open up a new Onshore project, we need to make a sketch on the plane that we would like to draw the airfoil profile. This sketch must have two points that we use as the leading and trailing edges.
To create an airfoil in Onshape you can use a custom airfoil generation tool. We can use the NACA airfoil tab to enter our desired parameters. For this example I am using a NACA 2412 airfoil. The popular Cessna 172 aircraft uses this airfoil. Next we select the plane of the sketch as well as the two points.
Creating a CFD Volume for the Airfoil
When we create a CFD volume for an airfoil, we must ensure that we provide enough space at the front and rear of the body to prevent the walls from distorting the far-field effects. Imagine that you are designing a custom-sized wind-tunnel test section and you want to minimize any flow effects that do not result solely from the body in the test section. You would then increase the size of the tunnel as much as possible. I am using a 140x160x300 volume, it’s a little smaller than you would usually want to go for an airfoil simulation, but for this example I’m ok with sacrificing fidelity for expediency. For wing designs, typically the flow volume should be 10x the chord length in all directions.
First we import a previously-generated airfoil profile. Next we can create our volume. I like to do a forward sketch, and then use the test body as a Boolean tool to cut out a shape from the fluid volume, but for a simple infinite wing airfoil we can just use the extrude tool to make a cut through the entire volume. We start by creating a rectangle for half of the wing that we would like to simulate.
Next we can extrude our fluid volume.
Finally we cut the wing section into the volume.
This is the base STL file that we will use for our CFD simulation.
SimScale Wing Simulation
The SimScale cloud CFD software is a convenient graphically-oriented wrapper for the OpenFOAM software. When we import our volume into SimScale we can name the boundary regions for easier assignments later. Lets call the surface that represents the airfoil “airfoil”, the surface upstream of the airfoil the “inlet” and the surface behind the airfoil the “outlet”. Everything else can be designated as a wall.
Next we set the simulation type to “incompressible” as we are dealing with subsonic flows, and we use the “k-omega-sst” turbulence model. As we just want to get a characteristic of the airfoils themselves at set operating points for angle of attack, we will use a steady-state solver.
Now, we add a new volume to our air materials to form the simulation region.
After setting the initial conditions to 0, we need to define the inlet and outlet boundaries. First we set the velocity inlet with the vector components that correspond to the angle of attack that we wish to test. For the screenshot below I’m testing a 60m/s flow velocity at a approximately 10 degrees angle of attack.
For the simulation to converge to a useful solution, we need to have both a velocity inlet boundary condition and a pressure outlet boundary condition. As we set the inlet face to be out velocity condition, we therefore set our outlet face to be the pressure boundary condition.
For the airfoil surface interface, we use a wall with a no-slip boundary condition. The no-slip condition specifies that the velocity at the surface is 0. This represents the condition in the boundary layer of a surface moving through a fluid (or vice versa) where the relative flow speed decreases the closer that you get to the solid surface.
Finally for the edges of the flow field we can use the symmetry condition.
Now we can set our simulation control to the desired time step and specify the frequency for saving the simulation data. You don’t have to save a datapoint at each timestep, and generally you shouldn’t as you can use a high temporal resolution simulation without requiring a lot of space to store the results.
Results
This is an image from a SimScale airfoil simulation around an airfoil. The color shows the velocity, with red being fast and blue representing a slower flow. At the leading and trailing edge of the airfoil, we can see the stagnation areas of lower flow speed, and along the upper surface of the airfoil we can see the increased speed of the flow.
Next we’re going to look at the pressure graph for the wing. From Bernoulli’s Principle we can deduce that there will be a lower pressure in the areas that have a faster airflow and a higher pressure in the areas that have a slower airflow. Looking at the velocity analysis above, it would seem that the pressure is lower above the wing and higher below the wing.
Pressure is usually the area of interest for airfoil analysis as the pressure around the wing determines its lifting forces and pitching moments. Integrating the pressure forces acting on the surface of the wing gives us aerodynamic forces including lift and drag.
This pressure graph shows that lift is generated from the low-pressure zone above the airfoil’s top surface. We can also see the small area of high pressure at the stagnation point.
The stagnation point is the point where the air isn’t angled enough to be deflected above or below the airfoil. It stops like it has hit a wall. When this happens all of the kinetic energy of the moving air is converted to a pressure rise.
At -10 degrees AOA we can see the stagnation point move up on the leading edge, we also don’t see the large pressure drop at the top of the wing as with the 0 AOA case.
At -5 AOA we start to see some lower pressure on the upper surface of the wing.
At 5 degrees AOA, we can see the negative pressure field above the wing increases even more.
At 10 degrees AOA we can see a larger low pressure area above the wing, It may not look like much, but if you look at how the color scale shifted we can see how much greater than the 5 degree AOA case the negative pressure area is.
Now we can look at some of the numerical plots that give us an idea of how well our simulation quality is. Looking at the Convergence plots and residuals shows us the stability of our simulation, and how long it takes to reach a usable solution. First we can look at a convergence plot for the flow domain.
We can see that after around 500s it has reached the steady-state condition, which was the goal of our simulation. Next we can look at our residuals. The residuals are a measure of how unbalanced the conservation equations are. High residuals indicate that the simulation results are likely incorrect as they contain large internal numerical inconsistencies. The Low residuals show a stable low-error solution.
We notice that the residuals keep decreasing and some of them appear to reach and oscillate around a steady state (\(Uz\) in green) This means that the simulation has found its solution and is simply bouncing around a minimum point. If you notice the y-axis is a log scale, so the errors are very small. I’m not sure how much more information we gained in the last 300s of the simulation. Therefore if we are running this model again for a finer set of AOA condition’s we can reduce the run time to around 600s.
Improvements
To fully characterize an airfoil section we need to use more than just 5 test points for angle of attack. Maybe every degree or 1/2 degree all the way up to and slightly beyond the stall point would be a good idea. There are other software packages that can do this for us (XFLR5 has a good panel code implementation). Another thing that we can do is to simulate the entire wing and not just a small cross-section of it. This would give us more of an idea of how the actual wing will behave as it can simulate tip vortices and span-wise flow.
Conclusion
I know that this was kind of a long post, but hopefully It gives you an idea about how fluid simulations work and a little bit of intuition behind them. There is a little bit of black magic to these simulations, it’s half art, half science, but I hope that this inspires you to try your own experiments!
The Simscale simulations are available publicly for people to view, and extend/experiment with. Link: Simscale C172
I also have the link to the OnShape Document Here