Skip to main content

System

Struct System 

Source
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

Source

pub fn new() -> Result<Self, Error>

Allocate an empty frame.

let system = seams::System::new()?;
assert_eq!(system.count(), 0);
Source

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);
Source

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);
Source

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);
Source

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());
Source

pub fn count(&self) -> i32

Number of points in the frame.

let system = seams::System::new()?;
assert_eq!(system.count(), 0);
Source

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);
Source

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());
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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));
Source

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());
Source

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());
Source

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()?;
Source

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));
Source

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());
Source

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());
Source

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());
Source

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);
Source

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);
Source

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());
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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()?;

Trait Implementations§

Source§

impl Drop for System

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for System

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.