pyCAPS
pyCAPS: A Python Extension Module for CAPS
|
The following provides an overview of pyCAPS's services, with the intention being to emphasis and focus on basic, core functionality. As such not at all functions will be discussed. Users are encouraged to individually explore each classes documentation for a complete list of options.
The capsProblem class is the front end of pyCAPS. All other classes are intended to be initiated through the problem class. The following code details the primary function calls and uses when creating/setting up a new problem.
The first step to create a new capsProblem is to import the pyCAPS module; on Linux and OSx this is the pyCAPS.so file, while on Windows it is the pyCAPS.pyd file. For convenience, it is recommended that the path to this file is added to the environmental variable PYTHONPATH.
After the module is loaded, a new capsProblem class object should be instantiated (see pyCAPS.capsProblem.__init__). Note that multiple problems may be simultaneously loaded/exist in a single script.
Once a problem has been created the public attributes of the capsProblem are accessible.
After all desired operations on the problem are finished, it is recommended to close the problem (see pyCAPS.capsProblem.closeCAPS).
Putting it all together we get:
A geometry file is loaded into the problem using the loadCAPS() function for the problem (see pyCAPS.capsProblem.loadCAPS). In the example below a *.csm file, "./csmData/cfdMultiBody.csm", is loaded into our created problem from above. The project name "basicTest" may be optionally set here; if no argument is provided the CAPS file provided is used as the project name. A reference to the newly created geometry class (see pyCAPS._capsGeometry) is stored and accessed through the geometry attribute (pyCAPS.capsProblem.geometry)
Alternatively, a reference to the geometry class is also returned during a call to loadCAPS() and can be used to also access the geometry class. Both the above and below code snippets are equivalent.
Analysis interface modules (AIMs) are loaded in the problem using the loadAIM() function for the problem (see pyCAPS.capsProblem.loadAIM). In the code sample below, the "fun3dAIM" is loaded into the problem with a specified working directory and intention.
Since the "altName" keyword is being specified in the above snippet this analysis instance will be referenced/bookkept in the problem's analysis dictionary (pyCAPS.capsProblem.analysis) as "fun3d". For example,
results in,
Alternatively, a reference to the analysis class is also returned during a call to loadAIM() and can be used to also access the analysis class. Both the above and below code snippets are equivalent.
Once the geometry is loaded various functions are provided to interact with it (see pyCAPS._capsGeometry). The following sections highlight a few of the more common ones.
Geometric design parameters may be set using the setGeometryVal() function (pyCAPS._capsGeometry.setGeometryVal), while the current value of the parameter may be retrieved using getGeometryVal() (pyCAPS._capsGeometry.getGeometryVal). In the following example (geometry from Loading the geometry) the current value for the parameter "lesweep" is first obtained. The value is then reset and increased by 20.0.
The results from this snippet look like:
Within Python a picture of the current geometry may be viewed and/or saved using the viewGeometry() function (pyCAPS._capsGeometry.viewGeometry). A representative example of the function is as follows,
Upon execution of the above code an image of the current geometry is displayed on the screen (showImage = True). As seen below, all the bodies are combined (combineBodies = True) into a single image with four different view points (viewType = "fourview"). Since a filename is also provided, the imaged displayed on the screen is also saved.
Once an AIM has been loaded, various functions are provided to interact with it (see pyCAPS._capsAnalysis). The following sections highlight a few of the more common ones.
AIM inputs may be set using the setAnalysisVal() function (pyCAPS._capsAnalysis.setAnalysisVal), while the current value of the input may be retrieved using getAnalysisVal() (pyCAPS._capsAnalysis.getAnalysisVal). In the following example (AIM from Loading an AIM) the current value for the input "Proj_Name" is first obtained and is then reset.
The results from this snippet look like:
Similar to getAnalysisVal, the getAnalysisOutVal() function (pyCAPS._capsAnalysis.getAnalysisOutVal) returns AIM output variables.
For a given AIM, the CAPS pre- and post- analysis functions are executed in pyCAPS using the preAnalysis() (pyCAPS._capsAnalysis.preAnalysis) and postAnalysis() (pyCAPS._capsAnalysis.postAnalysis) functions.