pyCAPS
pyCAPS: A Python Extension Module for CAPS
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
_capsAnalysis Class Reference

Functions to interact with a CAPS analysis object. More...

Public Member Functions

def setAnalysisVal (self, varname, value, units=None)
 Sets an ANALYSISIN variable for the analysis object. More...
 
def getAnalysisVal (self, varname=None, kwargs)
 Gets an ANALYSISIN variable for the analysis object. More...
 
def getAnalysisOutVal (self, varname=None, kwargs)
 Gets an ANALYSISOUT variable for the analysis object. More...
 
def getAnalysisInfo (self, printInfo=True, kwargs)
 Gets analysis information for the analysis object. More...
 
def getAttributeVal (self, attributeName, kwargs)
 Retrieve a list of geometric attribute values of a given name ("attributeName") for the bodies loaded into the analysis. More...
 
def getAttributeMap (self, getInternal=False, kwargs)
 Create geometric attribution map (embeded dictionaries) for the bodies loaded into the analysis. More...
 
def aimPreAnalysis (self)
 Alternative to preAnalysis(). More...
 
def preAnalysis (self)
 Run the pre-analysis function for the AIM. More...
 
def aimPostAnalysis (self)
 Alternative to postAnalysis(). More...
 
def postAnalysis (self)
 Run the post-analysis function for the AIM. More...
 
def createOpenMDAOComponent (self, inputVariable, outputVariable, kwargs)
 Create an OpenMDAO component object, an external code component (ExternalCode) is created if the executeCommand keyword arguement is provided. More...
 
def createTree (self, filename="aimName", kwargs)
 Create a HTML dendrogram/tree of the current state of the analysis. More...
 
def addAttribute (self, name, data)
 Add an attribute (that is meta-data) to the analysis object. More...
 
def getAttribute (self, name)
 Get an attribute (that is meta-data) that existS on the analysis object. More...
 
def getSensitivity (self, inputVar, outputVar)
 Get sensitivity values. More...
 
def aimBackDoor (self, JSONin)
 Alternative to backDoor(). More...
 
def backDoor (self, JSONin)
 Make a call to the AIM backdoor function. More...
 

Public Attributes

 capsProblem
 Reference to the problem object that loaded the AIM during a call to capsProblem.loadAIM . More...
 
 openMDAOComponent
 OpenMDAO "component" object (see createOpenMDAOComponent for instantiation). More...
 

Static Public Attributes

 aimName
 Reference name of AIM loaded for the analysis object (see $altName). More...
 
 officialName
 Name of the AIM loaded for the anlaysis object (see $aim). More...
 
 parents
 List of parents of the AIM loaded for the anlaysis object (see $parents). More...
 
 analysisDir
 Analysis directory of the AIM loaded for the anlaysis object (see $analysis). More...
 
 analysisIntent
 Analysis intent of the AIM loaded for the analysis object (see $capsIntent and $geometricRep)
 
 unitSystem
 Unit system the AIM was loaded with (if applicable). More...
 

Detailed Description

Functions to interact with a CAPS analysis object.

Should be created with capsProblem.loadAIM (not a standalone class)

Member Function Documentation

◆ addAttribute()

def addAttribute (   self,
  name,
  data 
)

Add an attribute (that is meta-data) to the analysis object.

See example analysis7.py for a representative use case.

Parameters
nameName used to define the attribute.
dataData value(s) for the attribute. Note that type casting in done automatically based on the determined type of the Python object.

◆ aimBackDoor()

def aimBackDoor (   self,
  JSONin 
)

Alternative to backDoor().

Warning: May be deprecated in future versions.

◆ aimPostAnalysis()

def aimPostAnalysis (   self)

Alternative to postAnalysis().

Warning: May be deprecated in future versions.

◆ aimPreAnalysis()

def aimPreAnalysis (   self)

Alternative to preAnalysis().

Warning: May be deprecated in future versions.

◆ backDoor()

def backDoor (   self,
  JSONin 
)

Make a call to the AIM backdoor function.

