SimulationResults
Results ElementSimulationResults is a container object containing the results from a simulation. A simulation can contain many output time steps.
Class Name
SimulationResults
Description
- Results for all bodies
- Results for all Requests
- Results for all RVs
The population of the results data is automatically done by the model.simulate() method when it is invoked with returnResults=True.
Usage
#
# Generate a SimulationResults object
#
run = model.simulate (type="DYNAMICS", end=None, dtout=None, duration=None, steps=None, dsa="", start=None, onOutputStep=None, returnResults=True)
#
# Query simulationResults object for element specific data
#
BodyResult = run.getObject (a_specific_body)
ReqResult = run.getObject (a_specific_request)
RVResult = run.getObject (a_specific_rv)
#
# Extract time history of desired signal from element specific data
#
signal = BodyResult.getComponent ("body_attribute")
signal = ReqResult.getObject ("request_attribute")
signal = RVResult.getObject ("rv_attribute")
#
# Extract desired signal information for a specific step
#
data = BodyResult.getStep (step=timeStep)
data = ReqResult.getStep (step=timeStep)
data = RVResult.getStep (step=timeStep)
Attributes
- run
- SimulationResults Object.
- getObject
- Method on SimulationResults Object.
- getComponent
- Method on BodyResult, ReqResult and
RVResult
objects.
signal = BodyResult.getComponent ("body_attribute")
signal = ReqResult.getObject ("request_attribute")
signal = RVResult.getObject ("rv_attribute")
- getStep
- Method on BodyResult, ReqResult or
RVResult
objects.
data = BodyResult.getStep (step=timeStep)
data = ReqResult.getStep (step=timeStep)
data = RVResult.getStep (step=timeStep)
Example
Demonstrate the use of SimulationResults to create plots from MotionSolve results.
- Perform a dynamic simulation from 0 to 2 seconds with 200 output steps.
- Extract the time history for the FZ component of force request object forceRequest1
- Plot the FZ time history in Matplotlib
# Perform a simulation
run = M.simulate(type="DYNAMICS", end=2, steps=200,returnResults=True)
# Get the force request data from the run object
req = run.getObject (model.forceRequest1)
# Extract the time and FZ signals
times = req.getComponent ("times")
FZ = req.getComponent ("FZ")
# Plot the signal
import matplotlib.pyplot as plt
plotTitle = forceRequest1.label + " vs. Time"
plt.plot (times, FZ)
plt.title (plotTitle)
plt.xlabel("Time")
plt.ylabel ("force [N]")
plt.grid (True)
plt.show()
Comments
- See Properties for an explanation about what properties are, why they are used, and how you can extend these.
- The SimulationResults may be queried to get access to the time histories of its various components.