cape.cfdx.runmatrix: Run matrix interface¶
This module provides a class cape.runmatrix.RunMatrix for
interacting with a list of cases. Usually this is the list of cases
defined as the run matrix for a set of CFD solutions, and it is defined
in the "RunMatrix" section of the JSON file
(see cape.cfdx.options.runmatrixopts).
However, the contents of the cape.runmatrix.RunMatrix may have
a list of cases that differs from the run matrix, for example containing
instead the cases contained in a data book.
The key defining parameter of a run matrix is the list of independent
variables, which are referred to as “trajectory keys” within Cape. For
example, a common list of trajectory keys for an inviscid setup is
["mach", "alpha", "beta"]. If the run matrix is loaded as x, then
the value of the Mach number for case number i would be x.mach[i].
If the name of the key to query is held within a variable k, use the
following syntax to get the value.
# Name of trajectory key k = "alpha" # Case number i = 10 # Value of that key for case *i* x[k][i]
Each case has a particular folder name. To get the name of the folder for case i, use the syntax
# Group folder name x.GetGroupFolderNames(i) # Case folder name x.GetFolderNames(i) # Combined group and case folder name x.GetFullFolderNames(i)
The trajectory class also contains several methods for filtering cases.
For example, the user may get the list of indices of cases with a Mach
number greater than 1.0, or the user may restrict to cases containing
the text "a1.0". These use the methods
cape.runmatrix.RunMatrix.Filter() and
cape.runmatrix.RunMatrix.FilterString(), respectively. Filtering
examples are shown below.
# Constraints I = x.Filter(cons=['mach>=0.5', 'mach<1.0']) # Contains exact text I = x.FilterString('m0.9') # Contains text with wildcards (like file globs) I = x.FilterWildcard('m?.?a-*') # Contains a regular expression I = x.FilterRegex('m0\.[5-8]+a')
These methods are all combined in the
cape.runmatrix.RunMatrix.GetIndices() method. The
cape.runmatrix.RunMatrix.GetSweeps() method provides a capability
to split a run matrix into groups in which the cases in each group
satisfy user-specified constraints, for example having the same angle of
attack.
Also provided are methods such as
cape.runmatrix.RunMatrix.GetAlpha(), which allows the user to
easily access the angle of attack for case i even if the run matrix is
defined using total angle of attack and roll angle. Similarly,
cape.runmatrix.RunMatrix.GetReynoldsNumber() returns the Reynolds
number per grid unit even if the run matrix uses static or dynamic
pressure, which relieves the user from having to do the conversions
before creating the run matrix conditions.
- class cape.cfdx.runmatrix.RunMatrix(*a, **kwargs)¶
Read a list of configuration variables
- Call:
>>> x = cape.RunMatrix(**traj) >>> x = cape.RunMatrix(File=fname, Keys=keys)
- Inputs:
- traj:
dict Dictionary of options from
opts["RunMatrix"]
- traj:
- Keyword arguments:
- File:
str Name of file to read, defaults to
'RunMatrix.dat'- Keys:
listofstritems List of variable names, defaults to
['Mach','alpha','beta']- Prefix:
str Prefix to be used for each case folder name
- GroupPrefix:
str Prefix to be used for each grid folder name
- GroupMesh:
bool Whether or not cases in same group can share volume grids
- Definitions:
dict Dictionary of definitions for each key
- File:
- Outputs:
- x:
cape.runmatrix.RunMatrix Instance of the trajectory class
- x:
- Data members:
- x.nCase:
int Number of cases in the trajectory
- x.prefix:
str Prefix to be used in folder names for each case in trajectory
- x.GroupPrefix:
str Prefix to be used for each grid folder name
- x.cols:
list, dtype=str List of variable names used
- x.text:
dict, dtype=list Lists of variable values taken from trajectory file
- x[key]:
numpy.ndarray, dtype=float Vector of values of each variable specified in keys
- x.nCase:
- Versions:
2014-05-28
@ddalle: v1.02014-06-05
@ddalle: v1.1; user-defined keys2023-07-20
@ddalle: v1.2; useoptdictto process args
- Copy()¶
Return a copy of the trajectory
- Call:
>>> y = x.Copy()
- Inputs:
- x:
cape.runmatrix.RunMatrix Instance of the trajectory class
- x:
- Outputs:
- y:
cape.runmatrix.RunMatrix Separate trajectory with same data
- y:
- Versions:
2015-05-22
@ddalle: v1.0
- ExpandIndices(itxt)¶
Expand string of subscripts into a list of indices
- Call:
>>> I = x.ExpandIndices(itxt)
- Inputs:
- x:
cape.runmatrix.RunMatrix CAPE run matrix instance
- itxt:
strorunicode Text of subscripts, separated by ‘;’
- x:
- Outputs:
- Examples:
>>> x.ExpandIndices(':5') [0, 1, 2, 3, 4] >>> x.ExpandIndices(':4;7,8') [0, 1, 2, 3, 7, 8]
- Versions:
2015-03-10
@ddalle: v1.02018-10-19
@ddalle: Multi ranges,1:4,5,6:10
- Filter(cons, I=None)¶
Filter cases according to a set of constraints
The constraints are specified as a list of strings that contain inequalities of variables that are in x.cols.
For example, if m is the name of a key (presumably meaning Mach number), and a is a variable presumably representing angle of attack, the following example finds the indices of all cases with Mach number greater than 1.5 and angle of attack equal to
2.0.>>> i = x.Filter(['m>1.5', 'a==2.0'])
A warning will be produces if one of the constraints does not correspond to a trajectory variable or cannot be evaluated for any other reason.
- Call:
>>> i = x.Filter(cons) >>> i = x.Fitler(cons, I)
- Inputs:
- Outputs:
- i:
np.ndarray[int] List of indices that match constraints
- i:
- Versions:
2014-12-09
@ddalle: v1.0- 2019-12-09
@ddalle: v2.0 Discontinue attributes, i.e. x.mach
Use
reto process constraints
- 2019-12-09
- FilterRegex(txt, I=None)¶
Filter cases by a regular expression
- Call:
>>> i = x.FilterRegex(txt) >>> i = x.FilterRegex(txt, I)
- Inputs:
- Outputs:
- i:
np.ndarray[int] List of indices that match constraints
- i:
- Versions:
2015-11-02
@ddalle: v1.0
- FilterString(txt, I=None)¶
Filter cases by whether or not they contain a substring
- Call:
>>> i = x.FilterString(txt) >>> i = x.FilterString(txt, I)
- Inputs:
- Outputs:
- i:
np.ndarray[int] List of indices that match constraints
- i:
- Versions:
2015-11-02
@ddalle: v1.0
- FilterWildcard(txt, I=None)¶
Filter cases by whether or not they contain a substring
This function uses file wild cards, so for example
x.FilterWildcard('*m?.0*')matches any case whose name containsm1.0orm2.0, etc. To make sure the?is a number, use*m[0-9].0. To obtain a filter that matches bothm10.0andm1.0, seeFilterRegex().- Call:
>>> i = x.FilterWildcard(txt) >>> i = x.FilterWildcard(txt, I)
- Inputs:
- Outputs:
- i:
numpy.ndarray[int] List of indices that match constraints
- i:
- Versions:
2015-11-02
@ddalle: v1.0
- FindMatch(y, i, keys=None, **kw)¶
Find first case (if any) matching another trajectory case
- Call:
>>> j = x.FindMatch(y, i, keys=None)
- Inputs:
- x:
dkit.runmatrix.RunMatrix Run matrix conditions interface
- y:
dkit.runmatrix.RunMatrix Target run matrix conditions interface
- i:
int Case number of case in y
- keys: {
None} |list[str] List of keys to test for equivalence
- tol: {
1e-8} |float>= 0 Tolerance for two values to be ideintal
- machtol: {tol} |
float>= 0 Tolerance for mach key, for instance
- x:
- Outputs:
- j:
None|int Index of first matching case, if any
- j:
- Versions:
2017-07-21
@ddalle: v1.0
- FindMatches(y, i, keys=None, **kw)¶
Find indices of cases matching another trajectory case
- Call:
>>> I = x.FindMatches(y, i, keys=None)
- Inputs:
- x:
dkit.runmatrix.RunMatrix Run matrix conditions interface
- y:
dkit.runmatrix.RunMatrix Target run matrix conditions interface
- i:
int Case number of case in y
- keys: {
None} |list[str] List of keys to test for equivalence
- tol: {
1e-8} |float>= 0 Tolerance for two values to be ideintal
- machtol: {tol} |
float>= 0 Tolerance for mach key, for instance
- x:
- Outputs:
- I:
np.ndarray(int) List of indices matching all constraints
- I:
- Versions:
2017-07-21
@ddalle: v1.0
- GetAlpha(i=None)¶
Get the angle of attack
- Call:
>>> alpha = x.GetAlpha(i=None)
- Inputs:
- x: :class;`cape.runmatrix.RunMatrix`
Run matrix interface
- i: {
None} |int Case number (return all if
None)
- Outputs:
- alpha:
float|np.ndarray Angle of attack in degrees
- alpha:
- Versions:
2016-03-24
@ddalle: v1.0
- GetAlphaManeuver(i=None)¶
Get the signed total angle of attack
- GetAlphaTotal(i=None)¶
Get the total angle of attack
- GetBeta(i=None)¶
Get the sideslip angle
- GetCoSweep(x0, i0, **kw)¶
Return a list of indices meeting sweep constraints
The sweep uses point i0 of co-trajectory x0 as the reference for the constraints.
For example, using
EqCons=['mach']will cause the method to return points with x.mach matching x0.mach[i0].- Call:
>>> I = x.GetSweep(x0, i0, **kw)
- Inputs:
- x:
cape.runmatrix.RunMatrix CAPE run matrix instance
- x0:
cape.runmatrix.RunMatrix Another instance of the pyCart trajectory class
- i0:
int Index of reference point in x0 for constraints
- SortVar:
str Variable by which to sort each sweep
- EqCons:
list[str] List of trajectory keys which must match (exactly) the first point in the sweep
- TolCons:
dict[float] Dictionary whose keys are trajectory keys which must match the first point in the sweep to a specified tolerance and whose values are the specified tolerances
- IndexTol:
int If specified, only trajectory points in the range
[i0,i0+IndexTol]are considered for the sweep- I:
np.ndarray[int] List of x indices to consider in the sweep
- x:
- Outputs:
- I:
np.ndarray[int] List of x indices in the sweep
- I:
- Versions:
2015-06-03
@ddalle: v1.0
- GetDensity(i=None, units=None)¶
Get freestream density
- GetDynamicPressure(i=None, units=None)¶
Get dynamic freestream pressure (in psf or Pa)
- Call:
>>> q = x.GetDynamicPressure(i=None)
- Inputs:
- Outputs:
- q:
float Dynamic pressure [ psf | Pa | units ]
- q:
- Versions:
2016-03-24
@ddalle: v1.02017-07-20
@ddalle: Added default cases2018-04-17
@ddalle: Units
- GetFirstKeyByType(KeyType)¶
Get all keys by type
- GetFolderNames(i: list | int | None = None) list | int¶
Get case folder name(s) for one or more cases
This does not include the “group”, or top-level folder, of the full case name.
- Call:
>>> name_or_names = x.GetFolderNames(i=None)
- Inputs:
- Outputs:
- Versions:
2014-05-28
@ddalle: v1.02014-06-05
@ddalle: v1.1; case folder only2024-10-16
@ddalle: v2.0; reduce code, same results
- GetFullFolderNames(i: list | int | None = None) list | int¶
Get full folder names for one or more cases
The names will generally be of the form
myconfig/m2.0a0.0b-0.5/with two levels. However, users may define additional levels of depth by adding the
/character to the Abbreviation or Format of individual run matrix keys.- Call:
>>> name_or_names = x.GetFullFolderNames(i=None)
- Inputs:
- Outputs:
- Versions:
2014-06-05
@ddalle: v1.02024-10-16
@ddalle: v2.0; reduce code, same results
- GetGamma(i=None)¶
Get freestream ratio of specific heats
- GetGasProperty(k, vdef=None)¶
Get property from the
"Freestream"section
- GetGroupFolderNames(i: list | int | None = None) list | int¶
Get case folder name(s) for one or more cases
This only includes the “group”, or top-level folder, of the full case name and not the individual case name. The reason for this separation is to allow users to put the Group keys anywhere within the list of RunMatrix > Keys.
- Call:
>>> name_or_names = x.GetGroupFolderNames(i=None)
- Inputs:
- Outputs:
- Versions:
2014-06-05
@ddalle: v1.02024-10-16
@ddalle: v2.0; reduce code, same results
- GetGroupIndex(i)¶
Get group index from case index
- GetIndices(**kw)¶
Get indices from either list or constraints or both
- Call:
>>> I = x.GetIndices(I=None, cons=[], **kw)
- Inputs:
- x:
cape.runmatrix.RunMatrix CAPE run matrix instance
- I:
list|str Array of indices or text of indices
- cons:
list[str] |str List of constraints or text list using commas
- re:
str Regular expression to test against folder names
- filter:
str Exact test to test against folder names
- glob:
str Wild card to test against folder names
- x:
- Outputs:
- I:
np.ndarray[int] Array of indices
- I:
- Versions:
2015-03-10
@ddalle: v1.02016-02-17
@ddalle: v2.0; handle text
- GetKeyValue(k, i=None, units=None, udef='1')¶
Get the value of one key with appropriate dimensionalization
- Call:
>>> v = x.GetKeyValue(k, i=None, units=None, udef="1")
- Inputs:
- Outputs:
- v:
float Value of key k for case i in units of units
- v:
- Versions:
2018-04-13
@ddalle: v1.0
- GetKeysByType(KeyType)¶
Get all keys by type
- Call:
>>> keys = x.GetKeysByType(KeyType) >>> keys = x.GetKeysByType(KeyTypes)
- Inputs:
- Outputs:
- keys:
numpy.ndarray(str) List of keys such that
x[key]['Type']matches KeyType
- keys:
- Versions:
2014-10-07
@ddalle: v1.0
- GetKeysByValue(val)¶
Get all keys with specified type of value
- GetMach(i=None)¶
Get Mach number
- GetMolecularWeight(i=None, units=None)¶
Get averaged freestream gas molecular weight
- GetNormalizedGasConstant(i=None, units=None)¶
Get averaged freestream gas molecular weight
- Call:
>>> R = x.GetNormalizedGasConstant(i=None, units=None)
- Inputs:
- Outputs:
- R:
float Normalized gas constant [J/kg*K | units ]
- R:
- Versions:
2018-04-13
@ddalle: v1.0
- GetPBSName(i: int, prefix: str | None = None, maxlen: int = 32) str¶
Get PBS name for a given case
- Call:
>>> name = x.GetPBSName(i, pre=None)
- Inputs:
- Outputs:
- name:
str Short name for the PBS job, visible via qstat
- name:
- Versions:
2014-09-30
@ddalle: v1.02016-12-20
@ddalle: v1.1; move toRunMatrix2024-08-16
@ddalle; v2.0; longer default
- GetPhi(i=None)¶
Get the velocity roll angle
- GetPhiManeuver(i=None)¶
Get the signed maneuver roll angle
- GetPressure(i=None, units=None)¶
Get static freestream pressure (in psf or Pa)
- Call:
>>> p = x.GetPressure(i)
- Inputs:
- Outputs:
- p:
float Static pressure [ psf | Pa | units ]
- p:
- Versions:
2016-03-24
@ddalle: v1.02017-07-20
@ddalle: Added default cases2018-04-17
@ddalle: Units
- GetReynoldsNumber(i=None, units=None)¶
Get Reynolds number (per foot)
- Call:
>>> Re = x.GetReynoldsNumber(i=None, units=None)
- Inputs:
- Outputs:
- Re:
float Reynolds number [1/inch | 1/ft]
- Re:
- Versions:
2016-03-23
@ddalle: v1.02017-07-19
@ddalle: Added default conditions
- GetSurfBC_BCIndex(i, key=None, comp=None, **kw)¶
Get namelist/column/etc. index for a surface BC key
- Call:
>>> inds = x.GetSurfBC_BCIndex(i, key=None, comp=None)
- Inputs:
- Outputs:
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfBC_CompID(i, key=None, comp=None, **kw)¶
Get component ID input for surface BC key
- Call:
>>> compID = x.GetSurfBC_CompID(i, key=None, comp=None, **kw)
- Inputs:
- Outputs:
- Versions:
2016-03-28
@ddalle: v1.0
- GetSurfBC_Gamma(i, key=None, comp=None, **kw)¶
Get ratio of specific heats for surface BC key
- Call:
>>> gam = x.GetSurfBC_Gamma(i, key=None, comp=None, **kw)
- Inputs:
- Outputs:
- gam:
float Surface boundary condition ratio of specific heats
- gam:
- Versions:
2016-03-29
@ddalle: v1.02016-08-29
@ddalle: Added comp
- GetSurfBC_Grids(i, key=None, comp=None, **kw)¶
Get list of grids for surface BC key
- Call:
>>> grids = x.GetSurfBC_Grids(i, key=None, comp=None)
- Inputs:
- Outputs:
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfBC_Mach(i, key=None, comp=None, **kw)¶
Get Mach number input for surface BC key
- Call:
>>> M = x.GetSurfBC_Mach(i, key=None, comp=None, **kw)
- Inputs:
- Outputs:
- M:
float Surface boundary condition Mach number
- M:
- Versions:
2016-03-28
@ddalle: v1.0
- GetSurfBC_NSpecies(i, key=None, comp=None, **kw)¶
Get number of species for a surface BC key
- Call:
>>> nY = x.GetSurfBC_NSpecies(i, key=None, comp=None, **kw)
- Inptus:
- Outputs:
- nY: {
1} |int Number of species
- nY: {
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfBC_Param(i, key, k, comp=None, vdef=None, **kw)¶
Process a single parameter of a SurfBC key
- Call:
>>> v = x.GetSurfBC_Param(i, key, k, comp=None, vdef=None, **kw)
- Inputs:
- x:
cape.runmatrix.RunMatrix Run matrix interface
- i:
int Case index
- key:
str Name of trajectory key to use
- k:
str Name of input parameter to find
- comp:
None|str If v is a dict, use v[comp] if comp is nontrivial
- vdef:
None|any Default value for v if v is
None- typ: {
"SurfBC"} |str RunMatrix key type to process
- x:
- Keyword arguments:
- j:
str Name of function to use if parameter is a string
- j:
- Outputs:
- v:
None|any Value of the parameter
- v:
- Versions:
2016-08-31
@ddalle: v1.0
- GetSurfBC_ParamType(key, k, comp=None)¶
Get generic parameter value and type for a surface BC key
- Call:
>>> v, t = x.GetSurfBC_ParamType(key, k, comp=None)
- Inputs:
- Outputs:
- v:
None|any Value of the parameter
- t:
str Name of the type of v (
type(v).__name__)
- v:
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfBC_PlenumID(i, key=None, comp=None, **kw)¶
Get gas ID input for surface BC key
- Call:
>>> pID = x.GetSurfBC_PlenumID(i, key=None, comp=None, **kw)
- Inputs:
- Outputs:
- pID:
int Gas number for plenum boundary condition
- pID:
- Versions:
2018-10-18
@ddalle: v1.0
- GetSurfBC_PressureCalibration(i, key=None, comp=None, **kw)¶
Get total pressure scaling factor used for calibration
- Call:
>>> fp = x.GetSurfBC_PressureCalibration(i, key, comp, **kw)
- Inputs:
- Outputs:
- fp: {
1.0} |float Pressure calibration factor
- fp: {
- Versions:
2016-04-12
@ddalle: v1.0
- GetSurfBC_PressureOffset(i, key=None, comp=None, **kw)¶
Get offset used for calibration of static or stagn pressure
The value used by
capeis given by\[\tilde{p} = \frac{b + ap}{p_\mathit{ref}}\]where \(\tilde{p}\) is the value used in the namelist, b is the value from this function, a is the result of
GetSurfBC_PressureCalibration(), p is the input value from the JSON file, and \(p_\mathit{ref}\) is the value fromGetSurfBC_RefPressure(). In code, this isp_tilde = (bp + fp*p) / pref
- Call:
>>> bp = x.GetSurfBC_PressureOffset(i, key, comp=None, **kw)
- Inputs:
- Outputs:
- bp: {
0.0} |float Stagnation or static pressure offset
- bp: {
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfBC_RefPressure(i, key=None, comp=None, **kw)¶
Get reference pressure for surface BC key
- Call:
>>> pinf = x.GetSurfBC_RefPressure(i, key, comp=None, **kw)
- Inputs:
- Outputs:
- pinf:
float Reference pressure to use, this divides the p0 value
- pinf:
- Versions:
2016-03-28
@ddalle: v1.0
- GetSurfBC_RefTemperature(i, key=None, comp=None, **kw)¶
Get reference temperature for surface BC key
- Call:
>>> Tinf = x.GetSurfBC_RefTemperature(i, key, comp, **kw)
- Inputs:
- Outputs:
- Tinf:
float Reference temperature, this divides the T0 value
- Tinf:
- Versions:
2016-03-28
@ddalle: v1.0
- GetSurfBC_Species(i, key=None, comp=None, **kw)¶
Get species information for a surface BC key
The species can be specified using several different manners.
The first and most common approach is to simply set a fixed list, for example setting
"Species"to[0.0, 1.0, 0.0]to specify use of the second species, or[0.2, 0.8, 0.1]to specify a mix of three different species.A second method is to specify an integer. For example, if
"Species"is set to2and"NSpecies"is set to4, the output will be[0.0, 1.0, 0.0, 0.0].The third method is a generalization of the first. An alternative to simply setting a fixed list of numeric species mass fractions, the entries in the list can depend on the values of other trajectory keys. For example, setting
"Species"to['YH2', 'YO2']will translate the mass fractions according to the values of trajectory keys"YH2"and"YO2".- Call:
>>> Y = x.GetSurfBC_Species(i, key=None, comp=None, **kw)
- Inputs:
- Outputs:
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfBC_TemperatureCalibration(i, key=None, comp=None, **kw)¶
Get total/static temperature scaling factor for calibration
- Call:
>>> fT=x.GetSurfBC_TemperatureCalibration(i ,key, comp, **kw)
- Inputs:
- Outputs:
- fp: {
1.0} |float Pressure calibration factor
- fp: {
- Versions:
2016-08-30
@ddalle: v1.0
- GetSurfBC_TemperatureOffset(i, key=None, comp=None, **kw)¶
Get offset for calibration of static or stag temperature
The value used by
capeis given by\[\tilde{T} = \frac{b + aT}{T_\mathit{ref}}\]where \(\tilde{T}\) is the value used in the namelist, b is the value from this function, a is the result of
GetSurfBC_TemperatureCalibration(), T is the input value from the JSON file, and \(T_\mathit{ref}\) is the value fromGetSurfBC_RefTemperature(). In code, this isT_tilde = (bt + ft*T) / Tref
- Call:
>>> bt = x.GetSurfBC_TemperatureOffset(i, key, comp, **kw)
- Inputs:
- Outputs:
- bt: {
0.0} |float Stagnation or static temperature offset
- bt: {
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfBC_TotalPressure(i, key=None, comp=None, **kw)¶
Get stagnation pressure input for surface BC key
- Call:
>>> p0 = x.GetSurfBC_TotalPressure(i, key, comp=None, **kw)
- Inputs:
- Outputs:
- p0:
float Stagnation pressure parameter, usually p0/pinf
- p0:
- Versions:
2016-03-28
@ddalle: v1.0
- GetSurfBC_TotalTemperature(i, key=None, comp=None, **kw)¶
Get stagnation pressure input for surface BC key
- Call:
>>> T0 = x.GetSurfBC_TotalTemperature(i, key, comp, **kw)
- Inputs:
- Outputs:
- T0:
float Stagnation temperature parameter, usually T0/Tinf
- T0:
- Versions:
2016-03-28
@ddalle: v1.0
- GetSurfBC_Val(i, key, v, t, vdef=None, **kw)¶
Default processing for processing a key by value
- Call:
>>> V = x.GetSurfBC_Val(i, key, v, t, vdef=None)
- Inputs:
- Outputs:
- V:
any Processed key, for example
x[key][i]
- V:
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfCT_AreaRatio(i, key=None, comp=None)¶
Get area ratio for surface CT key
- GetSurfCT_CompID(i, key=None, comp=None)¶
Get component ID input for surface CT key
- Call:
>>> compID = x.GetSurfCT_CompID(i, key=None, comp=None)
- Inputs:
- Outputs:
- Versions:
2016-04-11
@ddalle: v1.0
- GetSurfCT_ExitArea(i, key=None, comp=None)¶
Get exit area for surface CT key
- GetSurfCT_ExitMach(i, key=None, comp=None)¶
Get Mach number input for surface CT key
- Call:
>>> M2 = x.GetSurfCT_ExitMach(i, key=None, comp=None)
- Inputs:
- Outputs:
- M2:
float Nozzle exit Mach number
- M2:
- Versions:
2016-04-11
@ddalle: v1.0
- GetSurfCT_Gamma(i, key=None, comp=None)¶
Get ratio of specific heats input for surface CT key
- Call:
>>> gam = x.GetSurfCT_Gamma(i, key=None, comp=None)
- Inputs:
- Outputs:
- gam: {
1.4} |float Ratio of specific heats
- gam: {
- Versions:
2016-04-11
@ddalle: v1.0
- GetSurfCT_Grids(i, key=None, comp=None)¶
Get list of grids for surface CT key
- Call:
>>> compID = x.GetSurfCT_Grids(i, key=None, comp=None)
- Inputs:
- Outputs:
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfCT_Mach(i, key=None, comp=None)¶
Get Mach number input for surface CT key
- Call:
>>> M = x.GetSurfCT_TotalTemperature(i, key=None, comp=None)
- Inputs:
- Outputs:
- T0:
float Total temperature of thrust conditions
- T0:
- Versions:
2016-04-11
@ddalle: v1.0
- GetSurfCT_PlenumID(i, key=None, comp=None, **kw)¶
Get gas ID input for surface CT key
- Call:
>>> pID = x.GetSurfCT_PlenumID(i, key=None, comp=None, **kw)
- Inputs:
- Outputs:
- pID:
int Gas number for plenum boundary condition
- pID:
- Versions:
2018-10-18
@ddalle: v1.0
- GetSurfCT_PressureCalibration(i, key=None, comp=None)¶
Get pressure calibration factor for CT key
- Call:
>>> fp = x.GetSurfCT_PressureCalibration(i, key, comp=None)
- Inputs:
- Outputs:
- fp: {
1.0} |float Pressure calibration factor
- fp: {
- Versions:
2016-04-11
@ddalle: v1.0
- GetSurfCT_PressureOffset(i, key=None, comp=None)¶
Get offset used for calibration of static or stagn pressure
The value used by
capeis given by\[\tilde{p} = \frac{b + ap}{p_\mathit{ref}}\]where \(\tilde{p}\) is the value used in the namelist, b is the value from this function, a is the result of
GetSurfBC_PressureCalibration(), p is the input value from the JSON file, and \(p_\mathit{ref}\) is the value fromGetSurfBC_RefPressure(). In code, this isp_tilde = (bp + fp*p) / pref
- Call:
>>> bp = x.GetSurfCT_PressureOffset(i, key=None, comp=None)
- Inputs:
- Outputs:
- bp: {
0.0} |float Stagnation or static pressure offset
- bp: {
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfCT_RefArea(i, key=None, comp=None)¶
Get ref area for surface CT key, this divides CT value
If this is
None, it defaults to the vehicle reference area- Call:
>>> Aref = x.GetSurfCT_RefArea(i, key=None, comp=None)
- Inputs:
- Outputs:
- ARef: {
None} |float Reference area; if
None, use the vehicle area
- ARef: {
- Versions:
2016-04-11
@ddalle: v1.0
- GetSurfCT_RefDynamicPressure(i, key=None, comp=None)¶
Get reference dynamic pressure for surface CT key
- Call:
>>> qinf = x.GetSurfCT_RefDynamicPressure(i, key=None, comp=None)
- Inputs:
- Outputs:
- qinf:
float Reference dynamic pressure to use, this divides the CT value
- qinf:
- Versions:
2016-04-12
@ddalle: v1.02016-08-29
@ddalle: Added component capability
- GetSurfCT_RefPressure(i, key=None, comp=None)¶
Get reference pressure input for surface CT total pressure
- Call:
>>> Tref = x.GetSurfCT_RefPressure(i, key=None, comp=None)
- Inputs:
- Outputs:
- pref:
float Reference pressure for normalizing T0
- pref:
- Versions:
2016-04-13
@ddalle: v1.0
- GetSurfCT_RefTemperature(i, key=None, comp=None)¶
Reference temperature input for surf CT total temperature
- Call:
>>> Tref = x.GetSurfCT_RefTemperature(i, key, comp=None)
- Inputs:
- Outputs:
- Tref:
float Reference temperature for normalizing T0
- Tref:
- Versions:
2016-04-11
@ddalle: v1.0
- GetSurfCT_Species(i, key=None, comp=None)¶
Get species input for surface CT key
- Call:
>>> Y = x.GetSurfCT_Species(i, key=None, comp=None)
- Inputs:
- Outputs:
- Versions:
2016-08-30
@ddalle: v1.0
- GetSurfCT_TemperatureCalibration(i, key=None, comp=None)¶
Get temperature calibration factor for CT key
- Call:
>>> fT = x.GetSurfCT_Temperature(i, key=None, comp=None)
- Inputs:
- Outputs:
- fT: {
1.0} |float Temperature calibration factor
- fT: {
- Versions:
2016-08-30
@ddalle: v1.0
- GetSurfCT_TemperatureOffset(i, key=None, comp=None)¶
Get offset for calibration of static or stag temperature
The value used by
capeis given by\[\tilde{T} = \frac{b + aT}{T_\mathit{ref}}\]where \(\tilde{T}\) is the value used in the namelist, b is the value from this function, a is the result of
GetSurfBC_TemperatureCalibration(), T is the input value from the JSON file, and \(T_\mathit{ref}\) is the value fromGetSurfBC_RefTemperature(). In code, this isT_tilde = (bt + ft*T) / Tref
- Call:
>>> bt = x.GetSurfCT_TemperatureOffset(i, key, comp=None)
- Inputs:
- Outputs:
- bt: {
0.0} |float Stagnation or static temperature offset
- bt: {
- Versions:
2016-08-29
@ddalle: v1.0
- GetSurfCT_Thrust(i, key=None, comp=None)¶
Get thrust input for surface CT key
- Call:
>>> CT = x.GetSurfCT_Thrust(i, key=None, comp=None)
- Inputs:
- Outputs:
- CT:
float Thrust parameter, either thrust or coefficient
- CT:
- Versions:
2016-04-11
@ddalle: v1.02016-08-29
@ddalle: Added component capability
- GetSurfCT_TotalPressure(i, key=None, comp=None)¶
Get stagnation pressure input for surface CT key
- Call:
>>> p0 = x.GetSurfCT_TotalPressure(i, key=None, comp=None, **kw)
- Inputs:
- Outputs:
- p0:
float Stagnation pressure parameter, usually p0/pinf
- p0:
- Versions:
2016-03-28
@ddalle: v1.0
- GetSurfCT_TotalTemperature(i, key=None, comp=None)¶
Get total temperature input for surface CT key
- Call:
>>> T0 = x.GetSurfCT_TotalTemperature(i, key, comp=None)
- Inputs:
- Outputs:
- T0:
float Total temperature of thrust conditions
- T0:
- Versions:
2016-04-11
@ddalle: v1.0
- GetSutherland_C(i=None, units=None)¶
Get reference temperature for Sutherland’s Law
- GetSutherland_T0(i=None, units=None)¶
Get reference temperature for Sutherland’s Law
- GetSutherland_mu0(i=None, units=None)¶
Get reference viscosity for Sutherland’s Law
- GetSweep(M, **kw)¶
Return a list of indices meeting sweep constraints
The sweep uses the index of the first entry of
Truein M, i.e.i0=np.where(M)[0][0]. Then the sweep contains all other points that meet all criteria with respect to trajectory point i0.For example, using
EqCons=['mach']will cause the method to return points with x.mach matching x.mach[i0].- Call:
>>> I = x.GetSweep(M, **kw)
- Inputs:
- x:
cape.runmatrix.RunMatrix CAPE run matrix instance
- M:
numpy.ndarray(bool) Mask of which trajectory points should be considered
- i0: {
np.where(M)[0][0]} |int Index of case to use as seed of sweep
- SortVar:
str Variable by which to sort each sweep
- EqCons:
list[str] List of trajectory keys which must match (exactly) the first point in the sweep
- TolCons:
dict(float) Dictionary whose keys are trajectory keys which must match the first point in the sweep to a specified tolerance and whose values are the specified tolerances
- IndexTol:
int If specified, only trajectory points in the range
[i0,i0+IndexTol]are considered for the sweep
- x:
- Outputs:
- I:
np.ndarray[int] List of trajectory point indices in the sweep
- I:
- Versions:
2015-05-24
@ddalle: v1.02017-06-27
@ddalle: Added special variables
- GetSweeps(**kw)¶
Return a list of index sets in which each list contains cases that match according to specified criteria
For example, using
EqCons=['mach']will cause the method to return lists of points with the same Mach number.- Call:
>>> J = x.GetSweeps(**kw)
- Inputs:
- cons:
list[str] List of global constraints; only points satisfying these constraints will be in one of the output sweeps
- I:
np.ndarray[int] List of indices to restrict to
- SortVar:
str Variable by which to sort each sweep
- EqCons:
list[str] List of trajectory keys which must match (exactly) the first point in the sweep
- TolCons:
dict[float] Dictionary whose keys are trajectory keys which must match the first point in the sweep to a specified tolerance and whose values are the specified tolerances
- IndexTol:
int If specified, only trajectory points in the range
[i0,i0+IndexTol]are considered for the sweep
- cons:
- Outputs:
- J:
list(np.ndarray[int]) List of trajectory point sweeps
- J:
- Versions:
2015-05-25
@ddalle: v1.0
- GetTemperature(i=None, units=None)¶
Get static freestream temperature
- Call:
>>> T = x.GetTemperature(i)
- Inputs:
- x:
cape.runmatrix.RunMatrix Run matrix interface
- i: {
None} |int Case number (return all if
None)- units: {
None} |"mks"|"F"|"R" Output units
- x:
- Outputs:
- T:
float Static temperature [R | K]
- T:
- Versions:
2016-03-24
@ddalle: v1.02017-06-25
@ddalle: Added default i =None2018-04-13
@ddalle: Units
- GetTotalPressure(i=None, units=None)¶
Get freestream stagnation pressure (in psf or Pa)
- Call:
>>> p0 = x.GetTotalPressure(i)
- Inputs:
- Outputs:
- p0:
float Stagnation pressure [psf | Pa]
- p0:
- Versions:
2016-08-30
@ddalle: v1.02017-07-20
@ddalle: Added default cases2018-04-17
@ddalle: Added units
- GetTotalTemperature(i=None, units=None)¶
Get freestream stagnation temperature
- Call:
>>> T0 = x.GetTotalTemperature(i, units=None)
- Inputs:
- Outputs:
- T0:
float Freestream stagnation temperature [ R | K | units ]
- T0:
- Versions:
2016-08-30
@ddalle: v1.02017-07-20
@ddalle: Added default cases2018-04-17
@ddalle: Units
- GetUniqueGroupFolderNames(i=None)¶
Get unique names of folders that require separate meshes
- GetValue(k, I=None)¶
Get value(s) from a trajectory key, including derived keys
- Call:
>>> V = x.GetValue(k) >>> V = x.GetValue(k, I) >>> v = x.GetValue(k, i)
- Inputs:
- x:
RunMatrix Run matrix conditions interface
- k:
str RunMatrix key name
- i:
int Case index
- I:
np.ndarray(int) Array of case indices
- x:
- Outputs:
- V:
np.ndarray Array of values from one or more cases
- v:
np.any Value for individual case i
- V:
- Versions:
2018-10-03
@ddalle: v1.02019-06-19
@ddalle: Hooked toGetValue_Derived()
- GetValue_Derived(k, I=None)¶
Get value from a trajectory key, including derived keys
- Call:
>>> V = x.GetValue_Derived(k) >>> V = x.GetValue_Derived(k, I) >>> v = x.GetValue_Derived(k, i)
- Inputs:
- x:
dkit.runmatrix.RunMatrix Run matrix conditions interface
- k:
str Non-trajectory key name still described in x.defns
- i:
int Case index
- I:
np.ndarray(int) Array of case indices
- x:
- Outputs:
- V:
np.ndarray Array of values from one or more cases
- v:
np.any Value for individual case i
- V:
- Versions:
2019-06-19
@ddalle: v1.0 (CT only)
- GetVelocity(i=None, units=None)¶
Get velocity
- Call:
>>> U = x.GetVelocity(i)
- Inputs:
- Outputs:
- r:
float velocity [ m/s | ft/s | units ]
- r:
- Versions:
2018-04-13
@jmeeroff: v1.02018-04-17
@ddalle: Second method for units
- GetViscosity(i=None, units=None)¶
Get the dynamic viscosity for case(s) i
- MarkERROR(i: int, flag: str = 'E')¶
Mark a case as ERROR
- Call:
>>> x.MarkERROR(i, flag="E")
- Inputs:
- x:
cape.runmatrix.RunMatrix Instance of the trajectory class
- i:
int Index of the run case to print
- flag: {
"E"} |"e"``| ``"$E"|"ERROR" Marker to use to denote status
- x:
- Versions:
2019-06-14
@ddalle: v1.0
- MarkPASS(i: int, flag: str = 'p')¶
Mark a case as PASS
This result in a status of
PASS*if the case would is not otherwiseDONE.- Call:
>>> x.MarkPASS(i, flag="p")
- Inputs:
- x:
cape.runmatrix.RunMatrix Instance of the trajectory class
- i:
int Index of the run case to print
- flag: {
"p"} |"P"``| ``"$p"|"PASS" Marker to use to denote status
- x:
- Versions:
2019-06-14
@ddalle: v1.0
- ProcessGroups()¶
Split run matrix variables into groups
A “group” is a set of trajectory conditions that can use the same mesh or are just grouped in the same top-level folder.
- Call:
>>> x.ProcessGroups()
- Inputs:
- x:
cape.runmatrix.RunMatrix CAPE run matrix instance
- x:
- Effects:
Creates attributes that save the properties of the groups. These are called x.GroupKeys, x.GroupX, x.GroupID.
- Versions:
2014-06-05
@ddalle: v1.0
- ProcessKeyDefinitions(defns: dict)¶
Process definitions for each trajectory variable
Many variables have default definitions, such as
'Mach','alpha', etc. For user-defined trajectory keywords, defaults will be used for aspects of the definition that are missing from the inputs.- Call:
>>> x.ProcessKeyDefinitions(defns)
- Inputs:
- x:
cape.runmatrix.RunMatrix CAPE run matrix instance
- defns:
dict Dictionary of keyword definitions or partial definitions
- x:
- Effects:
- Versions:
2014-06-05
@ddalle: v1.02014-06-17
@ddalle: v2.0; usedefnsdict
- ReadRunMatrixFile(fname)¶
Read trajectory variable values from file
- Call:
>>> x.ReadRunMatrixFile(fname)
- Inputs:
- x:
cape.runmatrix.RunMatrix Instance of the trajectory class
- fname:
str Name of trajectory file
- x:
- Versions:
2014-10-13
@ddalle: v1.0; from __init__ method
- SetValue(k: str, i: int, v: Any, align: str = 'right')¶
Set the value of one key for one case to v
Also write the value to the appropriate line of text
- Call:
>>> x.SetValue(k, i, v, align="right")
- Inputs:
- Versions:
2019-06-14
@ddalle: v1.0
- UnmarkCase(i: int)¶
Unmark a case’s PASS or ERROR flag
- Call:
>>> x.UnmarkCase(i)
- Inputs:
- x:
cape.runmatrix.RunMatrix Instance of the trajectory class
- i:
int Index of the run case to print
- x:
- Versions:
2019-06-14
@ddalle: v1.0
- WriteConditionsJSON(i, fname='conditions.json')¶
Write a simple JSON file with exact trajectory variables
- WriteRunMatrixFile(fname=None)¶
Write run matrix values to file based on original text
Differences between the text and the working values (created by specifying values in the trajectory) are preserved.
- Call:
>>> x.WriteRunMatrixFile() >>> x.WriteRunMatrixFile(fname)
- Inputs:
- x:
cape.runmatrix.RunMatrix Instance of the trajectory class
- fname: {x.fname} |
str Name of trajectory file to write
- x:
- Versions:
2019-06-14
@ddalle: v1.0