seams-core v2.14.2
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
Trajectories and dynamics

Periodic unwrapping, molecular dipoles, and streaming time correlations. More...

Functions

SEAMS_API seams_status seams_mols (const seams_system *sys, int *mols, size_t len)
 Copy the stored molecule ids out.
SEAMS_API seams_status seams_set_mols (seams_system *sys, const int *mols, size_t len)
 Replace the stored molecule ids on a loaded frame.
SEAMS_API seams_status seams_molecule_centres (const seams_system *sys, const int *mols, size_t mols_len, const double *masses, size_t masses_len, int *mol_ids_out, double *centres_out, size_t cap, size_t *n_mols)
 Intact periodic centres of mass or geometry for molecules in a frame.
SEAMS_API seams_status seams_traj_unwrap_positions (const double *xyz, size_t nframes, size_t natoms, const double *boxes, size_t nboxes, double *unwrapped, size_t unwrapped_len)
 Unwrap periodic coordinates across consecutive frames.
SEAMS_API seams_status seams_traj_unwrap_centres (const double *xyz, size_t nframes, size_t natoms, const double *boxes, size_t nboxes, const int *mols, size_t mols_len, const double *masses, size_t masses_len, int *mol_ids_out, size_t mol_ids_cap, double *centres_out, size_t centres_len, size_t *n_mols)
 Assemble per-molecule centres and unwrap them across frames.
SEAMS_API seams_status seams_water_vectors (const seams_system *sys, int oxygen_type, int hydrogen_type, int *mol_ids, double *oh_mid, double *bisector, double *hh, double *hh_unit, size_t cap, size_t *n_waters)
 Water orientation vectors: O to H-midpoint and H-to-H under PBC.
SEAMS_API seams_status seams_molecule_dipoles (const seams_system *sys, const int *mols, size_t mols_len, const double *charges, size_t charges_len, int *mol_ids_out, double *dipoles, double *unit_vectors, size_t cap, size_t *n_mols)
 Generic per-molecule dipole or geometric orientation vectors.
SEAMS_API seams_status seams_orientation_order (const double *vectors, size_t n_vectors, const double axis[3], double *cos_theta, double *p2, size_t cap, double *mean_p1, double *mean_p2)
 Project molecular vectors onto an axis for P1 and P2 order parameters.
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.
SEAMS_API void seams_msd_destroy (seams_msd *msd)
 Free an MSD accumulator.
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_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.
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.
SEAMS_API seams_status seams_hbond_tcf_create (size_t max_lag, size_t origin_stride, double dt, int directed, seams_hbond_tcf **out)
 Create a streaming H-bond lifetime accumulator from per-frame edges.
SEAMS_API void seams_hbond_tcf_destroy (seams_hbond_tcf *tcf)
 Free an H-bond lifetime accumulator.
SEAMS_API seams_status seams_hbond_tcf_push (seams_hbond_tcf *tcf, const int *donors, const int *acceptors, size_t n_edges)
 Push one frame's hydrogen-bond edge set into the lifetime accumulator.
SEAMS_API seams_status seams_hbond_tcf_curve (const seams_hbond_tcf *tcf, double *lag_time, double *c_intermittent, double *s_continuous, size_t *n_origins, size_t cap, size_t *n_lags)
 Read intermittent C_HB(t) and continuous S_HB(t) lifetime curves.
SEAMS_API seams_status seams_hbond_tcf_fit (const seams_hbond_tcf *tcf, double t_start, double t_end, double *tau_c_int, double *tau_c_exp, double *tau_s_int, double *tau_s_exp)
 Integrated and single-exponential lifetimes for C_HB and S_HB.
SEAMS_API seams_status seams_reorient_create (size_t n_vectors, size_t max_lag, size_t origin_stride, double dt, seams_reorient **out)
 Create a streaming orientational correlation accumulator for C1 and C2.
SEAMS_API void seams_reorient_destroy (seams_reorient *reorient)
 Free a reorientation accumulator.
SEAMS_API seams_status seams_reorient_push (seams_reorient *reorient, const double *vectors, size_t n_vectors)
 Push one frame of molecular 3-vectors into a reorientation accumulator.
SEAMS_API seams_status seams_reorient_curve (const seams_reorient *reorient, double *lag_time, double *c1, double *c2, size_t *n_origins, size_t cap, size_t *n_lags)
 Read accumulated C1(t) = <P1(u(0).u(t))> and C2(t) = <P2(u(0).u(t))>.
