Results
Once the model is solved, it’s time to plot the results. With Python code results can be displayed as in the GUI, by listing, plotting, or obtain specific results of a particular node or element. First step is to open the results file which we want to get the data from, giving the path or just the name and file extension as it is stored in the same location where the model was saved. General Results After opening the result file to get general results, set the results to be shown. To do this is necessary to set: the Result Type (“NodeResults”, “ElementResults” or “EndResults”), the Result Enumerate (the argument names are place in the Script Manual), and optionally the Result Entity Type (“Nodal”, “Truss”, “Beam”, “Shell”, “Solid”) and the Units (the argument names are place in the Script Manual. An example of results of the nodal displacement of the X component in a beam, shown in mm:
openResultsFile("ExampleResults.rcf")
setResult("NodeResults", "UTx", "Beam", "mm")
Once the results want to be shown are set, you can list and plot them as follows:
listResults()
plotResults()
Results Data
You can also get specific data from a node or a particular element, stored in memory for a later export or to be displayed in the Output Window by the Python command “print”. First get the data from the results file:
res = getResults("ExampleResults.rcf")
Nodal Results: Get the displacement of the X component in the node 3.
iNode = Double(0.0)
res.getNodeResult(iNode, "UTx", 3)
print(str(iNode.getValue()))
Element Results: Get the X component of stress in the element 1, extreme 1 and first integer point.
iElement = Double(0.0)
res.getElementResult(iElement, "Sx", 1, 1, 1)
print(str(iElement.getValue()))
End Results: Get the direct membrane force per width unit in local X-direction in the element 1 and extreme 1
iEnd = Double(0.0)
res.getEndResult(iEnd, "SF1", 1, 1)
print(str(iEnd.getValue()))
Checking results are given by end results, so if you want to get them only is needed to use checking enumerate results in end results commands. On the other hand, in case of shaping a solid section, two new different types of result will be performed in the drop: Solid section result and Solid section IP result. Solid Section Results: Get the bending moment about the local Z-axis in a detailed solid section, on the section number 4.
iSS = Double(0.0)
res.getSolidSectionResult(iSS, "SM1",4)
print(str(iSS.getValue()))
Moreover, the information included in the info results inform may be displayed in the Output by following the next steps:
Header Results: Get the Mass value in the X direction.
imassX = Double(0.0)
res.getHeaderResult(imassX, "MassX")
print(str(iSS.getValue()))
Maximum and Minimum Results: Get the maximum or minimum results and get its location.
filterSEs = ["Solid 3D (2)", "Solid 3D"]
max_result = Double(0.0)
max_element_num = Int(0)
max_end_num = Int(0)
res.getMaxEndResult("Sx", "Pa", max_result, max_element_num, max_end_num, filterSEs)
min_result = Double(0.0)
min_element_num = Int(0)
min_end_num = Int(0)
res.getMinEndResult("Sx", "Pa", min_result, min_element_num, min_end_num, filterSEs)
If you need to retrieve the structural element object:
max_element_obj = getElement(max_element_num.getValue())
max_structural_element = max_element_obj.StructuralElement
There are also functions for node or integration point results:
max_result = Double(0.0)
max_element_num = Int(0)
max_end_num = Int(0)
max_ip_num = Int(0)
res.getMaxElementResult("Sx", "Pa", max_result, max_element_num, max_end_num, max_ip_num, [])
max_result = Double(0.0)
max_node_num = Int(0)
res.getMaxNodeResult("UTx", "m", max_result, max_node_num, [])
User Results
The user can create a new result or edit an existing result of a result file. This capability is performed through the result object obtained with the getResults method:
res = getResults("ExampleResults.rcf")
To create or modify any result, the number of results to set has to be the same as the number of results saved in the result file. This number can be known by the “get” methods of the result object:
Nodal Results: Get the displacement of the X component in all nodes.
UtxRes = []
UtxRes = res.getNodeResults("UTx")
print(len(UtxRes))
Element Results: Get the X component of stress in all beam elements.
SxBeam = []
SxBeam = res.getElementResults("Sx","Beam" )
print(len(SxBeam))
End Results: Get the direct membrane force per width unit in local X-direction in all shell elements
TxShell = []
TxShell = res.getEndResults("SF1","Shell" )
print(len(TxShell))
Solid section Results: Get the bending moment about the local Z-axis in a detailed solid section.
MzSolidSec = []
MzSolidSec = res.getSolidSectionResults("SM2") print(len(MzSolidSec))
The “Get” methods are also useful to create the new results. For example if Tresca criterion is required, we can use the maximum and minimum principal stresses to create the new result:
Add Result: Creates new result: addNodeResult/addEndResult/addElement
TrescaValues = []
SigMax = res.getEndResults("SP3","Solid" )
SigMin = res.getEndResults("SP1","Solid" )
for i in range(len(SigMax)):
TrescaValues.append(Double((SigMax[i]-SigMin[i])/2.0))
res.addEndResult("Tresca","Solid", "Pa", TrescaValues)
If the user requires to change any result, the “Set” methods will be the most suitable tool in order to carry out this purpose. These methods allow modifying any existing result, not only by carrying through a setNodeResult/setEndresult/setElement but also running a setEndResultOnElement/ setElementResultOnElement/setNodeResultOnNode at a specific element or node. For example if the user wants to increase the bending moment by a factor:
Set Result: Modify an existing result: setNodeResult/setEndresult/setElement
MzIncreased = []
Mz = res.getEndResults("SM2","Beam")
for i in range(len(Mz)):
MzIncreased.append(Double(1.1 * Mz[i].getValue()))
res.setEndResult("SM2","Beam","Nxm", MzIncreased)
On the other hand, if changing any result would be required for a specific element or node on a shell element:
Set Result: Modify an existing result on any element or node: setEndResultOnElement/setElementResultOnElement/setNodeResultOnNode
newEndRes = res.getEndResults("SF4", "Shell")
res.addEndResult("New_NY","Shell","N_m",newEndRes)
res.setEndResultOnElement("New_NY","Shell","N_m",5, 3, Double(10.5))
Erase Result: Removed an existing result: eraseElementResults/eraseNodeResults/eraseEndResults/eraseSolidSectionResults
newEndRes = res.getEndResults("SF4", "Shell")
bErased = res.eraseEndResults("SF4", "Shell")
bExist = res.hasEndResults("SF4", "Shell")
Has Result: Check the presence of a result: hasElementResults/hasNodeResults/hasEndResults/hasSolidSectionResults
newEndRes = res.getEndResults("SF4", "Shell")
bExist = res.hasEndResults("SF4", "Shell")
With these tools the user has total control over the management of results, the only limit being his imagination.
History Results
History results usability can be handled via Python with an object:
# Create the object
hr = HistoryResult()
# Add files to the object
hr.addResultFile(r"C:\Examples\LC1.rcf")
hr.addResultFile(r"C:\Examples\LC2.rcf")
hr.addResultFile(r"C:\Examples\LC3.rcf")
hr.addResultFile(r"C:\Examples\LC4.rcf")
# Create 3 variables
var1 = hr.createVariable()
hr.setName(var1, "Var1")
hr.setNode(var1, 1)
hr.setResultInfo(var1, "NodeResult", "UTx")
hr.setResultUnit(var1, "dm")
var2 = hr.createVariable()
hr.setName(var2, "Var2")
hr.setElement(var2, 1)
hr.setEnd(var2, 1)
hr.setResultInfo(var2, "ElementResult", "SF1")
var3 = hr.createVariable()
hr.setName(var3, "Var3")
hr.setElement(var3, 1)
hr.setEnd(var3, 1)
hr.setIP(var3, 0)
hr.setResultInfo(var3, "EndResult", "Sx")
# Plot or list
plotHR("MyPlot", [0,1,2,3])
listHR("MyList", [0,1,2,3])