|
Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
|
This class stores a series of snapshots of a system. More...
#include <Trajectory.hpp>

Classes | |
| struct | MappedFrameSlice |
Public Member Functions | |
Accessors | |
| std::vector< Cell > & | getFrames () |
| Gets a mutable reference to the frames. | |
| const std::vector< Cell > & | getFrames () const |
| Gets a constant reference to the frames. | |
| std::span< Cell > | frameSpan () |
| Gets a mutable span view over the trajectory frames. | |
| std::span< const Cell > | frameSpan () const |
| Gets an immutable span view over the trajectory frames. | |
| size_t | getFrameCount () const noexcept |
| Gets the total number of frames in the trajectory. | |
| const Cell & | firstFrame () const |
| Gets a constant reference to the first frame of the trajectory. | |
| Cell | getFrame (size_t index) const |
| Gets a copy of a frame at a specific index. | |
| std::array< real_t, 6 > | getLatticeParameters (size_t index) const |
| Gets the lattice parameters [a, b, c, alpha, beta, gamma] for a specific frame. | |
| real_t | getVolume (size_t index) const |
| Gets the simulation cell volume for a specific frame. | |
| const std::vector< std::array< real_t, 6 > > & | getFrameLatticeParameters () const |
| Gets the tracked lattice parameters [a, b, c, alpha, beta, gamma] for all frames. | |
| const std::vector< real_t > & | getFrameVolumes () const |
| Gets the tracked cell volumes for all frames. | |
| real_t | getTimeStep () const noexcept |
| Gets the time step between frames. | |
| void | setTimeStep (real_t step) noexcept |
| Sets the simulation time step. | |
| const correlation::analysis::BondCutoffRange & | getBondCutoffRange (size_t type1, size_t type2) const |
| Gets the bond cutoff range for two given element types. | |
| real_t | getBondCutoffSQ (size_t type1, size_t type2) const |
| Gets a squared bond cutoff distance for two given element types. | |
| real_t | getMinBondCutoffSQ (size_t type1, size_t type2) const |
| Gets a squared minimum bond cutoff distance for two given element types. | |
| real_t | getBondCutoff (size_t type1, size_t type2) const |
| Gets the maximum bond cutoff distance for two given element types. | |
| real_t | getMinBondCutoff (size_t type1, size_t type2) const |
| Gets the minimum bond cutoff distance for two given element types. | |
| void | setBondCutoffs (const correlation::analysis::BondCutoffMatrix &cutoffs) |
| Sets the bond cutoff matrix for neighbor searching. | |
| void | removeDuplicatedFrames (real_t tolerance=static_cast< real_t >(1e-5)) |
| Removes consecutive duplicated frames from the trajectory. Frames are considered duplicates if all atom positions are identical (within a small tolerance). | |
| void | precomputeBondCutoffs () const |
| Pre-calculates the squared bond cutoff distances for every pair of element types using the elements from the first frame. | |
| void | calculateVelocities () |
| Calculates velocities for all atoms in the trajectory using finite differences, accounting for periodic boundary conditions. Assumes constant time step. Populates the internal velocities_ vector. | |
| const correlation::analysis::BondCutoffMatrix & | getBondCutoffs () const noexcept |
| Gets the matrix of bond cutoff ranges for element pairs. | |
| const correlation::analysis::BondCutoffMatrix & | getBondCutoffsSQ () const noexcept |
| Backward-compatible alias returning the bond cutoff matrix. | |
| size_t | getRemovedFrameCount () const noexcept |
| Returns the number of frames removed during deduplication. | |
| bool | renameElement (std::string_view old_symbol, std::string_view new_symbol) |
| Renames an element species across all frames (both materialized and lazy-mapped) and recomputes bond cutoffs. | |
Private Member Functions | |
| void | validateFrame (const Cell &new_frame) const |
| Internal helper to validate that a new frame matches the trajectory topology. | |
| void | ensureMaterialized () const |
| void | syncCellMetricsUnlocked () const |
| void | applyElementRemap (Cell &cell) const |
| bool | renameElementMaterialized (std::string_view old_symbol, std::string_view new_symbol) |
| bool | renameElementMapped (std::string_view old_symbol, std::string_view new_symbol) |
Private Attributes | |
| std::unique_ptr< std::mutex > | init_mutex_ {std::make_unique<std::mutex>()} |
| std::vector< Cell > | frames_ |
| Collection of simulation snapshots. | |
| std::optional< Cell > | first_frame_ |
| std::vector< std::array< real_t, 6 > > | frame_lattice_parameters_ |
| Tracked lattice parameters per cell. | |
| std::vector< real_t > | frame_volumes_ |
| Tracked volume per cell. | |
| correlation::analysis::BondCutoffMatrix | bond_cutoffs_ |
| Cached bond cutoff ranges. | |
| real_t | time_step_ |
| Time between snapshots. | |
| size_t | removed_frames_count_ {0} |
| Counter for deduplicated frames. | |
| std::vector< std::shared_ptr< MappedFile > > | mapped_files_ |
| std::vector< MappedFrameSlice > | frame_slices_ |
| FrameParser | parser_ |
| std::vector< std::pair< std::string, std::string > > | element_remap_ |
Constructors | |
| using | FrameParser = std::function<Cell(const char *data, size_t size)> |
| Trajectory () | |
| Trajectory (std::vector< Cell > frames, real_t time_step) | |
| Constructs a trajectory from a vector of frames. | |
| Trajectory (std::shared_ptr< MappedFile > mapped_file, std::vector< size_t > frame_offsets, FrameParser parser, real_t time_step) | |
| Constructs a lazy-loading trajectory from a memory-mapped file. | |
| Trajectory (std::vector< std::shared_ptr< MappedFile > > mapped_files, std::vector< MappedFrameSlice > frame_slices, FrameParser parser, real_t time_step) | |
| Constructs a lazy-loading trajectory from multiple memory-mapped files. | |
| void | addFrame (const Cell &frame) |
| Appends a new frame to the trajectory. | |
This class stores a series of snapshots of a system.
It ensures that the number of atoms and their identities are consistent across all frames. It provides methods to analyze dynamic properties of the system, such as velocity distributions.
| using correlation::core::Trajectory::FrameParser = std::function<Cell(const char *data, size_t size)> |
| correlation::core::Trajectory::Trajectory | ( | ) |