SEAMS_API seams_status seams_reorient_fit (const seams_reorient *reorient, double t_start, double t_end, double *tau1_int, double *tau1_exp, double *tau2_int, double *tau2_exp)
 Integrated and single-exponential reorientation times tau_1 and tau_2.

Detailed Description

Periodic unwrapping, molecular dipoles, and streaming time correlations.

Function Documentation

◆ seams_hbond_tcf_create()

SEAMS_API seams_status seams_hbond_tcf_create ( size_t max_lag,
size_t origin_stride,
double dt,
int directed,
seams_hbond_tcf ** out )

Create a streaming H-bond lifetime accumulator from per-frame edges.

Parameters
max_lagMaximum lag in frames, or 0 to retain all lags. Above PTRDIFF_MAX / sizeof(double) - 1 the lag bins cannot be allocated, which is SEAMS_ERR_RANGE.
origin_strideFrame stride between time origins, at least 1.
dtPositive finite frame spacing.
directedNon-zero treats (donor, acceptor) as directed; zero canonicalizes pairs.
outReceives the new handle; set to NULL on failure.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
The caller frees *out with seams_hbond_tcf_destroy().
Thread safety
Pure aside from handle registration and the thread-local error string.
Example
seams_hbond_tcf *tcf = NULL;
seams_hbond_tcf_create(16, 1, 0.1, 1, &tcf);
SEAMS_API void seams_hbond_tcf_destroy(seams_hbond_tcf *tcf)
Free an H-bond lifetime accumulator.
SEAMS_API seams_status seams_hbond_tcf_create(size_t max_lag, size_t origin_stride, double dt, int directed, seams_hbond_tcf **out)
Create a streaming H-bond lifetime accumulator from per-frame edges.
struct seams_hbond_tcf seams_hbond_tcf
Streaming hydrogen-bond lifetime accumulator.
Definition seams.h:262

◆ seams_hbond_tcf_curve()

SEAMS_API seams_status seams_hbond_tcf_curve ( const seams_hbond_tcf * tcf,
double * lag_time,
double * c_intermittent,
double * s_continuous,
size_t * n_origins,
size_t cap,
size_t * n_lags )

Read intermittent C_HB(t) and continuous S_HB(t) lifetime curves.

Parameters
tcfH-bond TCF handle.
lag_timeReceives lag times k * dt, or NULL.
c_intermittentReceives intermittent autocorrelation C_HB, or NULL.
s_continuousReceives unbroken survival probability S_HB, or NULL.
n_originsReceives origin counts per lag, or NULL.
capCapacity of non-NULL output arrays.
n_lagsReceives the available lag count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_NOMEM.
Ownership
The caller owns all output buffers.
Thread safety
Read-only on tcf.
Example
const int don[1] = {1}, acc[1] = {2};
seams_hbond_tcf *tcf = NULL;
size_t nlags = 0;
seams_hbond_tcf_create(4, 1, 1.0, 1, &tcf);
seams_hbond_tcf_push(tcf, don, acc, 1);
seams_hbond_tcf_push(tcf, don, acc, 1);
seams_hbond_tcf_curve(tcf, NULL, NULL, NULL, NULL, 0, &nlags);
SEAMS_API seams_status seams_hbond_tcf_curve(const seams_hbond_tcf *tcf, double *lag_time, double *c_intermittent, double *s_continuous, size_t *n_origins, size_t cap, size_t *n_lags)
Read intermittent C_HB(t) and continuous S_HB(t) lifetime curves.
SEAMS_API seams_status seams_hbond_tcf_push(seams_hbond_tcf *tcf, const int *donors, const int *acceptors, size_t n_edges)
Push one frame's hydrogen-bond edge set into the lifetime accumulator.

◆ seams_hbond_tcf_destroy()

SEAMS_API void seams_hbond_tcf_destroy ( seams_hbond_tcf * tcf)

Free an H-bond lifetime accumulator.

Parameters
tcfHandle from seams_hbond_tcf_create(), or NULL.
Ownership
Releases the handle and its active origin sets.
Thread safety
Exclusive use of tcf.
Example

◆ seams_hbond_tcf_fit()

SEAMS_API seams_status seams_hbond_tcf_fit ( const seams_hbond_tcf * tcf,
double t_start,
double t_end,
double * tau_c_int,
double * tau_c_exp,
double * tau_s_int,
double * tau_s_exp )

Integrated and single-exponential lifetimes for C_HB and S_HB.

