|
Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
|
Represents the simulation cell (periodic box). More...
#include <Cell.hpp>

Public Member Functions | |
Constructors | |
| Cell ()=default | |
| Cell (const math::Vector3< real_t > &vec_a, const math::Vector3< real_t > &vec_b, const math::Vector3< real_t > &vec_c) | |
| Constructs a Cell from three lattice vectors. | |
| Cell (const std::array< real_t, 6 > ¶ms) | |
| Constructs a Cell from lattice parameters {a, b, c, alpha, beta, gamma}. | |
| Cell (Cell &&other) noexcept=default | |
| Move constructor. Transfers ownership of lattice vectors and atom data. | |
| Cell & | operator= (Cell &&other) noexcept=default |
| Move assignment operator. | |
| Cell (const Cell &other)=default | |
| Copy constructor. | |
| Cell & | operator= (const Cell &other)=default |
| Copy assignment operator. | |
| ~Cell ()=default | |
| Destructor. | |
Accessors | |
| const std::array< real_t, 6 > & | latticeParameters () const noexcept |
| Gets the lattice parameters (a, b, c, alpha, beta, gamma). | |
| void | setLatticeParameters (const std::array< real_t, 6 > ¶ms) |
| const math::Matrix3< real_t > & | latticeVectors () const noexcept |
| Gets the lattice vectors as a 3x3 matrix. | |
| const math::Matrix3< real_t > & | inverseLatticeVectors () const noexcept |
| Gets the inverse lattice vectors as a 3x3 matrix. Useful for converting Cartesian coordinates to fractional coordinates. | |
| const real_t & | volume () const noexcept |
| Gets the volume of the simulation cell. | |
| const std::vector< Atom > & | atoms () const noexcept |
| Gets the list of atoms in the cell. | |
| std::vector< Atom > & | atoms () noexcept |
| Gets a mutable list of atoms in the cell. | |
| std::span< const Atom > | atomSpan () const noexcept |
| Gets an immutable span view over the atoms in the cell. | |
| std::span< Atom > | atomSpan () noexcept |
| Gets a mutable span view over the atoms in the cell. | |
| bool | hasVelocities () const noexcept |
| Checks whether lazy per-atom velocities have been allocated for this cell. | |
| const std::vector< math::Vector3< real_t > > & | velocities () const noexcept |
| Gets the contiguous lazy velocity buffer (empty if velocities were never set). | |
| math::Vector3< real_t > | atomVelocity (size_t atom_idx) const noexcept |
| Gets the velocity of a specific atom, returning {0, 0, 0} if unallocated. | |
| void | setAtomVelocity (size_t atom_idx, const math::Vector3< real_t > &vel) |
| Sets the velocity of a specific atom, lazily allocating velocities_ on first write. | |
| void | ensureVelocities () |
| Ensures the lazy velocity buffer is sized to match atomCount(). | |
| const std::vector< Element > & | elements () const noexcept |
| Gets the list of unique chemical elements in the cell. | |
| std::span< const Element > | elementSpan () const noexcept |
| Gets an immutable span view over unique chemical elements in the cell. | |
| size_t | atomCount () const noexcept |
| Gets the total number of atoms in the cell. | |
| bool | isEmpty () const noexcept |
| Checks whether the cell contains no atoms. | |
| std::optional< Element > | findElement (std::string_view symbol) const |
| Finds the Element properties for a given element symbol. | |
| bool | renameElement (std::string_view old_symbol, std::string_view new_symbol) |
| Renames an existing element species in-place across all atoms in the cell. | |
Methods | |
| math::Vector3< real_t > | minimumImage (const math::Vector3< real_t > &distance) const |
| Applies the minimum image convention to a distance vector. | |
| Atom & | addAtom (std::string_view symbol, const math::Vector3< real_t > &position) |
| Adds a new atom to the cell. The atom's element type is automatically registered if it's the first mention of this symbol. | |
| void | wrapPositions () |
| Applies periodic boundary conditions to all atom positions. Wraps all atoms back into the primary simulation cell [0, 1) in fractional coordinates. | |
| std::array< real_t, 3 > | perpendicularWidths () const noexcept |
| Computes the perpendicular widths (interplanar spacing) between opposing cell faces. | |
| Cell | replicate (int rep_a, int rep_b, int rep_c) const |
| Replicates the simulation cell na x nb x nc times along lattice vectors. | |
| Cell | autoSupercell (real_t r_cut, int max_replication=10, real_t max_radius=correlation::math::MAX_CUTOFF_RADIUS) const |
| Automatically expands the cell to satisfy the Minimum Image Convention for cutoff r_cut. | |
| void | setEnergy (real_t energy) noexcept |
| Sets the energy of the cell frame. | |
| real_t | getEnergy () const noexcept |
| Gets the energy of the cell frame. | |
| void | reserveAtoms (std::size_t count) |
| Reserves capacity for atom storage to minimize reallocations. | |
| void | updateLattice (const math::Matrix3< real_t > &new_lattice) |
| Updates lattice vectors and recomputes volume, inverse matrix, and scalar parameters. | |
Private Member Functions | |
| void | updateLatticeParametersFromVectors () |
| Internal helper to synchronize scalar parameters with vector matrix. | |
| const Element & | getOrRegisterElement (std::string_view symbol) |
| Registers an element symbol if not already present and returns its Element reference. | |
Private Attributes | |
| math::Matrix3< real_t > | lattice_vectors_ |
| Basis vectors of the box. | |
| math::Matrix3< real_t > | inverse_lattice_vectors_ |
| Inverse matrix for fractional mapping. | |
| std::array< real_t, 6 > | lattice_parameters_ {} |
| {a, b, c, alpha, beta, gamma}. | |
| real_t | volume_ {0.0} |
| Cached volume in Angstroms^3. | |
| real_t | energy_ {0.0} |
| Potential energy of this specific coordinate set. | |
| std::vector< Atom > | atoms_ |
| Collection of atoms in the cell. | |
| std::vector< Element > | elements_ |
| Unique elements present in the system. | |
| std::vector< math::Vector3< real_t > > | velocities_ |
| Lazy per-atom velocities/forces (0 B when unused). | |
Represents the simulation cell (periodic box).
This class handles the lattice vectors, periodic boundary conditions, and stores the atoms contained within the cell.
|
explicitdefault |

