pub struct System { /* private fields */ }Expand description
One frame: coordinates, a cell, and the analyses that read them.
The handle is freed on drop. It is Send and not Sync.
let mut system = seams::System::new()?;
assert_eq!(system.count(), 0);
let err = system.read("missing-trajectory.lammpstrj", 1, -1).expect_err("no such file");
assert!(!err.message().is_empty());Implementations§
Source§impl System
impl System
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Allocate an empty frame.
let system = seams::System::new()?;
assert_eq!(system.count(), 0);Sourcepub fn set_ortho(
&mut self,
xyz: &[f64],
lx: f64,
ly: f64,
lz: f64,
) -> Result<(), Error>
pub fn set_ortho( &mut self, xyz: &[f64], lx: f64, ly: f64, lz: f64, ) -> Result<(), Error>
Store points in an orthorhombic cell whose origin is zero.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
assert_eq!(system.count(), 8);Sourcepub fn set_frame(&mut self, xyz: &[f64], box9: &[f64; 9]) -> Result<(), Error>
pub fn set_frame(&mut self, xyz: &[f64], box9: &[f64; 9]) -> Result<(), Error>
Store points and a general nine-number cell.
let (xyz, edge) = seams::diamond8();
let mut box9 = [0.0; 9];
box9[3] = edge;
box9[4] = edge;
box9[5] = edge;
box9[6] = 0.3;
let mut system = seams::System::new()?;
system.set_frame(&xyz, &box9)?;
assert_eq!(system.count(), 8);Sourcepub fn set_atoms(
&mut self,
xyz: &[f64],
box9: &[f64],
types: &[i32],
ids: &[i32],
) -> Result<(), Error>
pub fn set_atoms( &mut self, xyz: &[f64], box9: &[f64], types: &[i32], ids: &[i32], ) -> Result<(), Error>
Store points, a cell, and optional species and ids.
box9 is ox, oy, oz, lx, ly, lz, xy, xz, yz. Empty types and
ids leave those columns unset.
let (xyz, edge) = seams::diamond8();
let box9 = [0.0, 0.0, 0.0, edge, edge, edge, 0.0, 0.0, 0.0];
let types = [1; 8];
let mut system = seams::System::new()?;
system.set_atoms(&xyz, &box9, &types, &[])?;
assert_eq!(system.count(), 8);Sourcepub fn read(
&mut self,
path: &str,
frame: i32,
type_filter: i32,
) -> Result<(), Error>
pub fn read( &mut self, path: &str, frame: i32, type_filter: i32, ) -> Result<(), Error>
Read one frame from a trajectory path.
frame is 1-based. A negative type_filter keeps every atom.
The path may be XYZ, CON, a chemfiles format, or a LAMMPS dump.
let mut system = seams::System::new()?;
let err = system.read("no-such-frame.xyz", 1, -1).unwrap_err();
assert!(!err.message().is_empty());Sourcepub fn count(&self) -> i32
pub fn count(&self) -> i32
Number of points in the frame.
let system = seams::System::new()?;
assert_eq!(system.count(), 0);Sourcepub fn chill(&mut self, options: &ChillOptions) -> Result<Classification, Error>
pub fn chill(&mut self, options: &ChillOptions) -> Result<Classification, Error>
Original CHILL labels and nine population counts.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let ice = system.chill(&seams::ChillOptions::default())?;
assert_eq!(ice.labels.len(), 8);Sourcepub fn chill_plus(
&mut self,
options: &ChillOptions,
) -> Result<Classification, Error>
pub fn chill_plus( &mut self, options: &ChillOptions, ) -> Result<Classification, Error>
CHILL+ labels and nine population counts.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let ice = system.chill_plus(&seams::ChillOptions {
graph: seams::Graph::Mutual,
rule: seams::ChillRule::Ovito,
..seams::ChillOptions::default()
})?;
assert_eq!(ice.counts.iter().sum::<i32>() as usize, ice.labels.len());Sourcepub fn steinhardt(
&mut self,
options: &SteinhardtOptions,
) -> Result<Steinhardt, Error>
pub fn steinhardt( &mut self, options: &SteinhardtOptions, ) -> Result<Steinhardt, Error>
Local q_l on the cutoff shell.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let q3 = system.steinhardt(&seams::SteinhardtOptions { order: 3, ..Default::default() })?;
assert!(q3.average.is_none());
assert_eq!(q3.local.len(), 8);Sourcepub fn ql(&mut self, options: &OrderOptions) -> Result<Steinhardt, Error>
pub fn ql(&mut self, options: &OrderOptions) -> Result<Steinhardt, Error>
Local q_l on a named graph.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let q4 = system.ql(&seams::OrderOptions { order: 4, ..Default::default() })?;
assert_eq!(q4.local.len(), 8);Sourcepub fn q4q6(&mut self, cutoff: f64) -> Result<Q4Q6, Error>
pub fn q4q6(&mut self, cutoff: f64) -> Result<Q4Q6, Error>
Local q4 and q6 on the cutoff shell.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let orders = system.q4q6(3.5)?;
let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
assert!(mean > 0.3);Sourcepub fn q6bar(&mut self, options: &Q6BarOptions) -> Result<Q6Bar, Error>
pub fn q6bar(&mut self, options: &Q6BarOptions) -> Result<Q6Bar, Error>
q6-bar, its mean and median, and the ice count above the cut.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let summary = system.q6bar(&seams::Q6BarOptions::default())?;
assert!(summary.n_ice >= 0);Sourcepub fn neighbours(
&mut self,
options: &NeighbourOptions,
) -> Result<Neighbours, Error>
pub fn neighbours( &mut self, options: &NeighbourOptions, ) -> Result<Neighbours, Error>
Cutoff or mutual neighbour list.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let list = system.neighbours(&seams::NeighbourOptions::default())?;
assert_eq!(list.degrees()?.iter().sum::<i32>(), list.nnz()? as i32);Sourcepub fn knn(&mut self, options: &KnnOptions) -> Result<Neighbours, Error>
pub fn knn(&mut self, options: &KnnOptions) -> Result<Neighbours, Error>
k-nearest neighbour list.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let list = system.knn(&seams::KnnOptions { mutual: true, ..Default::default() })?;
assert!(list.nnz()? > 0);Sourcepub fn neighbour_degree(&mut self, cutoff: f64) -> Result<Vec<i32>, Error>
pub fn neighbour_degree(&mut self, cutoff: f64) -> Result<Vec<i32>, Error>
Degree of each atom on the cutoff graph.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let degree = system.neighbour_degree(3.5)?;
assert!(degree.iter().all(|d| *d == 4));Sourcepub fn rings(&mut self, options: &RingOptions) -> Result<Rings, Error>
pub fn rings(&mut self, options: &RingOptions) -> Result<Rings, Error>
Primitive rings up to a maximum size.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let rings = system.rings(&seams::RingOptions::default())?;
assert!(rings.fraction(0)?.is_finite());Sourcepub fn six_ring_fraction(&mut self, cutoff: f64) -> Result<(i32, f64), Error>
pub fn six_ring_fraction(&mut self, cutoff: f64) -> Result<(i32, f64), Error>
Count of six-rings and the fraction of atoms that sit on one.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let (six, fraction) = system.six_ring_fraction(3.5)?;
assert!(six >= 0);
assert!(fraction.is_finite());Sourcepub fn cages(&mut self, options: &CageOptions) -> Result<Cages, Error>
pub fn cages(&mut self, options: &CageOptions) -> Result<Cages, Error>
Hexagonal and double-diamond cage membership.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let cages = system.cages(&seams::CageOptions::default())?;
let _ = cages.counts()?;Sourcepub fn signature_cages(
&mut self,
options: &SignatureOptions,
) -> Result<SignatureMatch, Error>
pub fn signature_cages( &mut self, options: &SignatureOptions, ) -> Result<SignatureMatch, Error>
Closed cages of one ring census.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let err = system.signature_cages(&seams::SignatureOptions::default()).unwrap_err();
assert_eq!(err.status(), Some(seams::Status::Argument));Sourcepub fn rdf(
&mut self,
options: &DistributionOptions,
) -> Result<Distribution, Error>
pub fn rdf( &mut self, options: &DistributionOptions, ) -> Result<Distribution, Error>
Partial radial distribution and the cell volume.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let g = system.rdf(&seams::DistributionOptions { rmax: 6.0, bins: 4, ..Default::default() })?;
assert_eq!(g.radius.len(), g.g.len());Sourcepub fn running_cn(
&mut self,
options: &DistributionOptions,
) -> Result<RunningCoordination, Error>
pub fn running_cn( &mut self, options: &DistributionOptions, ) -> Result<RunningCoordination, Error>
Running coordination number along the partial RDF.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let series = system.running_cn(&seams::DistributionOptions { rmax: 6.0, bins: 4, ..Default::default() })?;
assert!(!series.coordination.is_empty());Sourcepub fn coordination(
&mut self,
options: &DistributionOptions,
) -> Result<f64, Error>
pub fn coordination( &mut self, options: &DistributionOptions, ) -> Result<f64, Error>
Coordination number integrated to rmax.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let cn = system.coordination(&seams::DistributionOptions { rmax: 3.5, bins: 8, ..Default::default() })?;
assert!(cn.is_finite());Sourcepub fn hbonds(&mut self, options: &BondOptions) -> Result<i32, Error>
pub fn hbonds(&mut self, options: &BondOptions) -> Result<i32, Error>
Hydrogen-bond count.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let bonds = system.hbonds(&seams::BondOptions::default())?;
assert_eq!(bonds, 0);Sourcepub fn density(
&mut self,
options: &DensityOptions,
) -> Result<DensityProfile, Error>
pub fn density( &mut self, options: &DensityOptions, ) -> Result<DensityProfile, Error>
Number density along one cell axis.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let rho = system.density(&seams::DensityOptions { bins: 2, ..Default::default() })?;
assert_eq!(rho.density.len(), 2);Sourcepub fn fingerprint(
&mut self,
options: &FingerprintOptions,
) -> Result<Fingerprint, Error>
pub fn fingerprint( &mut self, options: &FingerprintOptions, ) -> Result<Fingerprint, Error>
Topological fingerprint of the bonded graph.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let fp = system.fingerprint(&seams::FingerprintOptions::default())?;
assert!(!fp.key()?.is_empty());Sourcepub fn contact_pairs(&mut self, spec: &str) -> Result<Contacts, Error>
pub fn contact_pairs(&mut self, spec: &str) -> Result<Contacts, Error>
Mutual nearest unlike contacts. spec is site-table text.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let contacts = system.contact_pairs("1=cationHead")?;
assert_eq!(contacts.pairs, 0);Sourcepub fn domains(
&mut self,
options: &DomainOptions,
) -> Result<DomainReport, Error>
pub fn domains( &mut self, options: &DomainOptions, ) -> Result<DomainReport, Error>
Largest polar or apolar domain.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let domain = system.domains(&seams::DomainOptions { spec: "1=waterO".into(), ..Default::default() })?;
assert!(domain.largest >= 0);Sourcepub fn prisms(&mut self, options: &PrismOptions) -> Result<PrismCensus, Error>
pub fn prisms(&mut self, options: &PrismOptions) -> Result<PrismCensus, Error>
Perfect and imperfect prism counts by ring size.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let prisms = system.prisms(&seams::PrismOptions::default())?;
assert_eq!(prisms.perfect.len(), 7);Sourcepub fn monolayer(&mut self, options: &SheetOptions) -> Result<Vec<i32>, Error>
pub fn monolayer(&mut self, options: &SheetOptions) -> Result<Vec<i32>, Error>
Primitive-ring histogram of a monolayer.
counts[k] is the number of rings of size k.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let sheet = system.monolayer(&seams::SheetOptions { sheet_area: 10.0, ..Default::default() })?;
assert_eq!(sheet.len(), 7);Sourcepub fn site_table(&mut self, spec: &str) -> Result<Vec<i32>, Error>
pub fn site_table(&mut self, spec: &str) -> Result<Vec<i32>, Error>
Per-atom site kind. spec is site-table text such as 1=waterO.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let kinds = system.site_table("1=waterO")?;
assert_eq!(kinds.len(), 8);Sourcepub fn symmetry(&mut self, shell_rmsd: f64) -> Result<Vec<i32>, Error>
pub fn symmetry(&mut self, shell_rmsd: f64) -> Result<Vec<i32>, Error>
Per-atom ice-shell label.
A non-positive shell_rmsd selects the library ceiling. The label
is 0 for ice Ih, 1 for ice Ic, 2 for stacking disorder, or -1 when
the shell does not match.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let labels = system.symmetry(0.0)?;
assert_eq!(labels.len(), 8);Sourcepub fn brine(
&mut self,
ice: &[i32],
options: &BrineOptions,
) -> Result<Brine, Error>
pub fn brine( &mut self, ice: &[i32], options: &BrineOptions, ) -> Result<Brine, Error>
Planar ice front from an ice assignment.
ice[i] is non-zero when atom i is ice. The slice length must
equal count.
let (xyz, edge) = seams::diamond8();
let mut system = seams::System::new()?;
system.set_ortho(&xyz, edge, edge, edge)?;
let front = system.brine(&[1; 8], &seams::BrineOptions::default())?;
let _ = front.profile()?;