Pass t_start = 0 and t_end = 0 to fit across the full positive decay range.

Parameters
tcfH-bond TCF handle with at least 2 lag points.
t_startFit window start time, >= 0.
t_endFit window end time, > t_start (or both 0 for full range).
tau_c_intReceives trapezoidal integral of C_HB, or NULL.
tau_c_expReceives exponential decay time of C_HB, or NULL.
tau_s_intReceives trapezoidal integral of S_HB, or NULL.
tau_s_expReceives exponential decay time of S_HB, or NULL.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
Writes scalar outputs owned by the caller.
Thread safety
Read-only on tcf.
Example
const int don[2] = {1, 2}, acc[2] = {3, 4};
seams_hbond_tcf *tcf = NULL;
double tc = 0, ts = 0;
seams_hbond_tcf_create(4, 1, 1.0, 1, &tcf);
seams_hbond_tcf_push(tcf, don, acc, 2);
seams_hbond_tcf_push(tcf, don, acc, 1);
seams_hbond_tcf_fit(tcf, 0.0, 0.0, &tc, NULL, &ts, NULL);
SEAMS_API seams_status seams_hbond_tcf_fit(const seams_hbond_tcf *tcf, double t_start, double t_end, double *tau_c_int, double *tau_c_exp, double *tau_s_int, double *tau_s_exp)
Integrated and single-exponential lifetimes for C_HB and S_HB.

◆ seams_hbond_tcf_push()

SEAMS_API seams_status seams_hbond_tcf_push ( seams_hbond_tcf * tcf,
const int * donors,
const int * acceptors,
size_t n_edges )

Push one frame's hydrogen-bond edge set into the lifetime accumulator.

Duplicate edges within the same frame are deduplicated before updating intermittent C_HB(t) and continuous survival S_HB(t).

Parameters
tcfH-bond TCF handle.
donorsDonor ids of length n_edges (may be NULL when n_edges is 0).
acceptorsAcceptor ids of length n_edges (may be NULL when n_edges is 0).
n_edgesNumber of edges in this frame.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_NOMEM.
Ownership
The library copies edge ids and keeps no caller pointer.
Thread safety
Exclusive use of tcf.
Example
const int don[1] = {1}, acc[1] = {2};
seams_hbond_tcf *tcf = NULL;
seams_hbond_tcf_create(8, 1, 1.0, 1, &tcf);
seams_hbond_tcf_push(tcf, don, acc, 1);

◆ seams_molecule_centres()

SEAMS_API seams_status seams_molecule_centres ( const seams_system * sys,
const int * mols,
size_t mols_len,
const double * masses,
size_t masses_len,
int * mol_ids_out,
double * centres_out,
size_t cap,
size_t * n_mols )

Intact periodic centres of mass or geometry for molecules in a frame.

Atoms sharing a molecule id are assembled onto the first atom of that molecule through the minimum image of the stored orthorhombic or triclinic cell before averaging. Pass NULL for both mol_ids_out and centres_out to query the molecule count in n_mols.

Parameters
sysFrame handle.
molsOptional molecule id per atom, or NULL to use stored molecule ids.
mols_lenLength of mols when mols is non-NULL; must equal n, or 0 when NULL.
massesOptional positive weight per atom, or NULL for equal weights.
masses_lenLength of masses when masses is non-NULL; must equal n, or 0 when NULL.
mol_ids_outReceives one molecule id per molecule, or NULL.
centres_outReceives 3 * n_mols coordinates in Angstrom, or NULL.
capMolecule capacity of non-NULL output buffers.
n_molsReceives the molecule count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_BOX; SEAMS_ERR_NOMEM.
Ownership
The caller owns all buffers.
Thread safety
Read-only on sys.
Example
size_t nm = 0;
seams_molecule_centres(sys, NULL, 0, NULL, 0, NULL, NULL, 0, &nm);
SEAMS_API seams_status seams_molecule_centres(const seams_system *sys, const int *mols, size_t mols_len, const double *masses, size_t masses_len, int *mol_ids_out, double *centres_out, size_t cap, size_t *n_mols)
Intact periodic centres of mass or geometry for molecules in a frame.

◆ seams_molecule_dipoles()

SEAMS_API seams_status seams_molecule_dipoles ( const seams_system * sys,
const int * mols,
size_t mols_len,
const double * charges,
size_t charges_len,
int * mol_ids_out,
double * dipoles,
double * unit_vectors,
size_t cap,
size_t * n_mols )