Important: it is assumed that the JSON string returned (JSONout) by the AIM is freeable.

Parameters
JSONinJSON string input to the backdoor function. If the value isn't a string (e.g. a Python dictionary) it will automatically be converted to JSON string.
Returns
Returns a Python object of the converted JSON out string from the back door function if any.

◆ createOpenMDAOComponent()

def createOpenMDAOComponent (   self,
  inputVariable,
  outputVariable,
  kwargs 
)

Create an OpenMDAO component object, an external code component (ExternalCode) is created if the executeCommand keyword arguement is provided.

Note that this functionality is currently tied to verison 1.7.3 of OpenMDAO (pip install openmdao==1.7.3), use of verison 2.x will result in an import error.

Parameters
inputVariableInput variable(s)/parameter(s) to add to the OpenMDAO component. Variables may be either analysis input variables or geometry design parameters. Note, that the setting of analysis inputs supersedes the setting of geometry design parameters; issues may arise if analysis input and geometry design variables have the same name. If the analysis parameter wanting to be added to the OpenMDAO component is part of a capsTuple the following notation should be used: "AnalysisInput:TupleKey:DictionaryKey", for example "AVL_Control:ControlSurfaceA:deflectionAngle" would correspond to the AVL_Control input variable, the ControlSurfaceA element of the input values (that is the name of the control surface being created) and finally deflectionAngle corresponds to the name of the dictionary entry that is to be used as the component parameter. If the tuple's value isn't a dictionary just "AnalysisInput:TupleKey" is needed.
outputVariableOutput variable(s)/parameter(s) to add to the OpenMDAO component. Only scalar output variables are currently supported
**kwargsSee below.

Valid keywords:

Parameters
changeDirAutomatically switch into the analysis directory set for the AIM when executing an external code (default - True).
saveIterationIf the generated OpenMDAO component is going to be called multiple times, the inputs and outputs from the analysis and the AIM will be automatically bookkept ( = True) by moving the files to a folder within the AIM's analysis directory ( analysisDir ) named "Iteration_#" were # represents the iteration number (default - False). By default ( = False) input and output files will be continously overwritten. Notes:
  • If the AIM has 'parents' their genertated files will not be bookkept.
  • If previous iteration folders already exist, the iteration folders and any other files in the directory will be moved to a folder named "Instance_#".
  • This bookkeeping method will likely fail if the iterations are run concurrently!
executeCommandCommand to be executed when running an external code. Command must be a list of command line arguements (see OpenMDAO documentation). If provided an ExternalCode object is created; if not provided or set to None a Component object is created (default - None).
inputFileOptional list of input file names for OpenMDAO to check the existence of before OpenMDAO excutes the "solve_nonlinear" (default - None). This is redundant as the AIM automatically does this already.
outputFileOptional list of output names for OpenMDAOto check the existence of before OpenMDAO excutes the "solve_nonlinear" (default - None). This is redundant as the AIM automatically does this already.
stdinSet I/O connection for the standard input of an ExternalCode component. The use of this depends on the expected AIM execution.
stdoutSet I/O connection for the standard ouput of an ExternalCode component. The use of this depends on the expected AIM execution.
setSensitivityOptional dictionary containing sensitivity/derivative settings/parameters. See OpenMDAO documentation for a complete list of "deriv_options". Common values for a finite difference calculation would be setSensitivity['type'] = "fd", setSensitivity['form'] = "forward" or "backward" or "central", and setSensitivity['step_size'] = 1.0E-6
Returns
Optionally returns the reference to the OpenMDAO component object created. "None" is returned if a failure occurred during object creation.

◆ createTree()

def createTree (   self,
  filename = "aimName",
  kwargs 
)

Create a HTML dendrogram/tree of the current state of the analysis.

See example analysis5.py for a representative use case. The HTML file relies on the open-source JavaScript library, D3, to visualize the data. This library is freely available from https://d3js.org/ and is dynamically loaded within the HTML file. If running on a machine without internet access a (miniaturized) copy of the library may be written to a file alongside the generated HTML file by setting the internetAccess keyword to False. If set to True, internet access will be necessary to view the tree.

