57 explicit Cell(
const std::array<real_t, 6> ¶ms);
137 [[nodiscard]]
const std::vector<Atom> &
atoms() const noexcept {
return atoms_; }
143 [[nodiscard]] std::vector<Atom> &
atoms() noexcept {
return atoms_; }
168 [[nodiscard]]
const std::vector<math::Vector3<real_t>> &
velocities() const noexcept {
188 if (atom_idx >=
atoms_.size()) {
237 [[nodiscard]] std::optional<Element>
findElement(std::string_view symbol)
const;
245 bool renameElement(std::string_view old_symbol, std::string_view new_symbol);
299 [[nodiscard]]
Cell replicate(
int rep_a,
int rep_b,
int rep_c) const;
364 std::vector<math::Vector3<real_t>>
Atom data structure and AtomID type definitions.
Mathematical and physical constants for the Correlation tool.
Lightweight 3D vector and matrix classes for geometric calculations.
Floating point precision type definitions for Correlation.
Represents an atom in the simulation cell.
Definition Atom.hpp:183
Represents the simulation cell (periodic box).
Definition Cell.hpp:30
bool hasVelocities() const noexcept
Checks whether lazy per-atom velocities have been allocated for this cell.
Definition Cell.hpp:162
std::vector< Atom > atoms_
Collection of atoms in the cell.
Definition Cell.hpp:362
real_t energy_
Potential energy of this specific coordinate set.
Definition Cell.hpp:361
void wrapPositions()
Applies periodic boundary conditions to all atom positions. Wraps all atoms back into the primary sim...
Definition Cell.cpp:240
std::vector< Element > elements_
Unique elements present in the system.
Definition Cell.hpp:363
Cell(const Cell &other)=default
Copy constructor.
std::array< real_t, 6 > lattice_parameters_
{a, b, c, alpha, beta, gamma}.
Definition Cell.hpp:359
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.
Definition Cell.hpp:187
Cell & operator=(Cell &&other) noexcept=default
Move assignment operator.
std::span< Atom > atomSpan() noexcept
Gets a mutable span view over the atoms in the cell.
Definition Cell.hpp:155
std::vector< Atom > & atoms() noexcept
Gets a mutable list of atoms in the cell.
Definition Cell.hpp:143
std::array< real_t, 3 > perpendicularWidths() const noexcept
Computes the perpendicular widths (interplanar spacing) between opposing cell faces.
Definition Cell.cpp:250
void setLatticeParameters(const std::array< real_t, 6 > ¶ms)
Definition Cell.cpp:57
std::span< const Atom > atomSpan() const noexcept
Gets an immutable span view over the atoms in the cell.
Definition Cell.hpp:149
void reserveAtoms(std::size_t count)
Reserves capacity for atom storage to minimize reallocations.
Definition Cell.hpp:334
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.
Definition Cell.cpp:319
std::vector< math::Vector3< real_t > > velocities_
Lazy per-atom velocities/forces (0 B when unused).
Definition Cell.hpp:365
const math::Matrix3< real_t > & inverseLatticeVectors() const noexcept
Gets the inverse lattice vectors as a 3x3 matrix. Useful for converting Cartesian coordinates to frac...
Definition Cell.hpp:121
real_t volume_
Cached volume in Angstroms^3.
Definition Cell.hpp:360
const std::vector< Atom > & atoms() const noexcept
Gets the list of atoms in the cell.
Definition Cell.hpp:137
std::optional< Element > findElement(std::string_view symbol) const
Finds the Element properties for a given element symbol.
Definition Cell.cpp:144
size_t atomCount() const noexcept
Gets the total number of atoms in the cell.
Definition Cell.hpp:223
bool isEmpty() const noexcept
Checks whether the cell contains no atoms.
Definition Cell.hpp:229
math::Vector3< real_t > atomVelocity(size_t atom_idx) const noexcept
Gets the velocity of a specific atom, returning {0, 0, 0} if unallocated.
Definition Cell.hpp:177
std::span< const Element > elementSpan() const noexcept
Gets an immutable span view over unique chemical elements in the cell.
Definition Cell.hpp:217
const std::vector< math::Vector3< real_t > > & velocities() const noexcept
Gets the contiguous lazy velocity buffer (empty if velocities were never set).
Definition Cell.hpp:168
void updateLattice(const math::Matrix3< real_t > &new_lattice)
Updates lattice vectors and recomputes volume, inverse matrix, and scalar parameters.
Definition Cell.cpp:93
Cell(Cell &&other) noexcept=default
Move constructor. Transfers ownership of lattice vectors and atom data.
const std::vector< Element > & elements() const noexcept
Gets the list of unique chemical elements in the cell.
Definition Cell.hpp:211
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.
Definition Cell.cpp:270
void ensureVelocities()
Ensures the lazy velocity buffer is sized to match atomCount().
Definition Cell.hpp:200
Cell & operator=(const Cell &other)=default
Copy assignment operator.
const Element & getOrRegisterElement(std::string_view symbol)
Registers an element symbol if not already present and returns its Element reference.
Definition Cell.cpp:205
const real_t & volume() const noexcept
Gets the volume of the simulation cell.
Definition Cell.hpp:130
~Cell()=default
Destructor.
math::Matrix3< real_t > inverse_lattice_vectors_
Inverse matrix for fractional mapping.
Definition Cell.hpp:358
void setEnergy(real_t energy) noexcept
Sets the energy of the cell frame.
Definition Cell.hpp:322
const std::array< real_t, 6 > & latticeParameters() const noexcept
Gets the lattice parameters (a, b, c, alpha, beta, gamma).
Definition Cell.hpp:101
const math::Matrix3< real_t > & latticeVectors() const noexcept
Gets the lattice vectors as a 3x3 matrix.
Definition Cell.hpp:112
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 me...
Definition Cell.cpp:220
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.
Definition Cell.cpp:153
void updateLatticeParametersFromVectors()
Internal helper to synchronize scalar parameters with vector matrix.
Definition Cell.cpp:103
math::Vector3< real_t > minimumImage(const math::Vector3< real_t > &distance) const
Applies the minimum image convention to a distance vector.
Definition Cell.cpp:227
real_t getEnergy() const noexcept
Gets the energy of the cell frame.
Definition Cell.hpp:328
math::Matrix3< real_t > lattice_vectors_
Basis vectors of the box.
Definition Cell.hpp:357
A lightweight, constexpr, stack-based 3x3 matrix.
Definition LinearAlgebra.hpp:261
A lightweight, constexpr, stack-based 3D vector.
Definition LinearAlgebra.hpp:32
Definition ITrajectoryCalculator.hpp:13
real_t distance(const Atom &atom_a, const Atom &atom_b) noexcept
Calculates the Euclidean distance between two atoms.
Definition Atom.hpp:280
Defines universal mathematical and physical constants.
Definition AnalysisTypes.hpp:11
double real_t
Definition Precision.hpp:18
Represents a chemical element with its symbol and unique ID.
Definition Atom.hpp:52