Generic per-molecule dipole or geometric orientation vectors.

With charges, computes sum_a q_a (r_a - r_centre) in elementary-charge Angstrom on each PBC-assembled molecule. Without charges, computes the mean minimum-image vector from each molecule's first atom to its remaining atoms.

Parameters
sysFrame handle.
molsOptional molecule id per atom, or NULL to use stored molecule ids.
mols_lenLength of mols when non-NULL, or 0 when NULL.
chargesOptional partial charge per atom, or NULL for geometric mode.
charges_lenLength of charges when non-NULL, or 0 when NULL.
mol_ids_outReceives molecule ids, length cap, or NULL.
dipolesReceives 3 * cap raw dipole vectors, or NULL.
unit_vectorsReceives 3 * cap normalized orientation vectors, or NULL.
capMolecule capacity of non-NULL output arrays.
n_molsReceives the molecule count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_BOX; SEAMS_ERR_NOMEM.
Ownership
The caller owns all buffers.
Thread safety
Read-only on sys.
Example
size_t nm = 0;
seams_molecule_dipoles(sys, NULL, 0, NULL, 0, NULL, NULL, NULL, 0, &nm);
SEAMS_API seams_status seams_molecule_dipoles(const seams_system *sys, const int *mols, size_t mols_len, const double *charges, size_t charges_len, int *mol_ids_out, double *dipoles, double *unit_vectors, size_t cap, size_t *n_mols)
Generic per-molecule dipole or geometric orientation vectors.

◆ seams_mols()

SEAMS_API seams_status seams_mols ( const seams_system * sys,
int * mols,
size_t len )

Copy the stored molecule ids out.

Parameters
sysFrame handle.
molsCaller buffer for n ints, in stored order.
lenLength of mols. Must be at least n.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE when no frame is stored; SEAMS_ERR_RANGE for a short buffer.
Ownership
The caller owns mols.
Thread safety
Read-only: may run alongside other const calls on sys.
Example
int mols[8] = {0};
seams_mols(sys, mols, 8);
SEAMS_API seams_status seams_mols(const seams_system *sys, int *mols, size_t len)
Copy the stored molecule ids out.

◆ seams_msd_create()

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.

Parameters
natomsParticle or molecule count per frame, at least 1. Above PTRDIFF_MAX / (3 * sizeof(double)) the coordinates cannot be allocated, which is SEAMS_ERR_RANGE.
max_lagMaximum lag in frames, or 0 to retain all lags. Above PTRDIFF_MAX / sizeof(double) - 1 the lag bins cannot be allocated, which is SEAMS_ERR_RANGE.
origin_strideFrame stride between time origins, at least 1.
dtPositive finite frame spacing in physical time units.
axisNon-zero 3-vector defining the axial direction.
outReceives the new handle; set to NULL on failure.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
The caller frees *out with seams_msd_destroy().
Thread safety
Pure aside from handle registration and the thread-local error string.
Example
const double axis[3] = {0, 0, 1};
seams_msd *msd = NULL;
seams_msd_create(4, 16, 1, 0.1, axis, &msd);
SEAMS_API void seams_msd_destroy(seams_msd *msd)
Free an MSD accumulator.
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

◆ seams_msd_curve()

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.

Any of lag_time, total, axial, lateral, and n_origins may be NULL to skip that column; pass all five as NULL to query n_lags.

Parameters
msdMSD handle.
lag_timeReceives lag times k * dt, or NULL.
totalReceives 3D total MSD, or NULL.
axialReceives 1D axial MSD along axis, or NULL.
lateralReceives 2D lateral MSD perpendicular to axis, or NULL.
n_originsReceives time-origin counts per lag, or NULL.
capCapacity of non-NULL output arrays.
n_lagsReceives the available lag count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_NOMEM.
Ownership
The caller owns all output buffers.
Thread safety
Read-only on msd.
Example
const double axis[3] = {0, 0, 1};
const double f0[3] = {0, 0, 0}, f1[3] = {0, 0, 1};
seams_msd *msd = NULL;
size_t nlags = 0;
seams_msd_create(1, 4, 1, 1.0, axis, &msd);
seams_msd_push(msd, f0, 1, NULL, 0);
seams_msd_push(msd, f1, 1, NULL, 0);
seams_msd_curve(msd, NULL, NULL, NULL, NULL, NULL, 0, &nlags);
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_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.

◆ seams_msd_destroy()

