AeroProblem

class baseclasses.AeroProblem(name, **kwargs)[source]

The main purpose of this class is to represent all relevant information for a single aerodynamic analysis. This will include the thermodynamic parameters defining the flow condition and the reference quantities for normalization.

There are several different ways of specifying thermodynamic conditions. The following describes several of the possible ways and the appropriate situations.

‘mach’ + ‘altitude’

This is the preferred method for specifying flight conditions. This is suitable for all aerodynamic analysis codes, including aerostructural analysis. The 1976 standard atmosphere is used to compute \(P\) and \(T\). We then compute \(\rho = P / RT\). The remaining quantities are computed with baseclasses.AeroProblem._updateFromM(). The resulting Reynolds number depends on the scale of the mesh.

‘mach’ + ‘reynolds’ + ‘reynoldsLength’ + ‘T’:

Used to precisely match Reynolds numbers. The remaining quantities are computed with baseclasses.AeroProblem._updateFromRe().

‘V’ + ‘reynolds’ + ‘reynoldsLength’ + ‘T’:

Used to precisely match Reynolds numbers for low-speed cases. The remaining quantities are computed with baseclasses.AeroProblem._updateFromRe().

‘mach’ + ‘T’ + ‘P’:

Any arbitrary temperature and pressure. The inputs are first used to compute \(\rho = P / RT\). The remaining quantities are then computed with baseclasses.AeroProblem._updateFromM().

‘mach’ + ‘T’ + ‘rho’:

Any arbitrary temperature and density. The inputs are first used to compute \(P = \rho RT\). The remaining quantities are then computed with baseclasses.AeroProblem._updateFromM().

‘mach’ + ‘P’ + ‘rho’:

Any arbitrary density and pressure. The inputs are first used to compute \(T = P / \rho R\). The remaining quantities are then computed with baseclasses.AeroProblem._updateFromM().

‘V’ + ‘rho’ + ‘T’

Generally for low-speed specifications. The inputs are first used to compute \(P = \rho RT\). The remaining quantities are then computed with baseclasses.AeroProblem._updateFromV().

‘V’ + ‘rho’ + ‘P’

Generally for low-speed specifications. The inputs are first used to compute \(T = P / \rho R\). The remaining quantities are then computed with baseclasses.AeroProblem._updateFromV().

‘V’ + ‘T’ + ‘P’

Generally for low-speed specifications. The inputs are first used to compute \(\rho = P / RT\). The remaining quantities are then computed with baseclasses.AeroProblem._updateFromV().

The combinations listed above are the only valid combinations of arguments that are permitted. Furthermore, since the internal processing is based (permanently) on these parameters, it is important that the parameters given on initialization are sufficient for the required analysis. For example, if only the Mach number is given, an error will be raised if the user tries to set the ‘P’ (pressure) variable.

For our compressible RANS solver, ADflow, the inputs from AeroProblem are the dimensional freestream values \(M\), \(P\), \(T\), \(\gamma\), \(\rho\), \(R_{\text{gas}}\), Sutherland’s law constants \(S\), \(T_{ref}\), \(\mu_{ref}\), and the Prandtl number \(Pr\). The non-dimensionalized inputs used in the actual ADflow CFD computations are derived from these inherited inputs.

All parameters are optional except for the name argument which is required. All of the parameters listed below can be acessed and set directly after class creation by calling:

<aeroProblem>.<variable> = <value>

An attempt is made internally to maintain consistency of the supplied arguments. For example, if the altitude variable is set directly, the other thermodynamic properties (rho, P, T, mu, a) are updated accordingly.

Parameters:
namestr

Name of this aerodynamic problem.

evalFuncsiterable object containing strings

The names of the functions the user wants evaluated with this aeroProblem.

machfloat. Default is 0.0

Set the Mach number for the simulation

machReffloat. Default is None

Sets the reference Mach number for the simulation.

machGridfloat. Default is None

Set the Mach number for the grid.

alphafloat. Default is 0.0

Set the angle of attack in degrees.

betafloat. Default is 0.0

Set the side-slip angle in degrees.

altitudefloat. Default is 0.0

Set all thermodynamic parameters from the 1976 standard atmosphere. The altitude must be given in meters.

phatfloat. Default is 0.0

Set the rolling rate coefficient

qhatfloat. Default is 0.0

Set the pitch rate coefficient

rhatfloat. Default is 0.0

Set the yawing rate coefficient

degPolinteger. Default is 0

Degree of polynomial for prescribed motion. ADflow only

coefPolarray_like. Default is [0.0]