Parameters
filenameFilename to use when saving the tree (default - "aimName"). Note an ".html" is automatically appended to the name (same with ".json" if embedJSON = False).
**kwargsSee below.

Valid keywords:

Parameters
embedJSONEmbed the JSON tree data in the HTML file itself (default - True). If set to False a seperate file is generated for the JSON tree data.
internetAccessIs internet access available (default - True)? If set to True internet access will be necessary to view the tree.
analysisGeomShow the geometry currently load into the analysis in the tree (default - False).
internalGeomAttrShow the internal attributes (denoted by starting with an underscore, for example "_AttrName") that exist on the geometry (default - False). Note: "analysisGeom" must also be set to True.
reverseMapReverse the attribute map (default - False). See getAttributeMap for details.

◆ getAnalysisInfo()

def getAnalysisInfo (   self,
  printInfo = True,
  kwargs 
)

Gets analysis information for the analysis object.

See example analysis6.py for a representative use case.

Parameters
printInfoPrint information to sceen if True.
**kwargsSee below.
Returns
Cleanliness state of analysis object or a dictionary containing analysis information (infoDict must be set to True)

Valid keywords:

Parameters
infoDictReturn a dictionary containing analysis information instead of just the cleanliness state (default - False)

◆ getAnalysisOutVal()

def getAnalysisOutVal (   self,
  varname = None,
  kwargs 
)

Gets an ANALYSISOUT variable for the analysis object.

Parameters
varnameName of CAPS value to retrieve from the AIM. If no name is provided a dictionary containing all ANALYSISOUT values is returned. See example analysis4.py for a representative use case.
**kwargsSee below.

Valid keywords:

Parameters
unitsWhen set to True returns the units along with the value as specified by the analysis. When set to a string (e.g. units="ft") the returned value is converted into the specified units. (default - False).
namesOnlyReturn only a list of variable names (no values) if creating a dictionary (default - False).
Returns
Value of "varname" or dictionary of all values. Units are also returned if applicable based on the "units" keyword (does not apply to dictionary returns).

◆ getAnalysisVal()

def getAnalysisVal (   self,
  varname = None,
  kwargs 
)

Gets an ANALYSISIN variable for the analysis object.

Parameters
varnameName of CAPS value to retrieve from the AIM. If no name is provided a dictionary containing all ANALYSISIN values is returned. See example analysis4.py for a representative use case.
**kwargsSee below.

Valid keywords:

Parameters
unitsWhen set to True returns the units along with the value as specified by the analysis. When set to a string (e.g. units="ft") the returned value is converted into the specified units. (default - False).
namesOnlyReturn only a list of variable names (no values) if creating a dictionary (default - False).
Returns
Value of "varname" or dictionary of all values. Units are also returned if applicable based on the "units" keyword (does not apply to dictionary returns).

◆ getAttribute()

def getAttribute (   self,
  name 
)

Get an attribute (that is meta-data) that existS on the analysis object.

See example analysis7.py for a representative use case.

Parameters
nameName of attribute to retrieve.
Returns
Value of attribute "name".

◆ getAttributeMap()

def getAttributeMap (   self,
  getInternal = False,
  kwargs 
)

Create geometric attribution map (embeded dictionaries) for the bodies loaded into the analysis.

Dictionary layout:

  • Body 1
    • Body : Body level attributes
    • Faces
      • 1 : Attributes on the first face of the body
      • 2 : Attributes on the second face of the body
      • " : ...
    • Edges
      • 1 : Attributes on the first edge of the body
      • 2 : Attributes on the second edge of the body
      • " : ...
    • Nodes :
      • 1 : Attributes on the first node of the body
      • 2 : Attributes on the second node of the body
      • " : ...
  • Body 2
    • Body : Body level attributes
    • Faces
      • 1 : Attributes on the first face of the body
      • " : ...
    • ...
  • ...