SEAMS_API void seams_msd_destroy ( seams_msd * msd)

Free an MSD accumulator.

Parameters
msdHandle from seams_msd_create(), or NULL.
Ownership
Releases the handle and its ring buffer.
Thread safety
Exclusive use of msd.
Example

◆ seams_msd_fit()

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.

Fits MSD_total = 6 D_total t + c, MSD_axial = 2 D_axial t + c, and MSD_lateral = 4 D_lateral t + c over [t_start, t_end]. Pass t_start = 0 and t_end = 0 for the default [0.1 t_max, 0.5 t_max] window.

Parameters
msdMSD handle with at least 2 lag points.
t_startWindow start time, >= 0.
t_endWindow end time, > t_start (or both 0 for default window).
d_totalReceives 3D diffusion coefficient, or NULL.
d_axialReceives 1D axial diffusion coefficient, or NULL.
d_lateralReceives 2D lateral diffusion coefficient, or NULL.
alphaReceives the log-log anomalous exponent, or NULL. Receives NaN when the window holds fewer than two lags with t > 0 and MSD_total > 1e-20, so the log-log fit was skipped; test it with isnan(). The diffusion coefficients are still the linear fit.
Returns
SEAMS_OK when the linear fit succeeded, including a skipped log-log fit (alpha NaN); SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
Writes scalar outputs owned by the caller.
Thread safety
Read-only on msd.
Example
const double axis[3] = {0, 0, 1};
const double f0[3] = {0, 0, 0}, f1[3] = {0, 0, 1}, f2[3] = {0, 0, 2};
seams_msd *msd = NULL;
double dtot = 0, dax = 0, dlat = 0, alpha = 0;
seams_msd_create(1, 4, 1, 1.0, axis, &msd);
seams_msd_push(msd, f0, 1, NULL, 0);
seams_msd_push(msd, f1, 1, NULL, 0);
seams_msd_push(msd, f2, 1, NULL, 0);
seams_msd_fit(msd, 0.0, 0.0, &dtot, &dax, &dlat, &alpha);
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.

◆ seams_msd_push()

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.

Pass box9 as NULL (with box_len 0) when xyz is already unwrapped, or pass a nine-number cell (with box_len 9) to unwrap incrementally across frames.

Parameters
msdMSD handle.
xyzCoordinates of 3 * natoms doubles in Angstrom.
natomsParticle count; must match the count passed to seams_msd_create().
box9Optional 9-number periodic cell, or NULL for unwrapped input.
box_lenMust be 9 when box9 is non-NULL, or 0 when box9 is NULL.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_BOX; SEAMS_ERR_ARG; SEAMS_ERR_STATE; SEAMS_ERR_NOMEM.
Ownership
The library copies coordinates into active origin slots as needed.
Thread safety
Exclusive use of msd.
Example
const double axis[3] = {0, 0, 1};
const double f0[3] = {0, 0, 0};
seams_msd *msd = NULL;
seams_msd_create(1, 8, 1, 1.0, axis, &msd);
seams_msd_push(msd, f0, 1, NULL, 0);

◆ seams_orientation_order()

SEAMS_API seams_status seams_orientation_order ( const double * vectors,
size_t n_vectors,
const double axis[3],
double * cos_theta,
double * p2,
size_t cap,
double * mean_p1,
double * mean_p2 )

Project molecular vectors onto an axis for P1 and P2 order parameters.

Computes cos_theta = u . e and P2 = 0.5 * (3 cos_theta^2 - 1) for each non-zero vector, where e is the normalized axis. Zero-length vectors receive NaN in per-molecule outputs and are omitted from mean_p1 and mean_p2.

Parameters
vectorsInput 3-vectors, 3 * n_vectors doubles (or NULL when n_vectors is 0).
n_vectorsNumber of 3-vectors.
axisNon-zero reference axis of 3 finite doubles.
cos_thetaOptional output buffer of cap doubles for cos(theta), or NULL.
p2Optional output buffer of cap doubles for P2(cos(theta)), or NULL.
capCapacity of non-NULL per-vector buffers; must be at least n_vectors.
mean_p1Receives ensemble mean of cos(theta), or NULL.
mean_p2Receives ensemble mean of P2(cos(theta)), or NULL.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
The caller owns all arrays.
Thread safety
Pure aside from the thread-local error string.
Example
const double vecs[6] = {0, 0, 1, 0, 0, 2};
const double axis[3] = {0, 0, 1};
double p1 = 0, p2 = 0;
seams_orientation_order(vecs, 2, axis, NULL, NULL, 0, &p1, &p2);
SEAMS_API seams_status seams_orientation_order(const double *vectors, size_t n_vectors, const double axis[3], double *cos_theta, double *p2, size_t cap, double *mean_p1, double *mean_p2)
Project molecular vectors onto an axis for P1 and P2 order parameters.