|
explicit |
Constructs a Cell from three lattice vectors.
| vec_a | The first lattice vector. |
| vec_b | The second lattice vector. |
| vec_c | The third lattice vector. |

|
explicit |
Constructs a Cell from lattice parameters {a, b, c, alpha, beta, gamma}.
| params | An array containing the six lattice parameters:
|

|
defaultnoexcept |
Move constructor. Transfers ownership of lattice vectors and atom data.
| other | Cell object to move from. |

|
default |
Copy constructor.
| other | Cell object to copy from. |

|
default |
Destructor.
| Atom & correlation::core::Cell::addAtom | ( | std::string_view | symbol, |
| const math::Vector3< real_t > & | position ) |
Adds a new atom to the cell. The atom's element type is automatically registered if it's the first mention of this symbol.
| symbol | The chemical element symbol (e.g. "Fe"). |
| position | The Cartesian position [x, y, z] in Angstroms. |


|
inlinenodiscardnoexcept |
Gets the total number of atoms in the cell.

|
inlinenodiscardnoexcept |
Gets the list of atoms in the cell.

|
inlinenodiscardnoexcept |
Gets a mutable list of atoms in the cell.
|
inlinenodiscardnoexcept |
Gets an immutable span view over the atoms in the cell.
|
inlinenodiscardnoexcept |
Gets a mutable span view over the atoms in the cell.
|
inlinenodiscardnoexcept |
Gets the velocity of a specific atom, returning {0, 0, 0} if unallocated.
| [in] | atom_idx | Zero-based atom index. |

|
nodiscard |
Automatically expands the cell to satisfy the Minimum Image Convention for cutoff r_cut.
Computes minimal replication factors along each axis such that every perpendicular width satisfies w_k >= 2 * r_cut, up to safety limits.
| r_cut | Interaction or evaluation cutoff radius in Angstroms. |
| max_replication | Maximum allowable replication factor per axis (default: 10). |
| max_radius | Maximum allowable cutoff radius ceiling (default: 50.0 Angstroms). |
| std::invalid_argument | If r_cut > max_radius or required replication exceeds max_replication. |

