grid_positions_in_cell¶
- jaxrens.init.positions.grid_positions_in_cell(key, cell, n_atoms, min_distance)[source]¶
Pick n_atoms sites on a regular grid spaced by min_distance.
Grid counts per axis are derived from cell edge lengths (||a||, ||b||, ||c||) divided by min_distance, floored to an integer. Grid sites are built in fractional coordinates using numpy (the integer index ranges are Python-side scalars), at the centre of each grid cell, then jax.random.choice selects n_atoms sites without replacement. Conversion to Cartesian uses selected @ cell.
The spacing along each edge is at least min_distance, but the distance between sites that differ along several axes is not checked. In an oblique cell, for example one with two nearly parallel edges, some pairs of sites can be closer than min_distance. The guarantee holds for orthogonal cells.
- Parameters:
- Returns:
(n_atoms, 3) Cartesian positions.
- Return type:
- Raises:
ValueError – If the grid cannot fit n_atoms at the given min_distance.