◆ seams_reorient_create()

SEAMS_API seams_status seams_reorient_create ( size_t n_vectors,
size_t max_lag,
size_t origin_stride,
double dt,
seams_reorient ** out )

Create a streaming orientational correlation accumulator for C1 and C2.

Parameters
n_vectorsNumber of molecular vectors per frame, at least 1. Above PTRDIFF_MAX / (3 * sizeof(double)) the vectors cannot be allocated, which is SEAMS_ERR_RANGE.
max_lagMaximum lag in frames, or 0 to retain all lags. Above PTRDIFF_MAX / sizeof(double) - 1 the lag bins cannot be allocated, which is SEAMS_ERR_RANGE.
origin_strideFrame stride between time origins, at least 1.
dtPositive finite frame spacing.
outReceives the new handle; set to NULL on failure.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
The caller frees *out with seams_reorient_destroy().
Thread safety
Pure aside from handle registration and the thread-local error string.
Example
seams_reorient *rot = NULL;
seams_reorient_create(4, 16, 1, 0.1, &rot);
SEAMS_API void seams_reorient_destroy(seams_reorient *reorient)
Free a reorientation accumulator.
SEAMS_API seams_status seams_reorient_create(size_t n_vectors, size_t max_lag, size_t origin_stride, double dt, seams_reorient **out)
Create a streaming orientational correlation accumulator for C1 and C2.
struct seams_reorient seams_reorient
Streaming orientational time-correlation accumulator.
Definition seams.h:264

◆ seams_reorient_curve()

SEAMS_API seams_status seams_reorient_curve ( const seams_reorient * reorient,
double * lag_time,
double * c1,
double * c2,
size_t * n_origins,
size_t cap,
size_t * n_lags )

Read accumulated C1(t) = <P1(u(0).u(t))> and C2(t) = <P2(u(0).u(t))>.

Parameters
reorientReorientation handle.
lag_timeReceives lag times k * dt, or NULL.
c1Receives first Legendre correlation C1, or NULL.
c2Receives second Legendre correlation C2, or NULL.
n_originsReceives origin counts per lag, or NULL.
capCapacity of non-NULL output arrays.
n_lagsReceives the available lag count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_NOMEM.
Ownership
The caller owns all output buffers.
Thread safety
Read-only on reorient.
Example
const double v0[3] = {0, 0, 1}, v1[3] = {0, 1, 0};
seams_reorient *rot = NULL;
size_t nlags = 0;
seams_reorient_create(1, 4, 1, 1.0, &rot);
seams_reorient_push(rot, v0, 1);
seams_reorient_push(rot, v1, 1);
seams_reorient_curve(rot, NULL, NULL, NULL, NULL, 0, &nlags);
SEAMS_API seams_status seams_reorient_curve(const seams_reorient *reorient, double *lag_time, double *c1, double *c2, size_t *n_origins, size_t cap, size_t *n_lags)
Read accumulated C1(t) = <P1(u(0).u(t))> and C2(t) = <P2(u(0).u(t))>.
SEAMS_API seams_status seams_reorient_push(seams_reorient *reorient, const double *vectors, size_t n_vectors)
Push one frame of molecular 3-vectors into a reorientation accumulator.

◆ seams_reorient_destroy()

SEAMS_API void seams_reorient_destroy ( seams_reorient * reorient)

Free a reorientation accumulator.

Parameters
reorientHandle from seams_reorient_create(), or NULL.
Ownership
Releases the handle and its ring buffer.
Thread safety
Exclusive use of reorient.
Example

◆ seams_reorient_fit()

SEAMS_API seams_status seams_reorient_fit ( const seams_reorient * reorient,
double t_start,
double t_end,
double * tau1_int,
double * tau1_exp,
double * tau2_int,
double * tau2_exp )

Integrated and single-exponential reorientation times tau_1 and tau_2.

