pyCAPS
pyCAPS: A Python Extension Module for CAPS
|
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... | |
Functions to interact with a CAPS analysis object.
Should be created with capsProblem.loadAIM (not a standalone class)
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.
name | Name used to define the attribute. |
data | Data value(s) for the attribute. Note that type casting in done automatically based on the determined type of the Python object. |
def aimBackDoor | ( | self, | |
JSONin | |||
) |
Alternative to backDoor().
Warning: May be deprecated in future versions.
def aimPostAnalysis | ( | self | ) |
Alternative to postAnalysis().
Warning: May be deprecated in future versions.
def aimPreAnalysis | ( | self | ) |
Alternative to preAnalysis().
Warning: May be deprecated in future versions.
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.
JSONin | JSON 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. |
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.
inputVariable | Input 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. |
outputVariable | Output variable(s)/parameter(s) to add to the OpenMDAO component. Only scalar output variables are currently supported |
**kwargs | See below. |
Valid keywords:
changeDir | Automatically switch into the analysis directory set for the AIM when executing an external code (default - True). |
saveIteration | If 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:
|
executeCommand | Command 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). |
inputFile | Optional 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. |
outputFile | Optional 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. |
stdin | Set I/O connection for the standard input of an ExternalCode component. The use of this depends on the expected AIM execution. |
stdout | Set I/O connection for the standard ouput of an ExternalCode component. The use of this depends on the expected AIM execution. |
setSensitivity | Optional 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 |
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.
filename | Filename to use when saving the tree (default - "aimName"). Note an ".html" is automatically appended to the name (same with ".json" if embedJSON = False). |
**kwargs | See below. |
Valid keywords:
embedJSON | Embed 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. |
internetAccess | Is internet access available (default - True)? If set to True internet access will be necessary to view the tree. |
analysisGeom | Show the geometry currently load into the analysis in the tree (default - False). |
internalGeomAttr | Show 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. |
reverseMap | Reverse the attribute map (default - False). See getAttributeMap for details. |
def getAnalysisInfo | ( | self, | |
printInfo = True , |
|||
kwargs | |||
) |
Gets analysis information for the analysis object.
See example analysis6.py for a representative use case.
printInfo | Print information to sceen if True. |
**kwargs | See below. |
Valid keywords:
infoDict | Return a dictionary containing analysis information instead of just the cleanliness state (default - False) |
def getAnalysisOutVal | ( | self, | |
varname = None , |
|||
kwargs | |||
) |
Gets an ANALYSISOUT variable for the analysis object.
varname | Name 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. |
**kwargs | See below. |
Valid keywords:
units | When 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). |
namesOnly | Return only a list of variable names (no values) if creating a dictionary (default - False). |
def getAnalysisVal | ( | self, | |
varname = None , |
|||
kwargs | |||
) |
Gets an ANALYSISIN variable for the analysis object.
varname | Name 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. |
**kwargs | See below. |
Valid keywords:
units | When 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). |
namesOnly | Return only a list of variable names (no values) if creating a dictionary (default - False). |
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.
name | Name of attribute to retrieve. |
def getAttributeMap | ( | self, | |
getInternal = False , |
|||
kwargs | |||
) |
Create geometric attribution map (embeded dictionaries) for the bodies loaded into the analysis.
Dictionary layout:
Dictionary layout (reverseMap = True):
getInternal | Get internal attributes (denoted by starting with an underscore, for example "_AttrName") that exist on the geometry (default - False). |
**kwargs | See below. |
Valid keywords:
reverseMap | Reverse the attribute map (default - False). See above table for details. |
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.
attributeName | Name of attribute to retrieve values for. |
**kwargs | See below. |
Valid keywords:
bodyIndex | Specific body in which to retrieve attribute information from. |
attrLevel | Level 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 |
def getSensitivity | ( | self, | |
inputVar, | |||
outputVar | |||
) |
Get sensitivity values.
Note the AIM must have aimBackdoor function to interact with.
inputVar | Input variable to retrieve the sensitivity with respect to. |
outputVar | Output variable to retrieve the sensitivity value for. |
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.
def postAnalysis | ( | self | ) |
Run the post-analysis function for the AIM.
def preAnalysis | ( | self | ) |
Run the pre-analysis function for the AIM.
If the specified analysis directory doesn't exist it will be made automatically.
def setAnalysisVal | ( | self, | |
varname, | |||
value, | |||
units = None |
|||
) |
Sets an ANALYSISIN variable for the analysis object.
varname | Name of CAPS value to set in the AIM. |
value | Value to set. Type casting is automatically done based on the CAPS value type |
units | Applicable units of the current variable (default - None). Only applies to real values. specified in the AIM. |
|
static |
Reference name of AIM loaded for the analysis object (see $altName).
|
static |
Analysis directory of the AIM loaded for the anlaysis object (see $analysis).
If the directory does not exist it will be made automatically.
Reference to the problem object that loaded the AIM during a call to capsProblem.loadAIM .
|
static |
Name of the AIM loaded for the anlaysis object (see $aim).
openMDAOComponent |
OpenMDAO "component" object (see createOpenMDAOComponent for instantiation).
|
static |
List of parents of the AIM loaded for the anlaysis object (see $parents).
|
static |
Unit system the AIM was loaded with (if applicable).