61 Trajectory(std::shared_ptr<MappedFile> mapped_file, std::vector<size_t> frame_offsets,
71 Trajectory(std::vector<std::shared_ptr<MappedFile>> mapped_files,
72 std::vector<MappedFrameSlice> frame_slices,
FrameParser parser,
real_t time_step);
88 [[nodiscard]] std::vector<Cell> &
getFrames();
94 [[nodiscard]]
const std::vector<Cell> &
getFrames()
const;
100 [[nodiscard]] std::span<Cell>
frameSpan();
106 [[nodiscard]] std::span<const Cell>
frameSpan()
const;
268 bool renameElement(std::string_view old_symbol, std::string_view new_symbol);
286 mutable std::unique_ptr<std::mutex>
init_mutex_{std::make_unique<std::mutex>()};
290 mutable std::vector<std::array<real_t, 6>>
Simulation cell structure with periodic boundary conditions.
Contiguous 2D matrix of element-pair bond cutoff ranges.
Definition AnalysisTypes.hpp:48
Represents the simulation cell (periodic box).
Definition Cell.hpp:30
RAII memory-mapped read-only file view.
Definition MappedFile.hpp:54
std::span< Cell > frameSpan()
Gets a mutable span view over the trajectory frames.
Definition Trajectory.cpp:76
bool renameElementMapped(std::string_view old_symbol, std::string_view new_symbol)
Definition Trajectory.cpp:227
std::function< Cell(const char *data, size_t size)> FrameParser
Definition Trajectory.hpp:52
std::optional< Cell > first_frame_
Definition Trajectory.hpp:289
std::vector< Cell > frames_
Collection of simulation snapshots.
Definition Trajectory.hpp:288
bool renameElementMaterialized(std::string_view old_symbol, std::string_view new_symbol)
Definition Trajectory.cpp:213
FrameParser parser_
Definition Trajectory.hpp:299
real_t getBondCutoff(size_t type1, size_t type2) const
Gets the maximum bond cutoff distance for two given element types.
Definition Trajectory.cpp:299
real_t getMinBondCutoffSQ(size_t type1, size_t type2) const
Gets a squared minimum bond cutoff distance for two given element types.
Definition Trajectory.cpp:295
void ensureMaterialized() const
Definition Trajectory.cpp:186
size_t removed_frames_count_
Counter for deduplicated frames.
Definition Trajectory.hpp:295
std::array< real_t, 6 > getLatticeParameters(size_t index) const
Gets the lattice parameters [a, b, c, alpha, beta, gamma] for a specific frame.
Definition Trajectory.cpp:112
const std::vector< real_t > & getFrameVolumes() const
Gets the tracked cell volumes for all frames.
Definition Trajectory.cpp:144
void setTimeStep(real_t step) noexcept
Sets the simulation time step.
Definition Trajectory.hpp:167
real_t getVolume(size_t index) const
Gets the simulation cell volume for a specific frame.
Definition Trajectory.cpp:125
void addFrame(const Cell &frame)
Appends a new frame to the trajectory.
Definition Trajectory.cpp:312
const correlation::analysis::BondCutoffMatrix & getBondCutoffsSQ() const noexcept
Backward-compatible alias returning the bond cutoff matrix.
Definition Trajectory.hpp:251
const correlation::analysis::BondCutoffRange & getBondCutoffRange(size_t type1, size_t type2) const
Gets the bond cutoff range for two given element types.
Definition Trajectory.cpp:283
const std::vector< std::array< real_t, 6 > > & getFrameLatticeParameters() const
Gets the tracked lattice parameters [a, b, c, alpha, beta, gamma] for all frames.
Definition Trajectory.cpp:138
std::vector< Cell > & getFrames()
Gets a mutable reference to the frames.
Definition Trajectory.cpp:66
size_t getFrameCount() const noexcept
Gets the total number of frames in the trajectory.
Definition Trajectory.cpp:86
real_t getMinBondCutoff(size_t type1, size_t type2) const
Gets the minimum bond cutoff distance for two given element types.
Definition Trajectory.cpp:303
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 ...
Definition Trajectory.cpp:264
correlation::analysis::BondCutoffMatrix bond_cutoffs_
Cached bond cutoff ranges.
Definition Trajectory.hpp:293
real_t getTimeStep() const noexcept
Gets the time step between frames.
Definition Trajectory.hpp:161
void applyElementRemap(Cell &cell) const
Definition Trajectory.cpp:207
Trajectory()
Definition Trajectory.cpp:23
const correlation::analysis::BondCutoffMatrix & getBondCutoffs() const noexcept
Gets the matrix of bond cutoff ranges for element pairs.
Definition Trajectory.hpp:243
std::vector< std::pair< std::string, std::string > > element_remap_
Definition Trajectory.hpp:300
void setBondCutoffs(const correlation::analysis::BondCutoffMatrix &cutoffs)
Sets the bond cutoff matrix for neighbor searching.
Definition Trajectory.cpp:307
std::unique_ptr< std::mutex > init_mutex_
Definition Trajectory.hpp:286
std::vector< real_t > frame_volumes_
Tracked volume per cell.
Definition Trajectory.hpp:292
std::vector< std::shared_ptr< MappedFile > > mapped_files_
Definition Trajectory.hpp:297
std::vector< std::array< real_t, 6 > > frame_lattice_parameters_
Tracked lattice parameters per cell.
Definition Trajectory.hpp:291
void syncCellMetricsUnlocked() const
Definition Trajectory.cpp:150
std::vector< MappedFrameSlice > frame_slices_
Definition Trajectory.hpp:298
real_t time_step_
Time between snapshots.
Definition Trajectory.hpp:294
void removeDuplicatedFrames(real_t tolerance=static_cast< real_t >(1e-5))
Removes consecutive duplicated frames from the trajectory. Frames are considered duplicates if all at...
Definition Trajectory.cpp:340
const Cell & firstFrame() const
Gets a constant reference to the first frame of the trajectory.
Definition Trajectory.cpp:169
Cell getFrame(size_t index) const
Gets a copy of a frame at a specific index.
Definition Trajectory.cpp:93
void calculateVelocities()
Calculates velocities for all atoms in the trajectory using finite differences, accounting for period...
Definition Trajectory.cpp:359
real_t getBondCutoffSQ(size_t type1, size_t type2) const
Gets a squared bond cutoff distance for two given element types.
Definition Trajectory.cpp:291
void validateFrame(const Cell &new_frame) const
Internal helper to validate that a new frame matches the trajectory topology.
Definition Trajectory.cpp:368
void precomputeBondCutoffs() const
Pre-calculates the squared bond cutoff distances for every pair of element types using the elements f...
Definition Trajectory.cpp:329
size_t getRemovedFrameCount() const noexcept
Returns the number of frames removed during deduplication.
Definition Trajectory.hpp:259
Definition ITrajectoryCalculator.hpp:13
double real_t
Definition Precision.hpp:18
Represents the squared minimum and maximum bond distance bounds for an element pair.
Definition AnalysisTypes.hpp:29
Definition Trajectory.hpp:46
size_t size
Definition Trajectory.hpp:49
uint32_t file_index
Definition Trajectory.hpp:47
size_t offset
Definition Trajectory.hpp:48