You are on page 1of 9

UPDATED (2022) Instructions Two-Dimensional

Compressible Flow Solver Applet (CNSA)


User Guide

Ravi Srinivasan1
Joseph Schetz2 and Rodney Bowersox3
This software and user guide are supporting materials for the following AIAA publication:
Schetz, J.A. and Bowersox, R.D.W. 2011. Boundary-Layer Analysis, Second Edition. American
Institute of Aeronautics and Astronautics. Reston, VA 20191.

See Chapter 12 – specifically, Section 12.9 – of the above reference for a thorough technical
description of the computational methods employed by this software. This document serves
only as a procedural User Guide.

Introduction:
This software performs a two-dimensional, compressible Navier-Stokes airfoil (CNSA) simulation
for the flowfield around an arbitrary 4-digit NACA airfoil cross-section at user-specified angle of
attack, under a user-specified freestream condition (pressure, temperature, and Mach number).
The NACA airfoil geometry (thickness, camber, etc.) is determined uniquely from the 4-digit code
using the equations as described here:
http://en.wikipedia.org/wiki/NACA_airfoil
Typical geometries are the NACA 0012 (symmetric, 12% thick), and the 2412 (adds camber).
As the first step in the process, a grid generation routine (NACAGridGenerator) prepares a 2-D
elliptic grid around the airfoil, and a solver routine (solver or solver.exe) iteratively solves the
Navier–Stokes equations to produce field solutions for U and V velocities, pressure, temperature,
and Mach number. Output is produced in a format compatible with TecPlot visualization software.
A preconfigured TecPlot layout file is included for easy analysis, or the data can be imported and
processed in other software manually.
User control of both the grid-generation and solver routines is achieved through the use of text-
format input files. The sections below describe the parameters of these input files, and outline the
basic procedures required to begin using the software.

1 rcs@tamu.edu
2 ptiger@vt.edu
3 bowersox@tamu.edu
Requirements:
• Windows 7 or later running on 64-bit processors, or
• MacOS X or later, Linux, or Unix running on 64-bit processors
• A text editor for editing input files.
• TecPlot for viewing of output files.
• MATLAB v2019 or later (for MATLAB-based GUI)

Instructions:
Grid generation:
1) Open “gridinput.dat” from the “Grids” directory in any plain-text editor. Parameters
for the airfoil section geometry and elliptic grid generation solver are listed here, and
each is described in a comment following the “#” character. An example configuration
is depicted below:

2) Execute NACAGridGenerator from the same directory as gridinput.dat. On Windows,


NACAGridGenerator.exe can simply be double-clicked. On a Mac or Linux/UNIX
system, open a terminal window in the appropriate directory, type
“./NACAGridGenerator”, and press enter.

The grid generator routine will execute an iterative sequence to solve for the elliptic
distribution of grid points in the computational domain.

As output, the grid generator will create three files:

[basename]_algebraic.dat – A Tecplot data file of the algebraically-distributed


grid points used to initialize the iterative elliptic solver.

[basename]_elliptic.dat – A Tecplot data file of the final grid of elliptically-


distributed grid points.

[basename]_elliptic.xyz – A tabulated data file used as input to the flow solver in


the next step.
3) The grid file may be inspected in Tecplot using the preconfigured layout file called
“Grid Viewer.lay”. Open the layout file first in a plain-text editor, and edit the third
line to read the desired grid file, [basename]_elliptic.dat:

Now, open the layout file in Tecplot. A large grid shows the entire computational
domain, and an inset shows a close-up in the region of the airfoil. The grid
dimensions are normalized to the airfoil chord length (c = 1).
Pictured below is an elliptic grid for the NACA 2412:

4) To prepare for the flow solution procedure, copy the tabulated grid file,
“[basename]_elliptic.xyz”, to the “Runs” directory.

Flow solution:
5) Open “input.dat” from the “Runs” directory in any plain-text editor. Parameters for the
airfoil section geometry and elliptic grid generation solver are listed here, and each is
described in a comment following the “#” character. An example configuration is
depicted below (see figure on next page):

The first active line in input.dat should be updated to reflect the grid file from step 4.

The remaining lines are each described by their associated comments in the input deck.
Note, in particular, the freestream parameters (pressure, temperature, Mach
number, and angle-of-attack).
6) Execute Solver.
On Windows, Solver.exe can simply be double-clicked.
On a Mac or Linux/UNIX system, open a terminal window in the appropriate directory,
type “./solver”, and press enter.

The solver routine will execute an iterative sequence to solve for the flowfield in the
computational domain, according to the parameters in input.dat.

As the solver executes, pay attention to the evolution of the residual shown on the
scrolling output. For a stable, converged solution, the residuals should nominally
decrease until the desired convergence criterion (specified in input.dat, usually 1×10-6
or lower) is reached. If the solution first reaches the iteration limit (also specified in
input.dat), the solution in the output file may not be converged, and results may not be
physical.
As output, the solver will create one output file:

output.dat – A Tecplot data file of the flow parameters at each grid point. Points
are i, j-ordered and flow variables are in the following order:
• Density
• U Velocity
• V Velocity
• Pressure
• Temperature
• Mach number

7) The solution file may be inspected in Tecplot using the preconfigured layout file called
“Solution Viewer.lay”. Because the output file is always called “output.dat”, editing
the layout file is not necessary here, unless the name of the output file has been changed.
Open the layout file in Tecplot. The five frames show each of the flow variables as
contour maps on the computational domain, zoomed-in to a region close to the airfoil
cross-section. The grid dimensions are normalized to the airfoil chord length (c = 1).

