pyCAPS
pyCAPS: A Python Extension Module for CAPS
value2.py

Example use cases for interacting the a pyCAPS._capsValue object for setting the value.

1 from __future__ import print_function
2 
3 # Import pyCAPS module (Linux and OSx = pyCAPS.so file; Windows = pyCAPS.pyd file)
4 import pyCAPS
5 
6 # Instantiate our CAPS problem "myProblem"
7 print("Initiating capsProblem")
8 myProblem = pyCAPS.capsProblem()
9 
10 # Load a *.csm file "./csmData/cfdMultiBody.csm" into our newly created problem.
11 myGeometry = myProblem.loadCAPS("./csmData/cfdMultiBody.csm", "basicTest")
12 
13 # Create a value
14 myValue = myProblem.createValue("Altitude", [0.0, 30000.0, 60000.0], units="ft", limits=[0.0, 70000])
15 
16 print("Name = ", myValue.name)
17 print("Value = ", myValue.value)
18 print("Units = ", myValue.units)
19 print("Limits = ", myValue.limits)
20 
21 # Change the value
22 myValue.value = [0.0, 40000.0, 50000]
23 print("New Value = ", myValue.value)
24 
25 # Or change the value using the setVal() function - equivalent to the directly setting the value
26 myValue.setVal([0.0, 45000.0, 55000])
27 print("New Value = ", myValue.value)
28 
29 # Get the value using the getVal() function - equivalent to directly calling the value
30 print("Current Value = ", myValue.getVal())
31 
32 # Close our problems
33 print("Closing our problem")
34 myProblem.closeCAPS()
35