Constructs a trajectory from a vector of frames.
| frames | Vector of Cell objects representing simulation snapshots. |
| time_step | The time interval between consecutive frames. |

| correlation::core::Trajectory::Trajectory | ( | std::shared_ptr< MappedFile > | mapped_file, |
| std::vector< size_t > | frame_offsets, | ||
| FrameParser | parser, | ||
| real_t | time_step ) |
Constructs a lazy-loading trajectory from a memory-mapped file.
| mapped_file | Shared pointer to the mapped file. |
| frame_offsets | Byte offsets of the frames in the file. |
| parser | Function to parse a frame from a slice of memory. |
| time_step | The time interval between consecutive frames. |

| correlation::core::Trajectory::Trajectory | ( | std::vector< std::shared_ptr< MappedFile > > | mapped_files, |
| std::vector< MappedFrameSlice > | frame_slices, | ||
| FrameParser | parser, | ||
| real_t | time_step ) |
Constructs a lazy-loading trajectory from multiple memory-mapped files.
| mapped_files | Vector of shared pointers to mapped files. |
| frame_slices | Slice descriptors locating each frame across the mapped files. |
| parser | Function to parse a frame from a slice of memory. |
| time_step | The time interval between consecutive frames. |

| void correlation::core::Trajectory::addFrame | ( | const Cell & | frame | ) |
Appends a new frame to the trajectory.
| frame | The Cell object to add. |


|
private |


| void correlation::core::Trajectory::calculateVelocities | ( | ) |
Calculates velocities for all atoms in the trajectory using finite differences, accounting for periodic boundary conditions. Assumes constant time step. Populates the internal velocities_ vector.


|
private |


|
nodiscard |
Gets a constant reference to the first frame of the trajectory.
| std::runtime_error | if the trajectory is empty. |