Pictured below is an example solution for the NACA 2412 per the input file above:

Instructions for MATLAB based GUI for Using the CNSA Solver:

Alternatively, one may choose to run the CNSA Solver using a newly developed MATLAB based
GUI (developed by Sean Powers, swp@vt.edu). The instructional manual for this GUI is given
below to provide the user insight into how to use the MATLAB implementation of the
Compressible Navier-Stokes Applet (CNSA). This code does not change any of the original solver
code written in Fortran but allows the user to quickly obtain a solution and parse its data.

Getting Started:
Open the “Two_Dimensional_Compressible_Flow_Solver_Applet_CNSA.m” file and run it to
start the GUI. Figure 1 shows the GUI panel before running any solution. As stated previously,
this MATLAB implementation does not change any of the original Fortran source code. Instead,
MATLAB will command the code to run for you and will then post-process the data for you instead
of using applications such as Tecplot.
The code works by modifying both the “gridinput.dat” and “input.dat” data files with the
appropriate inputs. “gridinput.dat” is modified, saved, and then used to run
“NACA4D_GridGenerator_Windows.exe” application which generated the element grid around
which the flow will be solved. “input.dat” is then modified, saved, and used to run
“AFSolver_Windows.exe” which will iterate through to find a solution to the user input problem.

Figure 1. GUI window before running.

It is important to note that not all settings can be changed directly from the GUI. If the option that
the student wishes to change is not on the GUI the student can simply open one of the “.dat” files
and edit that setting. This will not break the code and will run the same. If multiple runs will be
completed in a row then simply hit the “Reset” button in between each run. Additional information
about the GUI will be described in detail below.

New Run:
If a new run is desired, then the user simply must click the “New Run?” button. The required
inputs will then turn from a grayed-out color to a bright white and will be clickable. The user will
then input the desired values into each box. All fields are required except for the “Fig Select:” and
“Fig Controls:” drop-down boxes (more on that later in this section”. Once the user is satisfied
with the inputs, they must click the green “calculate” button. The command window will then be
populated with the grid generator outputs quickly followed by the iterative flow solver outputs.
The command window will continue to update until either the max number of iterations has been
reached or the residual drops below the required value.
Once the flow solver has completed it will display a finished message in the command window.
The GUI will also display a figure containing the total velocity. Note that the code automatically
saves the file in a specific format. The first file is
“NACAnum_ConvergenceNum_RownumxColnum.dat”. The second file is labeled as
“NACAnum_ConvergenceNum_RownumxColnum.xyz”. Both files are used by the solver and
are not needed once the third and final file is created. This file is called
“NACAnum_ConvergenceNum_RownumxColnum.XYZ_M=Machnum_ALPHA_AoA_Flo
wType.dat”. This is the solution file and the one that MATLAB reads in to post-process the data.
This file type is also the one that will be used in the “Previous Run” section.
Figure 2 shows an example completed run. Figure 3 shows the controls that can be used with the
pictured contour. On the left is figure selection. If the user would like to see something other than
total velocity, one of the other six options can be selected and the figure shown in the GUI will
automatically be changed to the user’s selection.

Figure 2. Example output.

Figure 3. Figure controls.

On the right-hand side are figure controls. The first one is “Data Probe” which allows the user to
probe the data and look at specific points of data. Upon clicking a point in the figure this will bring
up its x and y coordinate as well as its “level”. Level refers to whatever value the color bar on the
far-right side is representing. The second option is “Zoom” which allows the user to use either the
scroll wheel to zoom in and out of the figure as well as click and drag a box around a specific area
of interest. Finally, the “Pan” function allows the user to click and drag the figure to inspect other
areas of the domain which are not seen by default. It should be noted that these features also work
when using the “Previous Run” feature.
Previous Run:
If the “Previous Run?” button is pressed then only a few of the inputs become clickable. A
completed previous run can be seen in Figure 4. The user must enter the file path that leads to the
“.dat” solution file. This includes the solution file name itself. An example would be,
“C:\Users\username\OneDrive\BL Navier-Stokes Solver\Processed Data\NACA 0040 --- M
= 0.25---AoA=5---Chord=1--TURBULENT\NACA0040_1E4_225x66.XYZ_M=0.250000
_ALPHA_5_TURBULENT.dat”. Once the link is input into the GUI the user must input the
chord length, total row number, and total column number. Then the user clicks the green calculate
button and the GUI will display the data related to that solution file. Again, an example output of
this is seen in Figure 4. “Fig Select:” and “Fig Controls:” operate the same as in a new run.

Figure 4. Previous run solution.

Code Needed for Extension:


Users will need to alter their code to do more in-depth processing. To start this, data from the GUI
code can be used to import the 7 different data sets in as matrices for manipulation. To do this,
first, complete the runs using the GUI and save the solution files. Then look at the “.m” file for the
GUI and go to line 650. The first if statement (line 651) looks to see if the code is a previous run.
In post-processing, this will always be the case. Therefore, copy the code from line 654 to 664 and
paste it into a new “.m” file that you intend to do post-processing in. Change the left-hand side of
these variables to the specific values for the solution file that you want to work with. Currently,
they are set to grab the values from the GUI so you should just hard set these values. Skip to line
795 and copy line 795 down to line 864. This piece of the code will give you the seven different
outputs from the original solver. Note that total velocity is calculated from the u-velocity and v-
velocity. This set of code will allow the user to plot contours of each output and continue post-
processing as they see fit. An example of plotting a contour can be seen in lines 869 to 884.

You might also like