seams-core v2.14.2
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
seams::Msd Class Reference

Owned streaming MSD accumulator. More...

#include <include/seams.hpp>

Inheritance diagram for seams::Msd:

Public Member Functions

 Msd (std::size_t natoms, std::size_t max_lag, std::size_t origin_stride, double dt, std::span< const double, 3 > axis)
 Allocate a streaming MSD accumulator.
void push (std::span< const double > xyz)
 Push one unwrapped coordinate frame.
void push (std::span< const double > xyz, std::span< const double, 9 > box9)
 Push one periodic coordinate frame and unwrap incrementally.
MsdCurve curve () const
 Copy out accumulated total, axial, and lateral MSD curves.
DiffusionFit fit (double t_start=0.0, double t_end=0.0) const
 Fit Einstein diffusion coefficients over [t_start, t_end].
Public Member Functions inherited from seams::detail::Handle< seams_msd, seams_msd_destroy >
 Handle ()=default
Handle & operator= (const Handle &)=delete
 ~Handle ()
 operator bool () const noexcept

Additional Inherited Members

Protected Member Functions inherited from seams::detail::Handle< seams_msd, seams_msd_destroy >
seams_msd * get () const noexcept
void reset () noexcept
Protected Attributes inherited from seams::detail::Handle< seams_msd, seams_msd_destroy >
seams_msd * ptr_

Detailed Description

Owned streaming MSD accumulator.

Definition at line 1089 of file seams.hpp.

Constructor & Destructor Documentation

◆ Msd()

seams::Msd::Msd ( std::size_t natoms,
std::size_t max_lag,
std::size_t origin_stride,
double dt,
std::span< const double, 3 > axis )
inline

Allocate a streaming MSD accumulator.

Parameters
natomsParticle count per frame.
max_lagMaximum lag in frames, or 0 for all lags.
origin_strideFrame stride between origins.
dtFrame spacing in physical time units.
axisAxial direction 3-vector.

Definition at line 1099 of file seams.hpp.

1100 {
1101 seams_msd *raw = nullptr;
1102 detail::check(seams_msd_create(natoms, max_lag, origin_stride, dt, axis.data(), &raw), nullptr);
1103 *this = Msd(raw);
1104 }
Msd(std::size_t natoms, std::size_t max_lag, std::size_t origin_stride, double dt, std::span< const double, 3 > axis)
Allocate a streaming MSD accumulator.
Definition seams.hpp:1099
SEAMS_API seams_status seams_msd_create(size_t natoms, size_t max_lag, size_t origin_stride, double dt, const double axis[3], seams_msd **out)
Create a streaming multi-origin MSD accumulator with axial/lateral split.
struct seams_msd seams_msd
Streaming mean-squared displacement accumulator.
Definition seams.h:260
void check(int status, const void *handle)
Definition seams.hpp:699

Member Function Documentation

◆ curve()

MsdCurve seams::Msd::curve ( ) const
inlinenodiscard

Copy out accumulated total, axial, and lateral MSD curves.

Definition at line 1125 of file seams.hpp.

1125 {
1126 std::size_t nl = 0;
1127 detail::check(seams_msd_curve(get(), nullptr, nullptr, nullptr, nullptr, nullptr, 0, &nl),
1128 get());
1129 MsdCurve out;
1130 out.lag_time.resize(nl);
1131 out.total.resize(nl);
1132 out.axial.resize(nl);
1133 out.lateral.resize(nl);
1134 out.n_origins.resize(nl);
1135 detail::check(seams_msd_curve(get(), out.lag_time.data(), out.total.data(), out.axial.data(),
1136 out.lateral.data(), out.n_origins.data(), nl, &nl),
1137 get());
1138 return out;
1139 }
SEAMS_API seams_status seams_msd_curve(const seams_msd *msd, double *lag_time, double *total, double *axial, double *lateral, size_t *n_origins, size_t cap, size_t *n_lags)
Read accumulated lag times and total, axial, and lateral MSD curves.

◆ fit()

DiffusionFit seams::Msd::fit ( double t_start = 0.0,
double t_end = 0.0 ) const
inlinenodiscard

Fit Einstein diffusion coefficients over [t_start, t_end].

Definition at line 1142 of file seams.hpp.

1142 {
1143 DiffusionFit out;
1145 seams_msd_fit(get(), t_start, t_end, &out.d_total, &out.d_axial, &out.d_lateral, &out.alpha),
1146 get());
1147 out.alpha_fitted = !std::isnan(out.alpha);
1148 return out;
1149 }
SEAMS_API seams_status seams_msd_fit(const seams_msd *msd, double t_start, double t_end, double *d_total, double *d_axial, double *d_lateral, double *alpha)
Linear Einstein diffusion fit on an MSD accumulator.

◆ push() [1/2]

void seams::Msd::push ( std::span< const double > xyz)
inline

Push one unwrapped coordinate frame.

Definition at line 1109 of file seams.hpp.

1109 {
1110 if (xyz.size() % 3 != 0) {
1111 throw Error(SEAMS_ERR_ARG, "coordinates are not a multiple of 3");
1112 }
1113 detail::check(seams_msd_push(get(), xyz.data(), xyz.size() / 3, nullptr, 0), get());
1114 }
Error(int status, std::string message)
Build an error from a status and a message.
Definition seams.hpp:186
SEAMS_API seams_status seams_msd_push(seams_msd *msd, const double *xyz, size_t natoms, const double *box9, size_t box_len)
Push one frame into a streaming MSD accumulator.
@ SEAMS_ERR_ARG
A caller argument is the wrong shape, or a coordinate is not finite.
Definition seams.h:159

◆ push() [2/2]

void seams::Msd::push ( std::span< const double > xyz,
std::span< const double, 9 > box9 )
inline

Push one periodic coordinate frame and unwrap incrementally.

Definition at line 1117 of file seams.hpp.

1117 {
1118 if (xyz.size() % 3 != 0) {
1119 throw Error(SEAMS_ERR_ARG, "coordinates are not a multiple of 3");
1120 }
1121 detail::check(seams_msd_push(get(), xyz.data(), xyz.size() / 3, box9.data(), 9), get());
1122 }

The documentation for this class was generated from the following file: