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

Defines a CAPS problem object. More...

Public Member Functions

def __init__ (self, libDir=None, raiseException=True)
 Initialize the problem. More...
 
def loadCAPS (self, capsFile, projectName=None, verbosity=None)
 Loads a *.csm, *.caps, or *.egads file into the problem. More...
 
def setVerbosity (self, verbosityLevel)
 Set the verbosity level of the CAPS output. More...
 
def saveCAPS (self, filename="saveCAPS.caps")
 Save a CAPS problem. More...
 
def closeCAPS (self)
 Close a CAPS problem. More...
 
def dirtyAnalysis (self)
 Report what analyses loaded into the problem are dirty. More...
 
def loadAIM (self, kwargs)
 Load an AIM (Analysis Interface Module) into the problem. More...
 
def createDataTransfer (self, kwargs)
 Alteranative to createDataBound. More...
 
def createDataBound (self, kwargs)
 Create a CAPS data bound/transfer into the problem. More...
 
def createValue (self, name, data, units=None, limits=None, fixedLength=True, fixedShape=True)
 Create a CAPS value object. More...
 
def autoLinkValue (self, value=None)
 Create a link between a created CAPS value parameter and analyis inputs of all loaded AIMs, automatically. More...
 
def addAttribute (self, name, data)
 Add an attribute (that is meta-data) to the problem object. More...
 
def getAttribute (self, name)
 Get an attribute (that is meta-data) that exists on the problem object. More...
 
def createTree (self, filename="myProblem", kwargs)
 Create a HTML dendrogram/tree of the current state of the problem. More...
 

Public Attributes

 status
 Current CAPS status code.
 
 raiseException
 Raise an exception after a CAPS error is found (default - True). More...
 
 geometry
 Geometry object loaded into the problem. More...
 
 aimGlobalCount
 Number of AIMs loaded into the problem. More...
 
 analysisDir
 Current analysis directory which was used to load the latest AIM. More...
 
 capsIntent
 Current intent (analysisIntent+geometricRep) which was used to load the latest AIM. More...
 
 analysis
 Dictionary of analysis objects loaded into the problem. More...
 
 dataBound
 Dictionary of data transfer/bound objects loaded into the problem. More...
 
 value
 Dictionary of value objects loaded into the problem. More...
 

Static Public Attributes

dictionary analysisIntent
 Analysis intent dictionary. More...
 
dictionary geometricRep
 Geometry representation dictionary. More...
 

Detailed Description

Defines a CAPS problem object.

A capsProblem is the top-level object for a single mission/problem. It maintains a single set of interrelated geometric models (see pyCAPS._capsGeometry), analyses to be executed (see pyCAPS._capsAnalysis), connectivity and data (see pyCAPS._capsBound) associated with the run(s), which can be both multi-fidelity and multi-disciplinary.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  libDir = None,
  raiseException = True 
)

Initialize the problem.

See problem.py for a representative use case.

Parameters
libDirDeprecated option, no longer required.
raiseExceptionRaise an exception after a CAPS error is encountered (default - True). See raiseException .

Member Function Documentation

◆ addAttribute()

def addAttribute (   self,
  name,
  data 
)

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

See example problem7.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.

◆ autoLinkValue()

def autoLinkValue (   self,
  value = None 
)

Create a link between a created CAPS value parameter and analyis inputs of all loaded AIMs, automatically.

Valid CAPS value, parameter objects must be created with createValue(). Note, only links to ANALYSISIN inputs are currently made at this time. See value6.py for a representative use case.

Parameters
valueValue to use when creating the link (default - None). A combination (i.e. a single or list) of value dictionary entries and/or value object instances (returned from a call to createValue()) can be used. If no value is provided, all entries in the value dictionary (value) will be used.

◆ closeCAPS()

def closeCAPS (   self)

Close a CAPS problem.

See problem1.py for a representative use case.

◆ createDataBound()

def createDataBound (   self,
  kwargs 
)

Create a CAPS data bound/transfer into the problem.

Parameters
**kwargsSee below.

Valid keywords:

Parameters
capsBoundName of capsBound to use for the data bound.
variableNameSingle or list of variables names to add.
aimSrcSingle or list of AIM names that will be the data sources for the bound.
aimDestSingle or list of AIM names that will be the data destinations during the transfer.
transferMethodSingle or list of transfer methods to use during the transfer.
Returns
Optionally returns the reference to the data bound dictionary (dataBound) entry created for the bound class object (pyCAPS._capsBound).

◆ createDataTransfer()

def createDataTransfer (   self,
  kwargs 
)

Alteranative to createDataBound.

Enforces that at least 2 AIMs must be already loaded into the problem. See createDataBound for details.

◆ createTree()

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

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

See example problem6.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 - "myProblem"). 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 for each analysis entity (default - False).
internalGeomAttrShow the internal attributes (denoted by starting with an underscore, for example "_AttrName") that exist on the geometry (default - False).
reverseMapReverse the geometry attribute map (default - False).

◆ createValue()

def createValue (   self,
  name,
  data,
  units = None,
  limits = None,
  fixedLength = True,
  fixedShape = True 
)

Create a CAPS value object.

Only a value of subtype in PARAMETER is currently supported. See value.py for a representative use case. Value objects are stored the value dictionary.

Parameters
nameName used to define the value. This will be used as the keyword entry in the value dictionary.
dataData value(s) for the variable. Note that type casting in done automatically based on the determined type of the Python object. Be careful with the Integers and Floats/Reals, for example 10 would be type casted as an Integer, while 10.0 would be a float - this small discrepancy may lead to type errors when linking values to analysis inputs.
unitsUnits associated with the value (default - None).
limitsValid/acceptable range for the value (default - None).
fixedLengthShould the length of the value object be fixed (default - True)? For example if the object is initialized with a value of [1, 2] it can not be changed to [1, 2, 3].
fixedShapeShould the shape of the value object be fixed (default - True)? For example if the object is initialized with a value of 1 it can not be changed to [1, 2] or [[1, 2, 3], [4, 5, 6]] can not be changed to [[1, 2], [4, 5]].
Returns
Optionally returns the reference to the value dictionary (value) entry created for the value (pyCAPS._capsValue).

◆ dirtyAnalysis()

def dirtyAnalysis (   self)

Report what analyses loaded into the problem are dirty.

Returns
Optionally returns a list of names of the dirty analyses. An empty list is returned if no analyses are dirty.

◆ getAttribute()

def getAttribute (   self,
  name 
)

Get an attribute (that is meta-data) that exists on the problem object.

See example problem7.py for a representative use case.

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

◆ loadAIM()

def loadAIM (   self,
  kwargs 
)

Load an AIM (Analysis Interface Module) into the problem.

See examples problem3.py and problem4.py for typical representative use cases.

Parameters
**kwargsSee below.

Valid keywords:

Parameters
aimName of the requested AIM.
altNameAlternative name to use when referencing AIM inside the problem (dictionary key in analysis). The name of the AIM, aim, will be used if no $altName is provided (see remarks).
analysisDirDirectory for AIM analysis. If none is provided the directory of the last loaded AIM will be used; if no AIMs have been load the current working directory is used. CAPS requires that an unique directory be specified for each instance of AIM.
capsIntentAnalysis intention in which to invoke the AIM (see analysisIntent). If geometricRep is also specified this value will be augmented with it.
geometricRepGeometric representation to use (see geometricRep).
parentsSingle or list of parent AIM names to initilize the AIM with.
copyAIMName of AIM to copy. Creates the new AIM instance by duplicating an existing AIM. Analysis directory ($analysisDir) and $altName should be provided and different from the AIM being copied. See example analysis2.py for a representative use case.
copyParentsWhen copying an AIM, should the same parents also be used (default - True).
Returns
Optionally returns the reference to the analysis dictionary (analysis) entry created for the analysis class object (pyCAPS._capsAnalysis).
Remarks
If no $altName is provided and an AIM with the name, $aim, has already been loaded, an alternative name will be automatically specified with the syntax $aim_[instance number]. If an $altName is provided it must be unique compared to other instances of the loaded aim.

◆ loadCAPS()

def loadCAPS (   self,
  capsFile,
  projectName = None,
  verbosity = None 
)

Loads a *.csm, *.caps, or *.egads file into the problem.

See problem1.py, problem2.py, and problem8.py for example use cases.

Parameters
capsFileCAPS file to load. Options: *.csm, *.caps, or *.egads. If the filename has a *.caps extension the pyCAPS analysis, bound, and value objects will be re-populated (see remarks).
projectNameCAPS project name. projectName=capsFile if not provided.
verbosityLevel of output verbosity. See setVerbosity .
Returns
Optionally returns the reference to the geometry class object (pyCAPS._capsGeometry).
Remarks
Caveats of loading an existing CAPS file:
  • Can currently only load *.caps files generated from pyCAPS originally.
  • OpenMDAO objects won't be re-populated for analysis objects

◆ saveCAPS()

def saveCAPS (   self,
  filename = "saveCAPS.caps" 
)

Save a CAPS problem.

See problem8.py for example use case.

Parameters
filenameFile name to use when saving CAPS problem.

◆ setVerbosity()

def setVerbosity (   self,
  verbosityLevel 
)

Set the verbosity level of the CAPS output.

See problem5.py for a representative use case.

Parameters
verbosityLevelLevel of output verbosity. Options: 0 (or "minimal"), 1 (or "standard") [default], and 2 (or "debug").

Member Data Documentation

◆ aimGlobalCount

aimGlobalCount

Number of AIMs loaded into the problem.

◆ analysis

analysis

Dictionary of analysis objects loaded into the problem.

Set via loadAIM.

◆ analysisDir

analysisDir

Current analysis directory which was used to load the latest AIM.

◆ analysisIntent

dictionary analysisIntent
static
Initial value:
= {
'ALL' : cCAPS.ALL,
'WAKE' : cCAPS.WAKE,
'STRUCTURE' : cCAPS.STRUCTURE,
'LINEARAERO' : cCAPS.LINEARAERO,
'FULLPOTENTIAL' : cCAPS.FULLPOTENTIAL,
'CFD' : cCAPS.CFD
}

Analysis intent dictionary.

◆ capsIntent

capsIntent

Current intent (analysisIntent+geometricRep) which was used to load the latest AIM.

◆ dataBound

dataBound

Dictionary of data transfer/bound objects loaded into the problem.

Set via createDataBound or createDataTransfer.

◆ geometricRep

dictionary geometricRep
static
Initial value:
= {
'ALL' : cCAPS.ALL,
'NODE' : cEGADS.NODE,
'WIREBODY' : cEGADS.WIREBODY,
'FACEBODY' : cEGADS.FACEBODY,
'SHEETBODY': cEGADS.SHEETBODY,
'SOLIDBODY': cEGADS.SOLIDBODY
}

Geometry representation dictionary.

◆ geometry

geometry

Geometry object loaded into the problem.

Set via loadCAPS.

◆ raiseException

raiseException

Raise an exception after a CAPS error is found (default - True).

Disabling (i.e. setting to False) may have unexpected consequences; in general the value should be set to True.

◆ value

value

Dictionary of value objects loaded into the problem.

Set via createValue.


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