SU2 Analysis Interface Module (AIM)
SU2 Analysis Interface Module (AIM) based on FUN3D AIM
SU2 AIM Example

Table of Contents

This is a walkthrough for using SU2 AIM to analyze and three-dimensional two-wing configuration.

Prerequisites

It is presumed that ESP and CAPS have been already installed. In addition, appropriate meshing and analysis packages were available for CAPS to link them to the corresponding AIMS.

In this example, TetGen is used for volume mesh generation, and SU2 is used for flow analysis. During the CAPS/pyCAPS build process, the location of TetGen source code needs to be set in ESPenv.sh to build TetGen AIM.

Script files

Two scripts are used for this illustration:

  1. cfdMultiBody.csm: Creates geometry, as described in [Part 1] of the next section
  2. su2_and_Tetgen_PyTest.py: pyCAPS script for performing analysis, as described in the [Part 2] of the next section.

pyCAPS walkthrough using SU2

This is a two-part process. The first part consists of creating a geometry model. The second part is setting the AIMs that uses this geometry model to perform desired analysis. In this walkthrough, the geometry model is created using ESP script and setup for AIMs is done using pyCAPS.

Part 1: Creating Geometry using ESP

Step 1: Setting up the CAPS Fidelity is the first step. This is required to provide CAPS information about all the geometries models available for analysis. In this example, the geometry model generated can be used for CFD analysis as shown:

attribute capsIntent CFD

Step 2: A typical geometry model can be created and interactively modified using design parameters. These design parameters are either design-variable based, or geometry-variables based. In this example a two-wing configuration is created using following design parameters.

despmtr series[1,1] 8412.00000
despmtr series2[1,1] 20.00000
despmtr area[1,1] 40.00000
despmtr aspect[1,1] 5.00000
despmtr taper[1,1] 0.50000
despmtr twist[1,1] 15.00000
despmtr lesweep[1,1] 30.00000
despmtr dihedral[1,1] 1.00000

3: Set CAPS internal attributes

# Set reference values
attribute capsReferenceArea area
attribute capsReferenceChord sqrt(area/aspect)
attribute capsReferenceSpan sqrt(area/aspect)*aspect

Step 4: Local analytical formulation for geometry creation

set cmean sqrt(area/aspect)
set span cmean*aspect
set sspan span/2
set croot 2*cmean/(1+taper)
set ctip croot*taper
set xtip sspan*tand(lesweep)
set ytip sspan*tand(dihedral)
set ybot -0.1*croot
set ytop +0.2*croot+ytip
set extend 0.02*cmean

Step 5: Building solid model. Once all design and locale variables are defined, a half span, solid model is created by "ruling" together to NACA series airfoils (following a series of scales, rotations, and translations).

mark
udprim naca Series series
scale croot
udprim naca Series series2
scale ctip
rotatez -twist 0 0
translate xtip ytip -sspan
rule 0

A full span model is then created by mirroring and joining the half-span model.

# Store half of wing
store HalfWing 0 0
# Restore the half wing
restore HalfWing 0
# Restore and mirror the half wing
restore HalfWing 0
mirror 0 0 1 0
# Combine halfs into a whole
join 0

Once the desired model obtained it needs to be rotated so that it is in the expected aero-coordinated system (y- out the right wing, x- in the flow direction, and +z- up).

# Get body into a typical aero-system
rotatex 90 0 0

Step 6: An attribute is then placed in the geometry so that the geometry components may be reference by the SU2 AIM

# Store the wing
store Wing 0 0
# Wing 1 - Restore
restore Wing 0
attribute capsGroup $Wing1

Next a second wing is created and scaled using the store/restore operations.

# Wing 2 - Restore and scale, translate
restore Wing 0
attribute capsGroup $Wing2
scale 0.4
translate 10 0 0

Step 7: For three-dimensional CFD analysis with the FUN3D AIM a "farfield" or "bounding box" boundary need to be also provided. In this example a simple sphere is created, and designated as such using the capsGroup attribute.

sphere 0 0 0 80
attribute capsGroup $Farfield

Step 8: Close the ESP script

end

Part 2: Performing analysis using CAPS/pyCAPS

Step 1: Import (py)CAPS environment.

from __future__ import print_function
# Import pyCAPS class file
try:
import pyCAPS
except:
print ("Unable to import pyCAPS module")
raise SystemError
# Import os module
try:
import os
except:
print ("Unable to import os module")
raise SystemError
# Import SU2 python environment
from parallel_computation import parallel_computation as su2Run

Step 2: Initialize

myProblem = pyCAPS.capsProblem()

Step 3: Load the geometry

myProblem.loadCAPS("./csmData/cfdMultiBody.csm")