Coefficients of polynomial motion. ADflow only

degFourierinteger. Default is 0

Degree of Fourier coefficient for prescribed motion. ADflow only

omegaFourierfloat. Default is 0.0

Fundamental circular frequency for oscillatory motion. ADflow only

cosCoefFourierarray_like. Default is [0.0]

Coefficients for cos terms

sinCoefFourierarray_like. Default is [0.0]

Coefficients for the sin terms

Pfloat.

Set the ambient pressure

Tfloat.

Set the ambient temperature

gammafloat. Default is 1.4

Set the ratio of the specific heats in ideal gas law

reynoldsfloat. Default is None

Set the Reynolds number

reynoldslengthfloat. Default is 1.0

Set the reference length for the Reynolds number calculations

areaReffloat. Default is 1.0

Set the reference area used for normalization of lift, drag, etc.

chordReffloat. Default is 1.0

Set the reference length used for moment normalization

spanReffloat. Default is 1.0

Set reference length for span. Only used for normalization of p-derivatives

xReffloat. Default is 0.0

Set the x-coordinate location of the center about which moments are taken

yReffloat. Default is 0.0

Set the y-coordinate location of the center about which moments are taken

zReffloat. Default is 0.0

Set the z-coordinate location of the center about which moments are taken

momentAxisiterable object containing floats.

Default is [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]] Set the reference axis for non-x/y/z based moment calculations

englishUnitsbool

Flag to use all English units: pounds, feet, Rankine etc.

solverOptionsdict

A set of solver specific options that temporarily override the solver’s internal options for this aero problem only. It must contain the name of the solver followed by a dictionary of options for that solver. For example solverOptions={'adflow':{'vis4':0.018}}. Currently, the only solver supported is ‘adflow’ and must use the specific key ‘adflow’.

Notes

See baseclasses.FluidProperties for more parameters that can be set.

Examples

>>> # DPW4 Test condition (metric)
>>> ap = AeroProblem('tunnel_condition', mach=0.85, reynolds=5e6, reynoldsLength=275.8*.0254, T=310.93, areaRef=594720*.0254**2, chordRef=275.8*.0254, xRef=1325.9*0.0254, zRef=177.95*.0254)
>>> # DPW4 Flight condition (metric)
>>> ap = AeroProblem('flight_condition', mach=0.85, altitude=37000*.3048, areaRef=594720*.0254**2, chordRef=275.8*.0254, xRef=1325.9*0.0254, zRef=177.95*.0254)
>>> # Onera M6 Test condition (Euler)
>>> ap = AeroProblem('m6_tunnel', mach=0.8395, areaRef=0.772893541, chordRef=0.64607, xRef=0.0, zRef=0.0, alpha=3.06)
>>> # Onera M6 Test condition (RANS)
>>> ap = AeroProblem('m6_tunnel', mach=0.8395, reynolds=11.72e6, reynoldsLength=0.64607, areaRef=0.772893541, chordRef=0.64607, xRef=0.0, zRef=0.0, alpha=3.06, T=255.56)
>>> # NACA0009 hydrofoil (0.9m semi-span) sailing condition (hacked for incompressible flow and viscosity)
>>> # R=461.9 for water vapor, but we can lower it to get a higher Mach number
>>> # Hack to get the dynamic viscosity of water, TSuthDim must equal T for this to work!
>>> ap = AeroProblem("hydrofoil", areaRef=0.243, alpha=6, chordRef=0.27, T=288.15, V=17, rho=1025, xRef=0.18, yRef=0.0, zRef=0.0, evalFuncs=["cl","cd","lift","drag","cavitation","target_cavitation"], R=100, muSuthDim=1.22e-3, TSuthDim=288.15)
_updateFromM()[source]

Update the full set of states from M, T, rho with the following steps:

  1. \(a = \sqrt{\gamma RT}\)

  2. Compute \(\mu(T)\) from Sutherland’s law.

  3. \(V = M a\)

  4. \(Re/L = \rho V / \mu\)

  5. \(\nu = \mu / \rho\)

  6. \(q = 0.5 \rho V^2\)

_updateFromRe()[source]

Update the full set of states from Re, T, and either V or M with the following steps:

  1. \(a = \sqrt{\gamma RT}\)

  2. Compute \(\mu(T)\) from Sutherland’s law.

  3. \(V = M a\) or \(M = V / a\)

  4. \(\rho = \frac{Re \mu}{V L}\)

  5. \(P = \rho R T\)

  6. \(q = 0.5 \rho V^2\)

_updateFromV()[source]

