# Direct dynamics analysis¶

## Introduction¶

This tutorial introduces additional features of the Direct Dynamics module in Robotran.

For the basics use of direct dynamics, see the Pendulum-Spring tutorial Getting Started.

The programming language in this tutorial is **Python**.

All the detailed informations is given in the MBsysPy documentation. However, this tutorial gives some insights on some specific options.

Time integration

Integrator type

MBsysPy comes with different integrators (RK4, Dopri5…). The
selection of the integrator is done by setting
`mbs_dirdyn.set_options(integrator)`

to the wanted value. The list
of the available integrators is in the MBsysPy
documentation.

```
#...
# %%===========================================================================
# Direct Dynamics
# =============================================================================
# dirdyn options (see documentations for additional options)
mbs_dirdyn.set_options(integrator = "RK4")
#...
```

Other options have to follow the same syntax as above.

REMARK:

By default, the integrator is Runge Kutta with 4 steps

Integrators parameters

Depending on the integrators, various parameters can be chosen
(`toler`

, `dt_max`

, …). See MBsysPy
documentation.

Force the integrator to pass at specific time values

If you need an adaptive integrator to pass at some fixed time stepped
value (for example for a synchronization), you can activate the
`flag_waypoint`

in the options. Then the step size is defined in
the `delta_t_wp`

field. ..

Stiff systems

It is also possible to perform numerical stabilization based on
Baumgarte method
at the velocities and accelerations levels. See
`flag_baumgarte_stabilization`

and `baumgarte_alpha`

`baumgarte_beta`

options.

Jacobian calculation

For the implicit integrators, option `n_freeze`

may stop the
computation and compute it only each `n_freeze`

time. For example,
if `n_freeze = 1`

, the Jacobian will be computed every two time
steps.

Besides, the flag `flag_ongoing_jac_computation`

says when the
integrator is computing the Jacobian (==1) or when an internal step
is processed (==0). It allows to separate calculation between the two
situations. For example, if a FSM is used, it could be better not to
change the FSM state during the Jacobian computation.

Animation

Various options are available for customizing the animations saving
(see `resfilename`

, `respath`

, `save_anim`

, …).

Various

To make the computation time smaller, several flags allow to prevent Robotran from computing useless values.

`flag_compute_Qc`

and`compute_Qc`

: computation of the driven joint Lagrange multipliers`compute_all_uxd`

: computation of the user derivative