jaxdem.utils.gridState#

Utility functions to initialize states with particles arranged in a grid.

Functions

grid_state(*, n_per_axis, spacing[, radius, ...])

Create a state where particles sit on a rectangular lattice.

jaxdem.utils.gridState.grid_state(*, n_per_axis: Sequence[int], spacing: Array | ndarray | bool | number | bool | int | float | complex, radius: float = 1.0, mass: float = 1.0, jitter: float = 0.0, vel_range: Array | ndarray | bool | number | bool | int | float | complex | None = None, radius_range: Array | ndarray | bool | number | bool | int | float | complex | None = None, mass_range: Array | ndarray | bool | number | bool | int | float | complex | None = None, seed: int = 0, key: Array | None = None) State[source][source]#

Create a state where particles sit on a rectangular lattice.

Random values can be sampled for particle radii, masses and velocities by specifying *_range arguments, which are interpreted as (min, max) bounds for a uniform distribution. When a range is not provided the corresponding radius or mass argument is used for all particles and the velocity components are sampled in [-1, 1].

Parameters:
  • n_per_axis (tuple[int]) – Number of spheres along each axis.

  • spacing (tuple[float] | float) – Centre-to-centre distance; scalar is broadcast to every axis.

  • radius (float) – Shared radius / mass for all particles when the corresponding range is not provided.

  • mass (float) – Shared radius / mass for all particles when the corresponding range is not provided.

  • jitter (float) – Add a uniform random offset in the range [-jitter, +jitter] for non-perfect grids (useful to break symmetry).

  • vel_range (ArrayLike | None) – (min, max) values for the velocity components, radii and masses.

  • radius_range (ArrayLike | None) – (min, max) values for the velocity components, radii and masses.

  • mass_range (ArrayLike | None) – (min, max) values for the velocity components, radii and masses.

  • seed (int) – Integer seed used when key is not supplied.

  • key (PRNG key, optional) – Controls randomness. If None a key will be created from seed.

Return type:

State