Parameters
reorientReorientation handle with at least 2 lag points.
t_startFit window start time, >= 0.
t_endFit window end time, > t_start (or both 0 for full range).
tau1_intReceives trapezoidal integral of C1, or NULL.
tau1_expReceives exponential decay time of C1, or NULL.
tau2_intReceives trapezoidal integral of C2, or NULL.
tau2_expReceives exponential decay time of C2, or NULL.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
Writes scalar outputs owned by the caller.
Thread safety
Read-only on reorient.
Example
const double v0[3] = {0, 0, 1}, v1[3] = {0.6, 0, 0.8};
seams_reorient *rot = NULL;
double t1 = 0, t2 = 0;
seams_reorient_create(1, 4, 1, 1.0, &rot);
seams_reorient_push(rot, v0, 1);
seams_reorient_push(rot, v1, 1);
seams_reorient_fit(rot, 0.0, 0.0, &t1, NULL, &t2, NULL);
SEAMS_API seams_status seams_reorient_fit(const seams_reorient *reorient, double t_start, double t_end, double *tau1_int, double *tau1_exp, double *tau2_int, double *tau2_exp)
Integrated and single-exponential reorientation times tau_1 and tau_2.

◆ seams_reorient_push()

SEAMS_API seams_status seams_reorient_push ( seams_reorient * reorient,
const double * vectors,
size_t n_vectors )

Push one frame of molecular 3-vectors into a reorientation accumulator.

Non-zero vectors are normalized per molecule; zero-norm vectors are skipped in correlation pairs.

Parameters
reorientReorientation handle.
vectorsArray of 3 * n_vectors finite doubles.
n_vectorsVector count; must match seams_reorient_create().
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
The library copies normalized vectors into active origin slots.
Thread safety
Exclusive use of reorient.
Example
const double v0[3] = {0, 0, 1};
seams_reorient *rot = NULL;
seams_reorient_create(1, 4, 1, 1.0, &rot);
seams_reorient_push(rot, v0, 1);

◆ seams_set_mols()

SEAMS_API seams_status seams_set_mols ( seams_system * sys,
const int * mols,
size_t len )

Replace the stored molecule ids on a loaded frame.

Parameters
sysFrame handle.
molsCaller buffer of n molecule ids.
lenLength of mols. Must equal the stored atom count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE when no frame is stored; SEAMS_ERR_RANGE when len differs from the atom count.
Handle access
Non-const: updates stored molecule ids and clears the handle error slot.
Ownership
The library copies mols and keeps no pointer to caller memory.
Thread safety
Exclusive use of sys.
Example
const int mols[8] = {1, 1, 2, 2, 3, 3, 4, 4};
seams_set_mols(sys, mols, 8);
SEAMS_API seams_status seams_set_mols(seams_system *sys, const int *mols, size_t len)
Replace the stored molecule ids on a loaded frame.

◆ seams_traj_unwrap_centres()

SEAMS_API seams_status seams_traj_unwrap_centres ( const double * xyz,
size_t nframes,
size_t natoms,
const double * boxes,
size_t nboxes,
const int * mols,
size_t mols_len,
const double * masses,
size_t masses_len,
int * mol_ids_out,
size_t mol_ids_cap,
double * centres_out,
size_t centres_len,
size_t * n_mols )

Assemble per-molecule centres and unwrap them across frames.

Pass NULL for both mol_ids_out and centres_out to query n_mols first.

Parameters
xyzWrapped atom coordinates, nframes * 3 * natoms doubles.
nframesNumber of frames, at least 1.
natomsNumber of atoms per frame, at least 1.
boxesCell array of 9 * nboxes doubles.
nboxesCell count, either 1 or nframes.
molsMolecule id per atom, length mols_len.
mols_lenMust equal natoms.
massesOptional positive mass per atom, or NULL for equal weights.
masses_lenMust equal natoms when masses is non-NULL, or 0 when NULL.
mol_ids_outReceives unique molecule ids, or NULL.
mol_ids_capCapacity of mol_ids_out in ints when non-NULL.
centres_outReceives nframes * 3 * n_mols unwrapped coordinates, or NULL.
centres_lenCapacity of centres_out in doubles when non-NULL.
n_molsReceives the molecule count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_BOX; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
The caller owns all buffers.
Thread safety
Pure aside from the thread-local error string.
Example
const double box[9] = {0, 0, 0, 10, 10, 10, 0, 0, 0};
const double xyz[12] = {9.8, 0, 0, 0.2, 0, 0, 0.4, 0, 0, 0.8, 0, 0};
const int mols[2] = {1, 1};
size_t nm = 0;
double out[6] = {0};
seams_traj_unwrap_centres(xyz, 2, 2, box, 1, mols, 2, NULL, 0, NULL, 0, out, 6, &nm);
SEAMS_API seams_status seams_traj_unwrap_centres(const double *xyz, size_t nframes, size_t natoms, const double *boxes, size_t nboxes, const int *mols, size_t mols_len, const double *masses, size_t masses_len, int *mol_ids_out, size_t mol_ids_cap, double *centres_out, size_t centres_len, size_t *n_mols)
Assemble per-molecule centres and unwrap them across frames.

