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

At each output time, the following information is stored:
  • Results for all bodies
  • Results for all Requests
  • Results for all RVs
The structure of SimulationResults is shown below.


Figure 1.

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.
Generated by the simulate method.
run=model.simulate (type="DYNAMICS", end=None, dtout=None, duration=None, steps=None, dsa="", start=None, onOutputStep=None, returnResults=False)

Upon completion of a simulation, the simulate method returns the entire time history of the simulation in a SimulationResults object -- a container that holds all BodyResults, RequestResults and RVResults. These results are generated only when returnResults=True.

getObject
Method on SimulationResults Object.
BodyResult = run.getObject (a_specific_body)
ReqResult  = run.getObject (a_specific_request)
RVResult   = run.getObject (a_specific_rv)
This method queries theSimulationResults object and returns the results for a specific Body (BodyResult), a specific Request (RequestResult) or a specific RV (RVResult).

getObject should be called only when returnResults=True for the simulation.

getComponent
Method on BodyResult, ReqResult and RVResult objects.
signal = BodyResult.getComponent ("body_attribute")
signal = ReqResult.getObject     ("request_attribute")
signal = RVResult.getObject      ("rv_attribute")
This method queries a BodyResult, ReqResult or RVResult object and returns the time history of a specific attribute of the object. For a complete list of attributes for each type of result, see BodyResult, RequestResult and RVResult.
getComponent should be called only when returnResults=True for the simulation.
getStep
Method on BodyResult, ReqResult or RVResult objects.
data = BodyResult.getStep (step=timeStep)
data = ReqResult.getStep  (step=timeStep)
data = RVResult.getStep   (step=timeStep)
This method queries a BodyResult, ReqResult or RVResult object and returns all of its data for a specific time step. For a complete list of attributes for each type of result, see BodyResult, ReqResult or RVResult.

getStep should be called only when returnResults=True for the simulation.

Example

Demonstrate the use of SimulationResults to create plots from MotionSolve results.

Create a model, M. Then:
  • 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

  1. See Properties for an explanation about what properties are, why they are used, and how you can extend these.
  2. The SimulationResults may be queried to get access to the time histories of its various components.