|
inlinenodiscardnoexcept |
Gets the list of unique chemical elements in the cell.

|
inlinenodiscardnoexcept |
Gets an immutable span view over unique chemical elements in the cell.

|
inline |
Ensures the lazy velocity buffer is sized to match atomCount().
|
nodiscard |
|
inlinenodiscardnoexcept |
Gets the energy of the cell frame.

|
private |
|
inlinenodiscardnoexcept |
Checks whether lazy per-atom velocities have been allocated for this cell.

|
inlinenodiscardnoexcept |
Gets the inverse lattice vectors as a 3x3 matrix. Useful for converting Cartesian coordinates to fractional coordinates.

|
inlinenodiscardnoexcept |
Checks whether the cell contains no atoms.

|
inlinenodiscardnoexcept |
Gets the lattice parameters (a, b, c, alpha, beta, gamma).

|
inlinenodiscardnoexcept |
Gets the lattice vectors as a 3x3 matrix.

|
nodiscard |
Applies the minimum image convention to a distance vector.
Finds the shortest distance vector between two points under periodic boundary conditions.
| distance | The Cartesian distance vector to wrap. |


Move assignment operator.
| other | Cell object to move from. |

Copy assignment operator.
| other | Cell object to copy from. |

|
nodiscardnoexcept |
Computes the perpendicular widths (interplanar spacing) between opposing cell faces.
For lattice vectors a, b, c with volume V, returns {V / ||b x c||, V / ||a x c||, V / ||a x b||}. If volume is non-positive or vectors are degenerate, returns {0, 0, 0}.


| bool correlation::core::Cell::renameElement | ( | std::string_view | old_symbol, |
| std::string_view | new_symbol ) |
Renames an existing element species in-place across all atoms in the cell.
| old_symbol | Existing element symbol (e.g., "1"). |
| new_symbol | Replacement element symbol (e.g., "Cu"). |

|
nodiscard |
Replicates the simulation cell na x nb x nc times along lattice vectors.
| rep_a | Replication factor along lattice vector a (>= 1). |
| rep_b | Replication factor along lattice vector b (>= 1). |
| rep_c | Replication factor along lattice vector c (>= 1). |
| std::invalid_argument | If any factor is < 1 or total atom count exceeds 50,000. |


|
inline |
Reserves capacity for atom storage to minimize reallocations.
| count | Expected number of atoms. |

|
inline |
Sets the velocity of a specific atom, lazily allocating velocities_ on first write.
| [in] | atom_idx | Zero-based atom index. |
| [in] | vel | Velocity vector. |

|
inlinenoexcept |
Sets the energy of the cell frame.
| energy | The energy value. |


| void correlation::core::Cell::setLatticeParameters | ( | const std::array< real_t, 6 > & | params | ) |


| void correlation::core::Cell::updateLattice | ( | const math::Matrix3< real_t > & | new_lattice | ) |
Updates lattice vectors and recomputes volume, inverse matrix, and scalar parameters.
| new_lattice | New 3x3 lattice matrix. |


|
private |
Internal helper to synchronize scalar parameters with vector matrix.


|
inlinenodiscardnoexcept |
Gets the contiguous lazy velocity buffer (empty if velocities were never set).
|
inlinenodiscardnoexcept |
Gets the volume of the simulation cell.

| void correlation::core::Cell::wrapPositions | ( | ) |
Applies periodic boundary conditions to all atom positions. Wraps all atoms back into the primary simulation cell [0, 1) in fractional coordinates.


|
private |
Collection of atoms in the cell.
|
private |
Unique elements present in the system.
|
private |
Potential energy of this specific coordinate set.
|
private |
Inverse matrix for fractional mapping.
|
private |
{a, b, c, alpha, beta, gamma}.
|
private |
Basis vectors of the box.
|
private |
Lazy per-atom velocities/forces (0 B when unused).
|
private |
Cached volume in Angstroms^3.