rejection_sample_positions

jaxrens.init.rejection.rejection_sample_positions(key, *, cell, types, n_atoms, energy_fn, start_energy_ceiling, min_distance, max_tries, mode, grid_distance)[source]

Draw and reject positions until a valid configuration is found.

Loop: draw positions (uniform or grid), evaluate energy + pair distances via a JIT-compiled inner check, accept if all criteria pass.

Parameters:
  • key (Array) – JAX PRNG key.

  • cell (Array) – (3, 3) cell matrix.

  • types (Array) – (n_atoms,) int32 type indices.

  • n_atoms (int) – Number of atoms.

  • energy_fn (Callable) – Callable (positions, types, cell, max_neighbors) -> BackendResult. Should already have backend kwargs bound.

  • start_energy_ceiling (float) – Absolute energy ceiling for the whole configuration.

  • min_distance (float) – Minimum allowed interatomic distance under PBC.

  • max_tries (int) – Maximum number of draw attempts before raising RuntimeError.

  • mode (Literal['uniform', 'grid']) – “uniform” or “grid”.

  • grid_distance (float) – Grid spacing for grid mode (used by grid_positions_in_cell).

Returns:

(n_atoms, 3) and scalar jnp.ndarray.

Return type:

(positions, energy)

Raises:
  • RuntimeError – If max_tries attempts all fail, with per-reason counters.

  • ValueError – (re-raised) if grid is too coarse to fit n_atoms.