Dictionary layout (reverseMap = True):

  • Body 1
    • Attribute : Attribute name
      • Value : Value of attribute
        • Body : True if value exist at body level, None if not
        • Faces : Face numbers at which the attribute exist
        • Edges : Edge numbers at which the attribute exist
        • Nodes : Node numbers at which the attribute exist
      • Value : Next value of attribute with the same name
        • Body : True if value exist at body level, None if not
        • " : ...
      • ...
    • Atribute : Attribute name
      • Value : Value of attribute
        • " : ...
      • ...
  • Body 2
    • Attribute : Attribute name
      • Value : Value of attribute
        • Body : True if value exist at body level, None if not
        • " : ...
      • ...
    • ...
  • ...
Parameters
getInternalGet internal attributes (denoted by starting with an underscore, for example "_AttrName") that exist on the geometry (default - False).
**kwargsSee below.

Valid keywords:

Parameters
reverseMapReverse the attribute map (default - False). See above table for details.
Returns
Dictionary containing attribution map

◆ getAttributeVal()

def getAttributeVal (   self,
  attributeName,
  kwargs 
)

Retrieve a list of geometric attribute values of a given name ("attributeName") for the bodies loaded into the analysis.

Level in which to search the bodies is determined by the attrLevel keyword argument. See analysis3.py for a representative use case.

Parameters
attributeNameName of attribute to retrieve values for.
**kwargsSee below.
Returns
A list of attribute values.

Valid keywords:

Parameters
bodyIndexSpecific body in which to retrieve attribute information from.
attrLevelLevel to which to search the body(ies). Options:
0 (or "Body") - search just body attributes
1 (or "Face") - search the body and all the faces [default]
2 (or "Edge") - search the body, faces, and all the edges
3 (or "Node") - search the body, faces, edges, and all the nodes

◆ getSensitivity()

def getSensitivity (   self,
  inputVar,
  outputVar 
)

Get sensitivity values.

Note the AIM must have aimBackdoor function to interact with.

Parameters
inputVarInput variable to retrieve the sensitivity with respect to.
outputVarOutput variable to retrieve the sensitivity value for.
Returns
Sensitivity value.

Note for AIM developers:

This function makes use of the caps_AIMbackdoor function. The JSONin variable provided is a JSON dictionary with the following form - {"mode": "Sensitivity", "outputVar": outputVar, "inputVar": inputVar}. Similarly, a JSON dictionary is expected to return (JSONout) with the following form - {"sensitivity": sensitivityVal}; furthermore it is assumed that JSON string returned (JSONout) is freeable.

◆ postAnalysis()

def postAnalysis (   self)

Run the post-analysis function for the AIM.

◆ preAnalysis()

def preAnalysis (   self)

Run the pre-analysis function for the AIM.

If the specified analysis directory doesn't exist it will be made automatically.

◆ setAnalysisVal()

def setAnalysisVal (   self,
  varname,
  value,
  units = None 
)

Sets an ANALYSISIN variable for the analysis object.

Parameters
varnameName of CAPS value to set in the AIM.
valueValue to set. Type casting is automatically done based on the CAPS value type
unitsApplicable units of the current variable (default - None). Only applies to real values. specified in the AIM.

Member Data Documentation

◆ aimName

aimName
static

Reference name of AIM loaded for the analysis object (see $altName).

◆ analysisDir

analysisDir
static

Analysis directory of the AIM loaded for the anlaysis object (see $analysis).

If the directory does not exist it will be made automatically.

◆ capsProblem

Reference to the problem object that loaded the AIM during a call to capsProblem.loadAIM .

◆ officialName

officialName
static

Name of the AIM loaded for the anlaysis object (see $aim).

◆ openMDAOComponent

openMDAOComponent

OpenMDAO "component" object (see createOpenMDAOComponent for instantiation).

◆ parents

parents
static

List of parents of the AIM loaded for the anlaysis object (see $parents).

◆ unitSystem

unitSystem
static

Unit system the AIM was loaded with (if applicable).


The documentation for this class was generated from the following file: