AVL Analysis Interface Module (AIM)
AVL Analysis Interface Module (AIM)
AIM Examples

This example contains a set of *.csm and pyCAPS (*.py) inputs that uses the AVL AIM. A user should have knowledge on the generation of parametric geometry in Engineering Sketch Pad (ESP) before attempting to integrate with any AIM. Specifically, this example makes use of Design Parameters, Set Parameters, User Defined Primitive (UDP) and attributes in ESP.

The follow code details the process in a *.csm file that generates three airfoil sections to create a wing. Note to execute in serveCSM a dictionary file must be included "serveCSM -dict $ESP_ROOT/include/intent.dict avlDocExample1.csm"

First step is to define the analysis intent that the geometry is intended support.

attribute capsIntent LINEARAERO

Next we will define the design parameters to define the wing cross section and planform.

despmtr thick 0.12 frac of local chord
despmtr camber 0.04 frac of loacl chord
despmtr area 10.0 Planform area of the full span wing
despmtr aspect 6.00 Span^2/Area
despmtr taper 0.60 TipChord/RootChord
despmtr sweep 20.0 1/4 Chord Sweep
despmtr washout -5.00 deg (negative is down at tip)
despmtr dihedral 4.00 deg

The design parameters will then be used to set parameters for use internally to create geometry.

set span sqrt(aspect*area)
set croot 2*area/span/(1+taper)
set ctip croot*taper
set dxtip (croot-ctip)/4+span/2*tand(sweep)
set dztip span/2*tand(dihedral)

Finally, the airfoils are created using the User Defined Primitive (UDP) naca. The inputs used for this example to the UDP are Thickness and Camber. Cross sections are in the X-Y plane and are rotated to the X-Z plane. Reference quantities must exist on any body, otherwise AVL defaults to 1.0 for Area, Span, Chord and 0.0 for X,Y,Z moment References

# left tip
udprim naca Thickness thick Camber camber
attribute capsGroup $Wing
attribute capsReferenceArea area
attribute capsReferenceSpan span
attribute capsReferenceChord croot
attribute capsReferenceX croot/4
scale ctip
rotatex 90 0 0
rotatey washout 0 ctip/4
translate dxtip -span/2 dztip
# root
udprim naca Thickness thick Camber camber
attribute capsGroup $Wing
rotatex 90 0 0
scale croot
# right tip
udprim naca Thickness thick Camber camber
attribute capsGroup $Wing
scale ctip
rotatex 90 0 0
rotatey washout 0 ctip/4
translate dxtip span/2 dztip

An example pyCAPS script that uses the above csm file to run AVL is as follows.

First the pyCAPS and os module needs to be imported.

import pyCAPS
import os

Note if your Python major version is less than 3 (i.e. Python 2.7). The following statement should also be included so that print statements work correctly.

from __future__ import print_function

Once the modules have been loaded the problem needs to be initiated.

myProblem = pyCAPS.capsProblem()

Next the *.csm file is loaded and design parameter is changed - area in the geometry. Any despmtr from the avlWing.csm file is available inside the pyCAPS script. They are: thick, camber, area, aspect, taper, sweep, washout, dihedral...

myGeometry = myProblem.loadCAPS("./csmData/avlWing.csm")
myGeometry.setGeometryVal("area", 10.0)

