2. Stable Simulations

2.1. AGX Dynamics

Algoryx Momentum is based on AGX Dynamics, which is a modern physics API for fast and stable rigid body simulations.

2.2. Simulation Frequency

The Simulation Frequency is the rate by which the simulation is executed. The resulting time step used for the simulation is \(\delta{t} = \dfrac{1}{SimulationFrequency}\). To achieve stable simulations, it is important to understand how the choosen Simulation Frequency can affect the result. Always strive to use the highest possible frequency, the higher, the more stable simulations. Collision detection relies on that all collisions can be caught during one step. So if a geometry is moving fast relative to its size, or collides with a relative small geometry, penetration, or tunneling effects can occur. This will result in large penetrations or even missed collisions. Large penetrations will create large forces that will try to restore the penetrated geometry outwards. Small objects/features will require higher frequencies to be resolved correctly. The default simulation frequency is 300Hz, corresponding to a time step of 3.33ms. The simulation frequency can be changed in the simulation frequency.

The Simulation Report can come to help in finding a suitable time step/simulation frequency based on the velocities and contacts during a simulation.

2.3. Solvers

AGX Dynamics consists of three different solvers: Split, Direct and Iterative.

By default all joints (hinge, prismatic, etc.) are solved with the direct and the iterative solver. For contact forces the Split solver is used, meaning all contact forces in normal direction are solved with the direct, and the friction forces with the iterative solver. This leads to fast and stable simulations which can handle large Mass ratio (differences in masses between interacting rigid bodies).

2.3.1. Iterative solver

An iterative solver gradually improves the solution with the number of iterations, and after a finite number of iterations it thus delivers a solution with finite precision. The most common type of iterative solver is the Gauss-Seidel relaxational method and an extension called Projected Gauss-Seidel (PGS) which is used to solve constrained linear systems of equations. It solves the equations one-by-one and updates all the dependent variables of the system before proceeding with the next equation. One iteration corresponds to a full pass through all the equations. Since the joint equations are treated one-by-one to solve for the joint force and corresponding updated velocity, and the information about this local solution propagates to the coupled equations, it is often referred to as an iterative impulse propagation method. However, the term propagation is somewhat misleading since the ordering of the equations is not well defined in PGS, so information propagates randomly, unless specifically ordered. Relaxational solvers are moderately efficient and conceptually simple, at least when the local joint violations are small, which is often true for systems with small mass ratios and weak couplings. Therefore they can be fast and efficient for large scale stacking problems with homogeneous types of bodies, while they are less efficient for e.g. lines and wires with large mass and force ratios, where they result in rubber band behavior unless the number of iterations is set to an extremely high value. They are also not so good at treating loop closures in physical systems, unless these problems are given special treatment.

2.3.2. Direct Solver

A direct solver finds the exact solution (down to machine precision) in a limited number of operations (provided there exist a well defined solution). For sparsely connected systems, a sparse type of solver is much preferred over a general dense solver, and can give enormous performance benefits. The chances of finding a proper physical solution are improved through regularization, which introduces an extra inverse mass/inertia term in all equations. Our direct solver computes solutions of quadratic programming (QP) problems using a block pivot method. This is similar to Newton-Raphson iterations without damping or line search and is generally very fast and almost always returns a good solution in just a few steps. The linear algebra operations rely on our own sparse symmetric indefinite factorization code which is tailored for multi-body dynamics, and can also handle ill-conditioned systems of equations arising from joint singularities, also known as gimbal lock. The overall algorithm is generally faster than publicly available QP solvers based on active set or interior point methods.

The direct solver is very robust and can handle large multi-body systems with very high mass ratios, and yet maintain joints accurately, to second order with respect to the time step. This is slower than the iterative solver but the latter makes larger errors and cannot process systems that have large mass ratios, or many joints. The simulation of a heavy vehicle for instance requires the direct solver for stability.

2.3.3. Split: Direct and iterative solver

The default solver in AGX Dynamics solves all constraints both in the iterative and the direct solver except for the normal forces for contacts. All joints are first solved directly, and then in a last pass, the normal and frictional contacts are solved. This results in a very fast solution, even for moderately large contact scenes with friction. For even larger systems with stacking etc, it is more efficient to select a pure iterative solution. Contacts and other joints can also be specified to be solved in the iterative mode for a faster, less accurate solution. Suitable for larger contact systems.

The split solver is slower than the purely iterative one, but it produces much better results with residual errors that are at least two orders of magnitude smaller. This generally produces more stable stacking with much better dry friction in general. Because of a fundamental mathematical limitation however, the direct solver becomes slower and slower for piling or volume filling configurations. The slowdown - the rate of change of the execution time divided by the number of objects - depends on the topology of the problem. It is worst for volume packing, moderate for planar constructions, i.e., walls, and nil for linear ones, i.e., stacks.

The execution time for the purely iterative solver grows only linearly with the number of bodies if the number of iterations is kept constant.

The most stable and accurate configuration is to use direct solver for all joints, including contacts. This can be selected in the Material Pairs.

2.3.4. Selecting solver

For contacts: In most cases the Split solver will do its job. However, assume you want to simulate a system with a large number of interacting objects, boxes on a conveyor belt for example. Then the iterative solver should be used to reduce the simulation time. If you notice anomalies in terms of unwanted friction behavior or instabilities then choose the Direct solver for contacts. The solver used for contacts can be specified in the Material Pairs settings.

For joints: Each joint in the system can be specified to use different solvers. This is however not recommended. A joint solved only with the direct solver will not see the forces calculated by the iterative solver which might introduce artifacts into the simulation.

2.4. Mass ratio

The default Split solver allows for large mass ratios. Up to 1:100.000 for certain settings can be solved in a stable manner.

However if you are using the iterative solver for joints and contacts the mass ratio between interacting bodies can become a problem. For an iterative solver (or when specifying joints to be solved iteratively) it is very important to keep the masses in the system in the same range of order of magnitude. For example a rigid body of mass 0.1 which interacts (collides with/is constrained to) with one that weighs 100 can cause instabilities due to large mass ratios when using the iterative solver. Try in this case to keep mass ratios as low as possible, or at least for interacting objects. Having objects with mass 1gram in the same simulation as objects with 100E10kg is ok, as long as they don’t interact with each other.

2.5. Size of objects and Velocities

Too small objects in comparison to their velocity and the simulation frequency can cause penetrations and missed collisions. Try to keep an eye on the size of geometries so they are not too small. It is important that the simulation frequency is high enough so that the smallest interacting feature in the system does not travel further than half its length during one time step. This will give you an upper bound on velocity, and a lower bound on simulation frequency.

2.6. Valid Initial States

When creating a simulation, it is important that the Initial State is valid. An example of an invalid state is when two geometries are positioned initially in contact. This can result in a “exploding” simulation, where the solver will try to push the two interacting geometries/bodies out of each other. Other examples of invalid initial states are when very large forces are applied to light rigid bodies. This can happen when motors on joints have large force ranges. Large initial velocities can cause simulation artifacts due to large interpenetration.

2.6.1. Multi-core support

Modern processors usually have two or more execution units, cores, which can be used to parallelize systems.

At the core of Algoryx Momentum AGX Dynamics will utilize the number of threads assigned. In Add-In Options you can specify the number of threads which are available for the physics engine. However, do not set a number larger than the number of hardware cores.

Attention

When simulating gears, set friction and restitution to zero to avoid any jamming artifacts due to the tessellation of the model.