Model Object#
- class Model(**kwds)#
Model class is a container for all objects of a simulation.
- Parameters:
output – A string that defines the root name for all output files.
comment – A string that specifies a comment associated with the model.
- control(function, routine=None, script=None)#
Defines a control command for one or more simulations. The execution of the command is deferred to CONSUB.
- Parameters:
function (str) – The list of parameters that are passed to the user-defined subroutine.
routine (str) –
String containing the path of the DLL, followed by ‘::’ and the name of the Consub function.
A callable python function.
script (str) – Points to a file that contains the consub function defined in routine.
- generateOutput(visualize=False, timeout=None, verbosity_level=0)#
Creates plt and animation h3d files.
- Parameters:
visualize (bool) – If visualize argument is set to True, HyperView player is invoked and the h3d file of the model is loaded.
timeout (float) – A number indicating the time in seconds allowed for the execution.
verbosity_level (int) –
0 - No output is printed to the screen.
1 - Print only warnings to the screen.
2 - Print all messages to the screen
- generate_abcd(pinput=None, poutput=None, format='matlab', returnResults=False)#
Generate a state space representation of the model in the form of state matrices A, B, C, and D in the desired format.
- Parameters:
pinput (Pinput) – Reference to an existing Plant Input class used in State Space matrix generation.
poutput (Poutput) – Reference to an existing Plant Output class used in State Space matrix generation.
format (string) –
Format specifier for the ABCD State Space Representation. Valid choices are:
”oml”
”matlab”
”simulink_mdl”
returnResults (bool) – Flag to indicate that abcd matrix is to be returned to the caller.
- Returns:
A dict of matrix names to values (‘a’, ‘b’, ‘c’, ‘d’, ‘e’) if returnResults is True.
- generate_eigensolution(nodamping=False, kinetic=False, returnResults=False)#
Perform eigen-analysis of the model, generate eigenvalues and mode shapes.
- Parameters:
nodamping (bool) – Ignores damping for all forces during the eigenvalue solution.
kinetic (bool) – Specifies whether the modal kinetic energy distribution is written out.
returnResults (bool) – Flag to indicate that EigenValue data is to be returned to the caller.
- Returns:
A dict of vectors where the key is the name of the component [‘real’, ‘imag’, ‘freq’, ‘cratio’, ‘nat_freq’] and the value is a list of components for each mode.
Example
eigenInfo = model.simulate(type="LINEAR", returnResults=True) print (eigenInfo['freq']) # mode 0 mode 1 mode 2 mode 3 mode 4 mode 5 >> (1591.5494309, 1591.5494309, 1591.54989555, 5032.92486205, 5032.9448705, 5032.928844)
- reset(restart=True)#
Reset the model. Subsequent simulation commands will start at time = 0.
- runAllSimulationEvents()#
Run all the valid SimulationEvent objects sequentially.
- save_model(file)#
Saves a snapshot of the model.
- Parameters:
file – A string corresponding to the file being created on your filesystem. The file is created by the pickle module.
- simulate(type='DYNAMICS', end=None, dtout=None, duration=None, steps=None, dsa=None, start=None, print_increment=None, constraint_tol=None, implicit_diff_tol=None, onOutputStep=None, returnResults=False, output='on', validate=True, active_contact_iteration=False, numThread=-99999, acusolve_cosim=False, save_increment=None, save_inc_overwrite=False, **kwds)#
Sends the model to the solver and runs the simulation.
- Parameters:
type (Enum) –
The type of simulation. Valid choices are:
”ASSEMBLY”
”DYNAMICS”
”TRANSIENT”
”KINEMATICS”
”STATICS”
end (float) – The end time of the analysis.
dtout (float) – The print interval.
duration (float) – The duration of the analysis.
steps (int) – The number of output steps to take between start and end.
dsa (Enum) –
The type of design sensitivity analysis. Valid choices are:
”NONE”
”AUTO”
”DIRECT”
”ADJOINT”
”FD”
”FD_SERIAL”
start (float) – The start time of the analysis.
print_increment (float) – The frequency of output in terms of the integrator steps that have been taken.
constraint_tol (float) – The tolerance on all algebraic constraint equations that the corrector must satisfy at convergence.
implicit_diff_tol (float) – Modifies the accuracy to which implicit differential equations are to be satisfied.
onOutputStep (callable function) – Supply a callable UPOST function that you want to be called at every output step.
returnResults (bool) – Specifies if run data will be returned to the caller.
output (Enum) –
Specifies protocol of standard output. Valid choices are:
”on”
”off”
”fileonly”
validate (bool) – Specifies if the model will be validated before submission (default True).
numThread (int) – Specifies the number of threads for Open MP multithreaded contact simulation.
active_contact_iteration (bool) – Specifies whether the contact residual is being updated during the corrector step of the implicit solver and an analytical Jacobian is provided or not. A value of True means that the residual is being updated.
acusolve_cosim (bool) – Specifies if this simulation is a MotionSolve-AcuSolve co-simulation.
save_increment (int) – Dumps the XML file every save_increment multiple of print interval.
save_inc_overwrite (bool) – Overwrite the XML file each time or create a new one every save_increment with time stamp added to the file name.
- Returns:
- SimulationResults
Output states for Bodies, Requests and Rvs.
- verify(validate=True, **kwds)#
Sends the model to solver and performs a verification analysis. Validation of the model can be optionally skipped.
- Parameters:
validate (bool) – Specifies if model validation is to be performed.
- Returns:
- count (int)
Total number of kinematic independent coordinates computed by MotionSolve.