|
nodiscard |
Gets a mutable span view over the trajectory frames.

|
nodiscard |
Gets an immutable span view over the trajectory frames.

|
nodiscard |
Gets the maximum bond cutoff distance for two given element types.
| type1 | ID of the first element type. |
| type2 | ID of the second element type. |

|
nodiscard |
Gets the bond cutoff range for two given element types.
| type1 | ID of the first element type. |
| type2 | ID of the second element type. |

|
inlinenodiscardnoexcept |
Gets the matrix of bond cutoff ranges for element pairs.

|
nodiscard |
Gets a squared bond cutoff distance for two given element types.
| type1 | ID of the first element type. |
| type2 | ID of the second element type. |

|
inlinenodiscardnoexcept |
Backward-compatible alias returning the bond cutoff matrix.

|
nodiscard |
Gets a copy of a frame at a specific index.
| index | The index of the frame to retrieve. |
| std::out_of_range | if the index is invalid. |


|
nodiscardnoexcept |
Gets the total number of frames in the trajectory.

|
nodiscard |
Gets the tracked lattice parameters [a, b, c, alpha, beta, gamma] for all frames.

|
nodiscard |
Gets a mutable reference to the frames.


|
nodiscard |
Gets a constant reference to the frames.

|
nodiscard |
Gets the tracked cell volumes for all frames.

|
nodiscard |
Gets the lattice parameters [a, b, c, alpha, beta, gamma] for a specific frame.
| index | The index of the frame to query. |
| std::out_of_range | if the index is invalid. |

|
nodiscard |
Gets the minimum bond cutoff distance for two given element types.
| type1 | ID of the first element type. |
| type2 | ID of the second element type. |

|
nodiscard |
Gets a squared minimum bond cutoff distance for two given element types.
| type1 | ID of the first element type. |
| type2 | ID of the second element type. |

|
inlinenodiscardnoexcept |
Returns the number of frames removed during deduplication.
|
inlinenodiscardnoexcept |
Gets the time step between frames.


|
nodiscard |
Gets the simulation cell volume for a specific frame.
| index | The index of the frame to query. |
| std::out_of_range | if the index is invalid. |

| void correlation::core::Trajectory::precomputeBondCutoffs | ( | ) | const |
Pre-calculates the squared bond cutoff distances for every pair of element types using the elements from the first frame.


| void correlation::core::Trajectory::removeDuplicatedFrames | ( | real_t | tolerance = static_cast<real_t>(1e-5) | ) |
Removes consecutive duplicated frames from the trajectory. Frames are considered duplicates if all atom positions are identical (within a small tolerance).
| tolerance | Euclidean distance threshold in Angstroms for position equivalence. |


| bool correlation::core::Trajectory::renameElement | ( | std::string_view | old_symbol, |
| std::string_view | new_symbol ) |
Renames an element species across all frames (both materialized and lazy-mapped) and recomputes bond cutoffs.
| old_symbol | Existing element symbol (e.g., "1"). |
| new_symbol | Replacement element symbol (e.g., "Cu"). |


|
private |


|
private |


| void correlation::core::Trajectory::setBondCutoffs | ( | const correlation::analysis::BondCutoffMatrix & | cutoffs | ) |
Sets the bond cutoff matrix for neighbor searching.
| cutoffs | Matrix of bond cutoff ranges [type1][type2]. |
| std::invalid_argument | If any cutoff bound is negative or min_sq > max_sq. |


|
inlinenoexcept |
Sets the simulation time step.
| step | Time step in femtoseconds. |
|
private |


|
private |
Internal helper to validate that a new frame matches the trajectory topology.
| new_frame | The frame to check. |
| std::invalid_argument | if frame is inconsistent. |


|
mutableprivate |
Cached bond cutoff ranges.
|
private |
|
mutableprivate |
|
mutableprivate |
Tracked lattice parameters per cell.
|
private |
|
mutableprivate |
Tracked volume per cell.
|
mutableprivate |
Collection of simulation snapshots.
|
mutableprivate |
|
private |
|
private |
|
private |
Counter for deduplicated frames.
|
private |
Time between snapshots.