Update the full set of states from V, T, rho with the following steps:

  1. \(a = \sqrt{\gamma RT}\)

  2. Compute \(\mu(T)\) from Sutherland’s law.

  3. \(\nu = \mu / \rho\)

  4. \(q = 0.5 \rho V^2\)

  5. \(M = V / a\)

  6. \(Re/L = \rho V / \mu\)

addDV(key, value=None, lower=None, upper=None, scale=1.0, name=None, offset=0.0, dvOffset=0.0, addToPyOpt=True, family=None, units=None)[source]

Add one of the class attributes as an ‘aerodynamic’ design variable. Typical variables are alpha, mach, altitude, chordRef, etc. An error will be given if the requested DV is not allowed to be added.

Parameters:
keystr

Name of variable to add. See above for possible ones

valuefloat. Default is None

Initial value for variable. If not given, current value of the attribute will be used.

lowerfloat. Default is None

Optimization lower bound. Default is unbonded.

upperfloat. Default is None

Optimization upper bound. Default is unbounded.

scalefloat. Default is 1.0

Set scaling parameter for the optimization to use.

namestr. Default is None

Overwrite the name of this variable. This is typically only used when the user wishes to have multiple aeroProblems to explictly use the same design variable.

offsetfloat. Default is 0.0

Specify a constant offset of the value relative to the actual design variable. This is most often used when a single aerodynamic variable is used to change multiple aeroProblems. For example, if you have three aeroProblems for a multiPoint analysis with Mach numbers of 0.84, 0.85 and 0.86, and you want all three to change by the same amount, you could do this:

>>> ap1.addDV('mach',..., name='centerMach', offset=-0.01)
>>> ap2.addDV('mach',..., name='centerMach', offset= 0.00)
>>> ap3.addDV('mach',..., name='centerMach', offset=+0.01)

The result is a single design variable driving three different Mach numbers.

dvOffsetfloat. Default is 0.0

This is the offset used to give to pyOptSparse. It can be used to re-center the value about zero.

addToPyOptbool. Default True.

Flag specifying if this variable should be added. Normally this is True. However, if there are multiple aeroProblems sharing the same variable, only one needs to add the variables to pyOpt and the others can set this to False.

unitsstr or None. Default None

Physical units of the variable

Examples

>>> # Add alpha variable with typical bounds
>>> ap.addDV('alpha', value=2.5, lower=0.0, upper=10.0, scale=0.1)
addVariablesPyOpt(optProb)[source]

Add the current set of variables to the optProb object.

Parameters:
optProbpyOpt_optimization class

Optimization problem definition to which variables are added

evalFunctions(funcs, evalFuncs, ignoreMissing=False)[source]

Evaluate the desired aerodynamic functions. It may seem strange that the aeroProblem has ‘functions’ associated with it, but in certain instances, this is the case.

For an aerodynamic optimization, consider the case when ‘mach’ is a design variable, and the objective is ML/D. We need the mach variable explictly in our our objCon function. In this case, the ‘function’ is simply the design variable itself, and the derivative of the function with respect the design variable is 1.0.

A more complex example is when ‘altitude’ is used for an aerostructural optimization. If we use the Breguet range equation is used for either the objective or constraints we need to know the flight velocity, ‘V’, which is a non-trivial function of the altitude (and Mach number).

Also, even if ‘altitude’ and ‘mach’ are not parameters, this function can be used to evaluate the ‘V’ value for example. In this case, ‘V’ is simply constant and no sensitivties would be calculated which is fine.

Note that the list of available functions depends on how the user has initialized the flight condition.

Parameters:
funcsdict

Dictionary into which the functions are saved

evalFuncsiterable object containing strings

The functions that the user wants evaluated

evalFunctionsSens(funcsSens, evalFuncs, ignoreMissing=True)[source]

Evaluate the sensitivity of the desired aerodynamic functions.

Parameters:
funcsSensdict

Dictionary into which the function sensitivities are saved

evalFuncsiterable object containing strings

The functions that the user wants evaluated

getDesignVars()[source]

Get the current DV values.

Returns:
dvsDict[str, float]

Current design variable values

setBCVar(varName, value, familyName)[source]

set the value of a BC variable on a specific variable

setDesignVars(x)[source]

Set the variables in the x-dict for this object.

Parameters:
xdict

Dictionary of variables which may or may not contain the design variable names this object needs

updateInternalDVs()[source]

A specialized function that allows for the updating of the internally stored DVs. This would be used for, example, if a CLsolve is done before the optimization and that value needs to be used.