Numerical Details

Mechanica implements a number of methods, conventions and strategies to provide a broad range of modeling and simulation features and necessary computational performance to support both interactive and high-cost simulation execution. This section describes the numerical details of Mechanica as relevant to building and executing models and simulations.

Cutoff Distance

Mechanica imposes a maximum distance within which two particles can interact, with the exception of bonded interactions, which are always imposed. If a potential or flux describes an interaction between the type(s) of two particles, the interaction can only occur if the two particles are separated by a distance less than the global cutoff distance. The global cutoff distance can be set when initializing Mechanica, and afterwards can be accessed but not changed (e.g., Universe property cutoff in Python).

  • In Python, the cutoff distance can be set with the init keyword argument cutoff.

  • In C++, the cutoff distance can be set with the MxUniverseConfig member cutoff.

  • In C, the cutoff distance can be set with the MxUniverseConfigHandle method MxCUniverseConfig_setCutoff.

Space Discretization

Much of Mechanica’s computational performance derives from task-based parallelism. The simulation domain of every Mechanica simulation is discretized into a grid of connected subspaces, called cells, and interactions are calculated between particles within the same cell, and between particles in connected cells (i.e., that share at least one point). However, interactions are not considered between particles in disconnected cells. As such, imposing a cutoff distance greater than the smallest length of a cell can lead to unexpected behavior in that Mechanica will not implement some defined interactions (e.g., interactions between particles within the cutoff distance, but in disconnected cells). Mechanica provides the ability to control the discretization of the simulation domain under the requirement that the discretization must contain at least three cells along each direction, and also with the recommendation that cells should be as cube-like as possible (cells with faces that are significantly different in size can introduce loss of interactions, due to reasons associated with improved computational performance).

  • In Python, the discretization can be set with the init keyword argument cells.

  • In C++, the discretization can be set with the MxUniverseConfig member spaceGridSize.

  • In C, the discretization can be set with the MxUniverseConfigHandle method MxCUniverseConfig_setCells.

Large Particles

A large particle is a particle with a radius greater than the cutoff distance. Mechanica provides limited support for large particles, and their simulation imposes significantly more computational cost than an ordinary particle. Large particles cannot interact with each other via potentials, and flux transport involving large particles does not occur. Futhermore, a particle that is determined to be a large particle during its creation is assumed to be a large particle for its lifetime, and likewise particles that are not large particles during their creation are assumed to remain as not large particles. In general, model specifications that prescribe large particles can be adjusted using a number of mechanisms provided by Mechanica, including changing the size of the simulation domain, overall scale of particle sizes and cutoff distance.