◆ seams_traj_unwrap_positions()

SEAMS_API seams_status seams_traj_unwrap_positions ( const double * xyz,
size_t nframes,
size_t natoms,
const double * boxes,
size_t nboxes,
double * unwrapped,
size_t unwrapped_len )

Unwrap periodic coordinates across consecutive frames.

Each step adds the minimum-image displacement under an orthorhombic or triclinic nine-number cell (ox, oy, oz, lx, ly, lz, xy, xz, yz). Pass nboxes equal to 1 for a constant cell or nframes for a deforming cell.

Parameters
xyzWrapped coordinates, nframes * 3 * natoms doubles in Angstrom.
nframesNumber of frames, at least 1.
natomsNumber of atoms per frame, at least 1.
boxesCell array of 9 * nboxes doubles.
nboxesCell count, either 1 or nframes.
unwrappedOutput buffer of unwrapped_len doubles.
unwrapped_lenCapacity in doubles, at least nframes * 3 * natoms.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_RANGE; SEAMS_ERR_BOX; SEAMS_ERR_ARG; SEAMS_ERR_NOMEM.
Ownership
The caller owns xyz, boxes, and unwrapped.
Thread safety
Pure aside from the thread-local error string.
Example
const double box[9] = {0, 0, 0, 10, 10, 10, 0, 0, 0};
const double wrapped[6] = {9.5, 1.0, 1.0, 0.5, 1.0, 1.0};
double unwrapped[6] = {0};
seams_traj_unwrap_positions(wrapped, 2, 1, box, 1, unwrapped, 6);
SEAMS_API seams_status seams_traj_unwrap_positions(const double *xyz, size_t nframes, size_t natoms, const double *boxes, size_t nboxes, double *unwrapped, size_t unwrapped_len)
Unwrap periodic coordinates across consecutive frames.

◆ seams_water_vectors()

SEAMS_API seams_status seams_water_vectors ( const seams_system * sys,
int oxygen_type,
int hydrogen_type,
int * mol_ids,
double * oh_mid,
double * bisector,
double * hh,
double * hh_unit,
size_t cap,
size_t * n_waters )

Water orientation vectors: O to H-midpoint and H-to-H under PBC.

Each water pairs one oxygen_type atom with two hydrogen_type atoms via shared molecule ids when available, or via minimum-image covalent distance otherwise. Pass NULL for all five output arrays to query n_waters.

Parameters
sysFrame handle.
oxygen_typeSpecies integer of water oxygen.
hydrogen_typeSpecies integer of water hydrogen, distinct from oxygen_type.
mol_idsReceives molecule ids, length cap, or NULL.
oh_midReceives O-to-H-midpoint vectors in Angstrom, 3 * cap doubles, or NULL.
bisectorReceives unit bisector vectors, 3 * cap doubles, or NULL.
hhReceives H1-to-H2 vectors in Angstrom, 3 * cap doubles, or NULL.
hh_unitReceives unit H1-to-H2 vectors, 3 * cap doubles, or NULL.
capMolecule capacity of every non-NULL output array.
n_watersReceives the water count.
Returns
SEAMS_OK; SEAMS_ERR_NULL; SEAMS_ERR_STATE; SEAMS_ERR_RANGE; SEAMS_ERR_ARG; SEAMS_ERR_BOX; SEAMS_ERR_NOMEM.
Ownership
The caller owns all output arrays.
Thread safety
Read-only on sys.
Example
size_t nw = 0;
seams_water_vectors(sys, 1, 2, NULL, NULL, NULL, NULL, NULL, 0, &nw);
SEAMS_API seams_status seams_water_vectors(const seams_system *sys, int oxygen_type, int hydrogen_type, int *mol_ids, double *oh_mid, double *bisector, double *hh, double *hh_unit, size_t cap, size_t *n_waters)
Water orientation vectors: O to H-midpoint and H-to-H under PBC.