The AVL AIM is then loaded with the capsIntent set to LINEARAERO (this is consistent with the intent specified above in the *.csm file.

myAnalysis = myProblem.loadAIM(aim = "avlAIM",
analysisDir = "AVLAnalysisTest",
capsIntent = "LINEARAERO")

After the AIM is loaded the Mach number and angle of attack are set, though all AIM Inputs are available.

myAnalysis.setAnalysisVal("Mach", 0.5)
myAnalysis.setAnalysisVal("Alpha", 1.0)
myAnalysis.setAnalysisVal("Beta", 0.0)
wing = {"groupName" : "Wing", # Notice Wing is the value for the capsGroup attribute
"numChord" : 8,
"spaceChord" : 1.0,
"numSpan" : 12,
"spaceSpan" : 1.0}
myAnalysis.setAnalysisVal("AVL_Surface", [("Wing", wing)])

Once all the inputs have been set, preAnalysis needs to be executed. During this operation, all the necessary files to run AVL are generated and placed in the analysis working directory (analysisDir)

myAnalysis.preAnalysis()

An OS system call is then made from Python to execute AVL.

print ("Running AVL")
currentDirectory = os.getcwd() # Get our current working directory
os.chdir(myAnalysis.analysisDir) # Move into test directory
os.system("avl caps < avlInput.txt > avlOutput.txt");
os.chdir(currentDirectory) # Move back to working directory

A call to postAnalysis is then made to check to see if AVL executed successfully and the expected files were generated.

myAnalysis.postAnalysis()

Similar to the AIM inputs, after the execution of AVL and postAnalysis any of the AIM's output variables (AIM Outputs) are readily available; for example,

print ("CXtot ", myAnalysis.getAnalysisOutVal("CXtot"))
print ("CYtot ", myAnalysis.getAnalysisOutVal("CYtot"))
print ("CZtot ", myAnalysis.getAnalysisOutVal("CZtot"))
print ("Cltot ", myAnalysis.getAnalysisOutVal("Cltot"))
print ("Cmtot ", myAnalysis.getAnalysisOutVal("Cmtot"))
print ("Cntot ", myAnalysis.getAnalysisOutVal("Cntot"))
print ("Cl'tot ", myAnalysis.getAnalysisOutVal("Cl'tot"))
print ("Cn'tot ", myAnalysis.getAnalysisOutVal("Cn'tot"))
print ("CLtot ", myAnalysis.getAnalysisOutVal("CLtot"))
print ("CDtot ", myAnalysis.getAnalysisOutVal("CDtot"))
print ("CDvis ", myAnalysis.getAnalysisOutVal("CDvis"))
print ("CLff ", myAnalysis.getAnalysisOutVal("CLff"))
print ("CYff ", myAnalysis.getAnalysisOutVal("CYff"))
print ("CDind ", myAnalysis.getAnalysisOutVal("CDind"))
print ("CDff ", myAnalysis.getAnalysisOutVal("CDff"))
print ("e ", myAnalysis.getAnalysisOutVal("e"))

results in

CXtot -0.00033
CYtot 1e-05
CZtot -0.30016
Cltot -0.0
Cmtot -0.19468
Cntot -1e-05
Cl'tot -0.0
Cn'tot -1e-05
CLtot 0.30011
CDtot 0.00557
CDvis 0.0
CLff 0.29968
CYff 0.0
CDind 0.00557
CDff 0.00492
e 0.9691

Additionally, besides making a call to the AIM outputs, sensitivity values may be obtained in the following manner,

sensitivity = myAnalysis.getSensitivity("Alpha", "CLtot")

The avlAIM supports the control surface modeling functionality inside AVL. Trailing edge control surfaces can be added to the above example by making use of the vlmControlName attribute (see AIM Attributes regarding the attribution specifics). To add a RightFlap and LeftFlap to the previous example *.csm file the naca UDP entries are augmented with the following attributes.

# left tip
udprim naca Thickness thick Camber camber
attribute vlmControl_LeftFlap 80 # Hinge line is at 80% of the chord
...
# root
udprim naca Thickness thick Camber camber
attribute vlmControl_LeftFlap 80 # Hinge line is at 80% of the chord
attribute vlmControl_RightFlap 80 # Hinge line is at 80% of the chord
...
# right tip
udprim naca Thickness thick Camber camber
attribute vlmControl_RightFlap 80 # Hinge line is at 80% of the chord
...

Note how the root airfoil contains two attributes for both the left and right flaps.

In the pyCAPS script the AIM Inputs, AVL_Control, must be defined.

flap = {"controlGain" : 0.5,
"deflectionAngle" : 10.0}
myAnalysis.setAnalysisVal("AVL_Control", [("LeftFlap", flap), ("RightFlap", flap)])

Notice how the information defined in the flap variable is assigned to the vlmControlName portion of the attributes added to the *.csm file.