Step 4: Extract the geometry model specific to the desired analysis

myProblem.capsIntent = "CFD"

Step 5: Make a list of design parameters available to interact with geometry model

# Change a design parameter - area in the geometry
myProblem.geometry.setGeometryVal("area", 50)

Step 6: Load required AIMS. A typical high-fidelity CFD analysis requires mesh AIMs and an analysis AIM. For surface meshing, the face tessellation from ESP geometry can be directly used as a surface mesh. If the face tessellation is not satisfactory, an additional step of using surface AIM for external surface mesh generator will be required. Here, the face tessellation is used as surface mesh. For volume mesh generation, TetGen is used. For this, TetGen AIM is used.

myMesh = myProblem.loadAIM(aim = "tetgenAIM", analysisDir= ".")

Provide appropriate inputs to mesh generator required to generate mesh with adequate mesh quality and any additional features, such as boundary layer and local refinement. Refer TetGen AIM documentation for the list of all the available options.

# Set new EGADS body tessellation parameters
myMesh.setAnalysisVal("Tess_Params", [.05, 0.01, 20.0])
# Preserve surface mesh while meshing
myMesh.setAnalysisVal("Preserve_Surf_Mesh", True)

After options are set aimPreAnalysis needs to be executed:

myMesh.aimPreAnalysis()

Load and SU2 AIM and link it to TetGen AIM as a parent. This step is required so that the volume mesh generated by TetGen AIM can be used for SU2 analysis. This step allows the volume mesh generated by TetGen AIM to be converted into SU2 native format.

# Load SU2 aim - child of Tetgen AIM
su2 = myProblem.loadAIM(aim = "su2AIM",
altName = "su2",
analysisDir = "SU2TetgenAnalysisTest", parents = ["tetgenAIM"])

Set analysis parameters specific to SU2. These parameters are automatically converted into SU2 specific format and transferred into the SU2 configuration file. See AIM Inputs for the available options.

# Set SU2 Version
su2.setAnalysisVal("SU2_Version","Raven")
projectName = "pyCAPS_SU2_Tetgen"
# Set project name
su2.setAnalysisVal("Proj_Name", projectName)
# Set AoA number
su2.setAnalysisVal("Alpha", 1.0)
# Set Mach number
su2.setAnalysisVal("Mach", 0.5901)
# Set equation type
su2.setAnalysisVal("Equation_Type","Compressible")
# Set number of iterations
su2.setAnalysisVal("Num_Iter",10)

Set the boundary conditions using attribution. These boundary tags and associated boundary conditions are converted into SU2 specific boundary conditions and set in the SU2 configuration file.

inviscidBC1 = {"bcType" : "Inviscid"}
inviscidBC2 = {"bcType" : "Inviscid"}
su2.setAnalysisVal("Boundary_Condition", [("Wing1", inviscidBC1),
("Wing2", inviscidBC2),
("Farfield","farfield")])

After all desired options are set aimPreAnalysis needs to be executed.

su2.aimPreAnalysis()

Execute SU2 flow solver. Here the python module for parallel computation is used. The configuration file (and the corresponding mesh file) is provided automatically for executing SU2. The number of processors can be set by user, depending on the available computational resources.

print ("\n\nRunning SU2......")
currentDirectory = os.getcwd() # Get our current working directory
os.chdir(su2.analysisDir) # Move into test directory
numberProc = 4;
su2Run(projectName + ".cfg", numberProc) # Run SU2
os.chdir(currentDirectory) # Move back to top directory

Perform post analysis task, such as parsing the final values from SU2 execution.

su2.aimPostAnalysis()

Step 7: Print the post analysis values.

# Get force results
print ("Total Force - Pressure + Viscous")
# Get Lift and Drag coefficients
print ("Cl = " , su2.getAnalysisOutVal("CLtot"), \
"Cd = " , su2.getAnalysisOutVal("CDtot"))
# Get Cmx, Cmy, and Cmz coefficients
print ("Cmx = " , su2.getAnalysisOutVal("CMXtot"), \
"Cmy = " , su2.getAnalysisOutVal("CMYtot"), \
"Cmz = " , su2.getAnalysisOutVal("CMZtot"))
# Get Cx, Cy, Cz coefficients
print ("Cx = " , su2.getAnalysisOutVal("CXtot"), \
"Cy = " , su2.getAnalysisOutVal("CYtot"), \
"Cz = " , su2.getAnalysisOutVal("CZtot"))

Step 8: Close the script upon normal termination.

myProblem.closeCAPS()

Executing pyCAPS script

Issuing the following command executes the script:

python su2_and_Tetgen_PyTest.py