Skip to main content

Crate seams

Crate seams 

Source
Expand description

Safe calls into the d-SEAMS C API.

d-SEAMS classifies the molecules of a simulation frame. This crate gives Rust programs its analyses: CHILL and CHILL+ ice labels, Steinhardt order parameters, primitive rings, cages, radial distribution functions, hydrogen bonds, topological fingerprints and planar brine fronts.

The crates.io package is dseams. The library keeps the name seams, so code says use seams::System.

§Quick example

Coordinates and cutoffs are in angstroms. This program classifies the eight-atom cubic ice cell that diamond8 returns:

let (xyz, edge) = seams::diamond8();
seams::set_num_threads(1)?;
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
assert_eq!(system.count(), 8);
let ice = system.chill_plus(&seams::ChillOptions::default())?;
assert_eq!(ice.counts[seams::Label::Cubic as usize], 8);
let orders = system.q4q6(3.5)?;
assert!(orders.q6.iter().all(|value| value.is_finite()));

§How the crate is organised

A System holds one frame. System::set_ortho, System::set_frame, System::set_atoms and System::read fill it, and every analysis is a method on it. A cell is nine numbers in the LAMMPS order: origin, edge lengths, then the tilts xy, xz and yz.

Analyses with several settings take an options struct that implements Default, so you change only the fields you need. Neighbour lists and rings can be iterated.

§Errors, ownership and threads

Every call that can fail returns Result<T, Error>. An Error carries the engine’s message and, when the crate names it, a Status. Each handle (System, Neighbours, Rings, Cages, Fingerprint and Brine) owns a native object and frees it in Drop.

A handle may move to another thread (Send). It is not Sync, because the C library requires exclusive use of a handle. Separate handles may run the Steinhardt calls on separate threads. The OpenMP width set by set_num_threads is process-global.

§Choosing a libseams

The dseams-sys build script links the shared libseams in the directory named by SEAMS_LIBDIR when that variable is set. Otherwise it uses the bundled feature, which compiles the engine from source and reads LAMMPS dumps and XYZ files, or an installed library found through pkg-config. A bundled build also enables chemfiles and readcon-core when pkg-config finds them. has_chemfiles and has_readcon report the linked engine’s readers. cargo add dseams --features bundled is the shortest way to a working build.

The raw C declarations are re-exported as ffi.

§Learn more

The book has a getting-started page and tutorials that run the analyses on real frames. The engine book covers the science behind each analysis.

Re-exports§

pub use seams_sys as ffi;

Structs§

BondOptions
Knobs for a hydrogen-bond count.
Brine
Owned planar ice-front measurement.
BrineFronts
The two planar crossings of an ice slab.
BrineOptions
Knobs for a planar ice front.
BrineProfile
Concentration profile along the brine axis.
CageCounts
Disjoint cage populations.
CageOptions
Knobs for hexagonal and double-diamond cages.
Cages
Owned hexagonal and double-diamond membership.
ChillOptions
Knobs for CHILL and CHILL+.
Classification
CHILL or CHILL+ labels and the nine population counts.
Contacts
Mutual nearest unlike contacts of a site table.
DensityOptions
Knobs for the axial number density.
DensityProfile
Number density along one cell axis.
Distribution
Partial radial distribution.
DistributionOptions
Knobs for a partial RDF, its running coordination, or the integral.
DomainOptions
Knobs for a domain search.
DomainReport
Largest polar or apolar domain.
Fingerprint
Owned topological fingerprint.
FingerprintOptions
Knobs for a topological fingerprint.
KnnOptions
Knobs for a k-nearest neighbour list.
NeighbourOptions
Knobs for a neighbour list.
NeighbourPair
One directed neighbour pair. The self entry is omitted.
NeighbourPairs
Iterator of directed neighbour pairs.
Neighbours
Owned neighbour list.
OrderOptions
Knobs for q_l on a named graph.
Pockets
Brine pockets trapped in the ice.
PrismCensus
Perfect and imperfect prism counts by ring size.
PrismOptions
Knobs for prism stacks.
Q4Q6
Local q4 and q6 on the cutoff shell.
Q6Bar
Lechner-Dellago q6-bar and the ice count above a cut.
Q6BarOptions
Knobs for the q6-bar ice summary.
Rejection
Molal rejection coefficient.
RingIter
Iterator of primitive rings. Each item is a Result of vertex indices.
RingOptions
Knobs for primitive rings.
Rings
Owned primitive-ring set.
RunningCoordination
Running coordination number along a partial RDF.
SheetOptions
Knobs for a monolayer ring histogram.
SignatureMatch
Closed cages whose ring census matches a signature.
SignatureOptions
Knobs for a signature cage census.
Steinhardt
Local Steinhardt parameter, and the average when it was requested.
SteinhardtOptions
Knobs for a local Steinhardt parameter on the cutoff shell.
System
One frame: coordinates, a cell, and the analyses that read them.

Enums§

Axis
Cell axis.
CageLabel
Per-atom cage membership. The four codes are disjoint.
ChillRule
CHILL+ threshold table.
DomainSubset
Domain subset. The values match the C API.
Error
A failed call. The message is seams_handle_error when the call had a handle.
Graph
Neighbour graph.
Label
CHILL and CHILL+ atom label. Classification::counts[label as usize] is the population.
RingSymmetry
Primitive-ring symmetry class.
SiteKind
Site-table kind.
Status
Status codes. The numeric values match seams_status.

Functions§

abi
ABI number compiled into this library. The value is 1.
diamond8
Eight-atom cubic diamond used by the crate examples.
has_chemfiles
Whether the linked engine reads formats provided by chemfiles, including PDB and GRO.
has_readcon
Whether the linked engine reads .con files through readcon-core.
label_name
Short name of a CHILL+ label.
nframes
Count frames in a trajectory path.
num_threads
OpenMP width the next call will use.
ring_symmetry_name
Short name of a ring-symmetry code.
set_num_threads
Set the OpenMP width for the next call. Zero restores the library default.
version
Library version text, for example 2.14.1.