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);
Examples found in repository?
examples/ice.rs (line 30)
28fn main() {
29    let (xyz, length) = diamond(2);
30    let mut sys = seams::System::new().expect("system");
31    sys.set_ortho(&xyz, length, length, length).expect("frame");
32    let ice = sys
33        .chill_plus(&seams::ChillOptions::default())
34        .expect("chill+");
35    println!(
36        "dseams {} cubic {} of {}",
37        seams::version(),
38        ice.counts[0],
39        ice.labels.len()
40    );
41}
More examples
Hide additional examples
examples/lang_tasks.rs (line 26)
25fn census(path: &str) -> Result<String, Error> {
26    let mut frame = System::new()?;
27    frame.read(path, 1, -1)?;
28    let pairs = frame.neighbours(&NeighbourOptions::default())?.nnz()?;
29    let rings = frame
30        .rings(&RingOptions {
31            max_size: 6,
32            ..RingOptions::default()
33        })?
34        .histogram(6)?;
35    let chill = frame.chill_plus(&ChillOptions::default())?;
36    Ok(format!(
37        "pairs {pairs} rings {} chill {}",
38        joined(&rings),
39        joined(&chill.counts)
40    ))
41}
examples/ice_ih.rs (line 12)
11fn census(path: &str) -> String {
12    let mut system = System::new().expect("system");
13    system.read(path, 1, 1).expect("read");
14    let n = system.count();
15    let order = system.q4q6(3.5).expect("q6");
16    let mean = order.q6.iter().sum::<f64>() / order.q6.len() as f64;
17    let ice = system.chill_plus(&ChillOptions::default()).expect("chill+");
18    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
19    format!(
20        "rust ice nop {} q6 {:.6} hexagonal {} rings {}",
21        n,
22        mean,
23        ice.counts[Label::Hexagonal as usize],
24        six
25    )
26}
examples/minimal.rs (line 76)
71fn run(path: &str) -> String {
72    let (xyz, edges) = read_dump(path);
73    assert_eq!(xyz.len() / 3, 46);
74    set_num_threads(1).expect("threads");
75    assert_eq!(num_threads(), 1);
76    let mut system = System::new().expect("system");
77    system
78        .set_ortho(&xyz, edges[0], edges[1], edges[2])
79        .expect("frame");
80    assert_eq!(system.count(), 46);
81    let degree = system.neighbour_degree(3.5).expect("neighbours");
82    assert_eq!(degree.len(), 46);
83    let orders = system.q4q6(3.5).expect("q6");
84    let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
85    let ice = system
86        .chill_plus(&seams::ChillOptions::default())
87        .expect("chill+");
88    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
89    assert_eq!(ice.counts[4], 46);
90    assert_eq!(six, 54);
91    assert!(mean > 0.5);
92    format!("rust example ok {} q6 {:.3}", version(), mean)
93}
examples/binding_overhead.rs (line 44)
17fn main() {
18    let mut frames: HashMap<String, System> = HashMap::new();
19    let mut loaded: HashMap<String, bool> = HashMap::new();
20    let mut sink = 0.0_f64;
21    let stdin = std::io::stdin();
22    let mut out = std::io::stdout();
23    for line in stdin.lock().lines() {
24        let line = line.unwrap_or_default();
25        if line.is_empty() {
26            continue;
27        }
28        if line.starts_with("quit") {
29            break;
30        }
31        let mut parts = line.split_whitespace();
32        let threads: i32 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
33        let op = parts.next().unwrap_or("").to_string();
34        let path = parts.next().unwrap_or("").to_string();
35        if threads < 1 || path.is_empty() {
36            eprintln!("error command");
37            std::process::exit(1);
38        }
39        if let Err(err) = retune(threads) {
40            eprintln!("error {err}");
41            std::process::exit(1);
42        }
43        let sys = frames.entry(path.clone()).or_insert_with(|| {
44            System::new().unwrap_or_else(|err| {
45                eprintln!("error {err}");
46                std::process::exit(1);
47            })
48        });
49        let ready = loaded.get(&path).copied().unwrap_or(false);
50        if op != "read" && !ready {
51            if let Err(err) = sys.read(&path, 1, -1) {
52                eprintln!("error {err}");
53                std::process::exit(1);
54            }
55            loaded.insert(path.clone(), true);
56        }
57        let t0 = Instant::now();
58        let result = match op.as_str() {
59            "read" => sys.read(&path, 1, -1).map(|_| {
60                loaded.insert(path.clone(), true);
61                sink += f64::from(sys.count());
62            }),
63            "knn" => sys
64                .knn(&seams::KnnOptions {
65                    k: 4,
66                    cutoff: 3.5,
67                    mutual: true,
68                    ..seams::KnnOptions::default()
69                })
70                .and_then(|nb| {
71                    sink += nb.nnz()? as f64;
72                    Ok(())
73                }),
74            "steinhardt" => sys
75                .steinhardt(&seams::SteinhardtOptions {
76                    cutoff: 3.5,
77                    order: 6,
78                    average: true,
79                    ..seams::SteinhardtOptions::default()
80                })
81                .map(|q| {
82                    let extra = q.average.as_ref().map(|v| v[0]).unwrap_or(0.0);
83                    sink += q.local[0] + extra;
84                }),
85            "chill" => sys
86                .chill(&seams::ChillOptions {
87                    cutoff: 3.5,
88                    ..seams::ChillOptions::default()
89                })
90                .map(|ice| {
91                    sink += f64::from(ice.counts[1]);
92                }),
93            "rings" => sys
94                .rings(&seams::RingOptions {
95                    cutoff: 3.5,
96                    max_size: 6,
97                    ..seams::RingOptions::default()
98                })
99                .map(|rings| {
100                    sink += f64::from(rings.size());
101                }),
102            _ => {
103                eprintln!("error {op}");
104                std::process::exit(1);
105            }
106        };
107        let ms = t0.elapsed().as_secs_f64() * 1e3;
108        if let Err(err) = result {
109            eprintln!("error {err}");
110            std::process::exit(1);
111        }
112        writeln!(out, "{ms:.9}").ok();
113        out.flush().ok();
114    }
115    eprintln!("sink {sink:.6}");
116}
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);
Examples found in repository?
examples/ice.rs (line 31)
28fn main() {
29    let (xyz, length) = diamond(2);
30    let mut sys = seams::System::new().expect("system");
31    sys.set_ortho(&xyz, length, length, length).expect("frame");
32    let ice = sys
33        .chill_plus(&seams::ChillOptions::default())
34        .expect("chill+");
35    println!(
36        "dseams {} cubic {} of {}",
37        seams::version(),
38        ice.counts[0],
39        ice.labels.len()
40    );
41}
More examples
Hide additional examples
examples/minimal.rs (line 78)
71fn run(path: &str) -> String {
72    let (xyz, edges) = read_dump(path);
73    assert_eq!(xyz.len() / 3, 46);
74    set_num_threads(1).expect("threads");
75    assert_eq!(num_threads(), 1);
76    let mut system = System::new().expect("system");
77    system
78        .set_ortho(&xyz, edges[0], edges[1], edges[2])
79        .expect("frame");
80    assert_eq!(system.count(), 46);
81    let degree = system.neighbour_degree(3.5).expect("neighbours");
82    assert_eq!(degree.len(), 46);
83    let orders = system.q4q6(3.5).expect("q6");
84    let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
85    let ice = system
86        .chill_plus(&seams::ChillOptions::default())
87        .expect("chill+");
88    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
89    assert_eq!(ice.counts[4], 46);
90    assert_eq!(six, 54);
91    assert!(mean > 0.5);
92    format!("rust example ok {} q6 {:.3}", version(), mean)
93}
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());
Examples found in repository?
examples/lang_tasks.rs (line 27)
25fn census(path: &str) -> Result<String, Error> {
26    let mut frame = System::new()?;
27    frame.read(path, 1, -1)?;
28    let pairs = frame.neighbours(&NeighbourOptions::default())?.nnz()?;
29    let rings = frame
30        .rings(&RingOptions {
31            max_size: 6,
32            ..RingOptions::default()
33        })?
34        .histogram(6)?;
35    let chill = frame.chill_plus(&ChillOptions::default())?;
36    Ok(format!(
37        "pairs {pairs} rings {} chill {}",
38        joined(&rings),
39        joined(&chill.counts)
40    ))
41}
More examples
Hide additional examples
examples/ice_ih.rs (line 13)
11fn census(path: &str) -> String {
12    let mut system = System::new().expect("system");
13    system.read(path, 1, 1).expect("read");
14    let n = system.count();
15    let order = system.q4q6(3.5).expect("q6");
16    let mean = order.q6.iter().sum::<f64>() / order.q6.len() as f64;
17    let ice = system.chill_plus(&ChillOptions::default()).expect("chill+");
18    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
19    format!(
20        "rust ice nop {} q6 {:.6} hexagonal {} rings {}",
21        n,
22        mean,
23        ice.counts[Label::Hexagonal as usize],
24        six
25    )
26}
examples/binding_overhead.rs (line 51)
17fn main() {
18    let mut frames: HashMap<String, System> = HashMap::new();
19    let mut loaded: HashMap<String, bool> = HashMap::new();
20    let mut sink = 0.0_f64;
21    let stdin = std::io::stdin();
22    let mut out = std::io::stdout();
23    for line in stdin.lock().lines() {
24        let line = line.unwrap_or_default();
25        if line.is_empty() {
26            continue;
27        }
28        if line.starts_with("quit") {
29            break;
30        }
31        let mut parts = line.split_whitespace();
32        let threads: i32 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
33        let op = parts.next().unwrap_or("").to_string();
34        let path = parts.next().unwrap_or("").to_string();
35        if threads < 1 || path.is_empty() {
36            eprintln!("error command");
37            std::process::exit(1);
38        }
39        if let Err(err) = retune(threads) {
40            eprintln!("error {err}");
41            std::process::exit(1);
42        }
43        let sys = frames.entry(path.clone()).or_insert_with(|| {
44            System::new().unwrap_or_else(|err| {
45                eprintln!("error {err}");
46                std::process::exit(1);
47            })
48        });
49        let ready = loaded.get(&path).copied().unwrap_or(false);
50        if op != "read" && !ready {
51            if let Err(err) = sys.read(&path, 1, -1) {
52                eprintln!("error {err}");
53                std::process::exit(1);
54            }
55            loaded.insert(path.clone(), true);
56        }
57        let t0 = Instant::now();
58        let result = match op.as_str() {
59            "read" => sys.read(&path, 1, -1).map(|_| {
60                loaded.insert(path.clone(), true);
61                sink += f64::from(sys.count());
62            }),
63            "knn" => sys
64                .knn(&seams::KnnOptions {
65                    k: 4,
66                    cutoff: 3.5,
67                    mutual: true,
68                    ..seams::KnnOptions::default()
69                })
70                .and_then(|nb| {
71                    sink += nb.nnz()? as f64;
72                    Ok(())
73                }),
74            "steinhardt" => sys
75                .steinhardt(&seams::SteinhardtOptions {
76                    cutoff: 3.5,
77                    order: 6,
78                    average: true,
79                    ..seams::SteinhardtOptions::default()
80                })
81                .map(|q| {
82                    let extra = q.average.as_ref().map(|v| v[0]).unwrap_or(0.0);
83                    sink += q.local[0] + extra;
84                }),
85            "chill" => sys
86                .chill(&seams::ChillOptions {
87                    cutoff: 3.5,
88                    ..seams::ChillOptions::default()
89                })
90                .map(|ice| {
91                    sink += f64::from(ice.counts[1]);
92                }),
93            "rings" => sys
94                .rings(&seams::RingOptions {
95                    cutoff: 3.5,
96                    max_size: 6,
97                    ..seams::RingOptions::default()
98                })
99                .map(|rings| {
100                    sink += f64::from(rings.size());
101                }),
102            _ => {
103                eprintln!("error {op}");
104                std::process::exit(1);
105            }
106        };
107        let ms = t0.elapsed().as_secs_f64() * 1e3;
108        if let Err(err) = result {
109            eprintln!("error {err}");
110            std::process::exit(1);
111        }
112        writeln!(out, "{ms:.9}").ok();
113        out.flush().ok();
114    }
115    eprintln!("sink {sink:.6}");
116}
Source

pub fn count(&self) -> i32

Number of points in the frame.

let system = seams::System::new()?;
assert_eq!(system.count(), 0);
Examples found in repository?
examples/ice_ih.rs (line 14)
11fn census(path: &str) -> String {
12    let mut system = System::new().expect("system");
13    system.read(path, 1, 1).expect("read");
14    let n = system.count();
15    let order = system.q4q6(3.5).expect("q6");
16    let mean = order.q6.iter().sum::<f64>() / order.q6.len() as f64;
17    let ice = system.chill_plus(&ChillOptions::default()).expect("chill+");
18    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
19    format!(
20        "rust ice nop {} q6 {:.6} hexagonal {} rings {}",
21        n,
22        mean,
23        ice.counts[Label::Hexagonal as usize],
24        six
25    )
26}
More examples
Hide additional examples
examples/minimal.rs (line 80)
71fn run(path: &str) -> String {
72    let (xyz, edges) = read_dump(path);
73    assert_eq!(xyz.len() / 3, 46);
74    set_num_threads(1).expect("threads");
75    assert_eq!(num_threads(), 1);
76    let mut system = System::new().expect("system");
77    system
78        .set_ortho(&xyz, edges[0], edges[1], edges[2])
79        .expect("frame");
80    assert_eq!(system.count(), 46);
81    let degree = system.neighbour_degree(3.5).expect("neighbours");
82    assert_eq!(degree.len(), 46);
83    let orders = system.q4q6(3.5).expect("q6");
84    let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
85    let ice = system
86        .chill_plus(&seams::ChillOptions::default())
87        .expect("chill+");
88    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
89    assert_eq!(ice.counts[4], 46);
90    assert_eq!(six, 54);
91    assert!(mean > 0.5);
92    format!("rust example ok {} q6 {:.3}", version(), mean)
93}
examples/binding_overhead.rs (line 61)
17fn main() {
18    let mut frames: HashMap<String, System> = HashMap::new();
19    let mut loaded: HashMap<String, bool> = HashMap::new();
20    let mut sink = 0.0_f64;
21    let stdin = std::io::stdin();
22    let mut out = std::io::stdout();
23    for line in stdin.lock().lines() {
24        let line = line.unwrap_or_default();
25        if line.is_empty() {
26            continue;
27        }
28        if line.starts_with("quit") {
29            break;
30        }
31        let mut parts = line.split_whitespace();
32        let threads: i32 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
33        let op = parts.next().unwrap_or("").to_string();
34        let path = parts.next().unwrap_or("").to_string();
35        if threads < 1 || path.is_empty() {
36            eprintln!("error command");
37            std::process::exit(1);
38        }
39        if let Err(err) = retune(threads) {
40            eprintln!("error {err}");
41            std::process::exit(1);
42        }
43        let sys = frames.entry(path.clone()).or_insert_with(|| {
44            System::new().unwrap_or_else(|err| {
45                eprintln!("error {err}");
46                std::process::exit(1);
47            })
48        });
49        let ready = loaded.get(&path).copied().unwrap_or(false);
50        if op != "read" && !ready {
51            if let Err(err) = sys.read(&path, 1, -1) {
52                eprintln!("error {err}");
53                std::process::exit(1);
54            }
55            loaded.insert(path.clone(), true);
56        }
57        let t0 = Instant::now();
58        let result = match op.as_str() {
59            "read" => sys.read(&path, 1, -1).map(|_| {
60                loaded.insert(path.clone(), true);
61                sink += f64::from(sys.count());
62            }),
63            "knn" => sys
64                .knn(&seams::KnnOptions {
65                    k: 4,
66                    cutoff: 3.5,
67                    mutual: true,
68                    ..seams::KnnOptions::default()
69                })
70                .and_then(|nb| {
71                    sink += nb.nnz()? as f64;
72                    Ok(())
73                }),
74            "steinhardt" => sys
75                .steinhardt(&seams::SteinhardtOptions {
76                    cutoff: 3.5,
77                    order: 6,
78                    average: true,
79                    ..seams::SteinhardtOptions::default()
80                })
81                .map(|q| {
82                    let extra = q.average.as_ref().map(|v| v[0]).unwrap_or(0.0);
83                    sink += q.local[0] + extra;
84                }),
85            "chill" => sys
86                .chill(&seams::ChillOptions {
87                    cutoff: 3.5,
88                    ..seams::ChillOptions::default()
89                })
90                .map(|ice| {
91                    sink += f64::from(ice.counts[1]);
92                }),
93            "rings" => sys
94                .rings(&seams::RingOptions {
95                    cutoff: 3.5,
96                    max_size: 6,
97                    ..seams::RingOptions::default()
98                })
99                .map(|rings| {
100                    sink += f64::from(rings.size());
101                }),
102            _ => {
103                eprintln!("error {op}");
104                std::process::exit(1);
105            }
106        };
107        let ms = t0.elapsed().as_secs_f64() * 1e3;
108        if let Err(err) = result {
109            eprintln!("error {err}");
110            std::process::exit(1);
111        }
112        writeln!(out, "{ms:.9}").ok();
113        out.flush().ok();
114    }
115    eprintln!("sink {sink:.6}");
116}
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);
Examples found in repository?
examples/binding_overhead.rs (lines 86-89)
17fn main() {
18    let mut frames: HashMap<String, System> = HashMap::new();
19    let mut loaded: HashMap<String, bool> = HashMap::new();
20    let mut sink = 0.0_f64;
21    let stdin = std::io::stdin();
22    let mut out = std::io::stdout();
23    for line in stdin.lock().lines() {
24        let line = line.unwrap_or_default();
25        if line.is_empty() {
26            continue;
27        }
28        if line.starts_with("quit") {
29            break;
30        }
31        let mut parts = line.split_whitespace();
32        let threads: i32 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
33        let op = parts.next().unwrap_or("").to_string();
34        let path = parts.next().unwrap_or("").to_string();
35        if threads < 1 || path.is_empty() {
36            eprintln!("error command");
37            std::process::exit(1);
38        }
39        if let Err(err) = retune(threads) {
40            eprintln!("error {err}");
41            std::process::exit(1);
42        }
43        let sys = frames.entry(path.clone()).or_insert_with(|| {
44            System::new().unwrap_or_else(|err| {
45                eprintln!("error {err}");
46                std::process::exit(1);
47            })
48        });
49        let ready = loaded.get(&path).copied().unwrap_or(false);
50        if op != "read" && !ready {
51            if let Err(err) = sys.read(&path, 1, -1) {
52                eprintln!("error {err}");
53                std::process::exit(1);
54            }
55            loaded.insert(path.clone(), true);
56        }
57        let t0 = Instant::now();
58        let result = match op.as_str() {
59            "read" => sys.read(&path, 1, -1).map(|_| {
60                loaded.insert(path.clone(), true);
61                sink += f64::from(sys.count());
62            }),
63            "knn" => sys
64                .knn(&seams::KnnOptions {
65                    k: 4,
66                    cutoff: 3.5,
67                    mutual: true,
68                    ..seams::KnnOptions::default()
69                })
70                .and_then(|nb| {
71                    sink += nb.nnz()? as f64;
72                    Ok(())
73                }),
74            "steinhardt" => sys
75                .steinhardt(&seams::SteinhardtOptions {
76                    cutoff: 3.5,
77                    order: 6,
78                    average: true,
79                    ..seams::SteinhardtOptions::default()
80                })
81                .map(|q| {
82                    let extra = q.average.as_ref().map(|v| v[0]).unwrap_or(0.0);
83                    sink += q.local[0] + extra;
84                }),
85            "chill" => sys
86                .chill(&seams::ChillOptions {
87                    cutoff: 3.5,
88                    ..seams::ChillOptions::default()
89                })
90                .map(|ice| {
91                    sink += f64::from(ice.counts[1]);
92                }),
93            "rings" => sys
94                .rings(&seams::RingOptions {
95                    cutoff: 3.5,
96                    max_size: 6,
97                    ..seams::RingOptions::default()
98                })
99                .map(|rings| {
100                    sink += f64::from(rings.size());
101                }),
102            _ => {
103                eprintln!("error {op}");
104                std::process::exit(1);
105            }
106        };
107        let ms = t0.elapsed().as_secs_f64() * 1e3;
108        if let Err(err) = result {
109            eprintln!("error {err}");
110            std::process::exit(1);
111        }
112        writeln!(out, "{ms:.9}").ok();
113        out.flush().ok();
114    }
115    eprintln!("sink {sink:.6}");
116}
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());
Examples found in repository?
examples/ice.rs (line 33)
28fn main() {
29    let (xyz, length) = diamond(2);
30    let mut sys = seams::System::new().expect("system");
31    sys.set_ortho(&xyz, length, length, length).expect("frame");
32    let ice = sys
33        .chill_plus(&seams::ChillOptions::default())
34        .expect("chill+");
35    println!(
36        "dseams {} cubic {} of {}",
37        seams::version(),
38        ice.counts[0],
39        ice.labels.len()
40    );
41}
More examples
Hide additional examples
examples/lang_tasks.rs (line 35)
25fn census(path: &str) -> Result<String, Error> {
26    let mut frame = System::new()?;
27    frame.read(path, 1, -1)?;
28    let pairs = frame.neighbours(&NeighbourOptions::default())?.nnz()?;
29    let rings = frame
30        .rings(&RingOptions {
31            max_size: 6,
32            ..RingOptions::default()
33        })?
34        .histogram(6)?;
35    let chill = frame.chill_plus(&ChillOptions::default())?;
36    Ok(format!(
37        "pairs {pairs} rings {} chill {}",
38        joined(&rings),
39        joined(&chill.counts)
40    ))
41}
examples/ice_ih.rs (line 17)
11fn census(path: &str) -> String {
12    let mut system = System::new().expect("system");
13    system.read(path, 1, 1).expect("read");
14    let n = system.count();
15    let order = system.q4q6(3.5).expect("q6");
16    let mean = order.q6.iter().sum::<f64>() / order.q6.len() as f64;
17    let ice = system.chill_plus(&ChillOptions::default()).expect("chill+");
18    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
19    format!(
20        "rust ice nop {} q6 {:.6} hexagonal {} rings {}",
21        n,
22        mean,
23        ice.counts[Label::Hexagonal as usize],
24        six
25    )
26}
examples/minimal.rs (line 86)
71fn run(path: &str) -> String {
72    let (xyz, edges) = read_dump(path);
73    assert_eq!(xyz.len() / 3, 46);
74    set_num_threads(1).expect("threads");
75    assert_eq!(num_threads(), 1);
76    let mut system = System::new().expect("system");
77    system
78        .set_ortho(&xyz, edges[0], edges[1], edges[2])
79        .expect("frame");
80    assert_eq!(system.count(), 46);
81    let degree = system.neighbour_degree(3.5).expect("neighbours");
82    assert_eq!(degree.len(), 46);
83    let orders = system.q4q6(3.5).expect("q6");
84    let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
85    let ice = system
86        .chill_plus(&seams::ChillOptions::default())
87        .expect("chill+");
88    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
89    assert_eq!(ice.counts[4], 46);
90    assert_eq!(six, 54);
91    assert!(mean > 0.5);
92    format!("rust example ok {} q6 {:.3}", version(), mean)
93}
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);
Examples found in repository?
examples/binding_overhead.rs (lines 75-80)
17fn main() {
18    let mut frames: HashMap<String, System> = HashMap::new();
19    let mut loaded: HashMap<String, bool> = HashMap::new();
20    let mut sink = 0.0_f64;
21    let stdin = std::io::stdin();
22    let mut out = std::io::stdout();
23    for line in stdin.lock().lines() {
24        let line = line.unwrap_or_default();
25        if line.is_empty() {
26            continue;
27        }
28        if line.starts_with("quit") {
29            break;
30        }
31        let mut parts = line.split_whitespace();
32        let threads: i32 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
33        let op = parts.next().unwrap_or("").to_string();
34        let path = parts.next().unwrap_or("").to_string();
35        if threads < 1 || path.is_empty() {
36            eprintln!("error command");
37            std::process::exit(1);
38        }
39        if let Err(err) = retune(threads) {
40            eprintln!("error {err}");
41            std::process::exit(1);
42        }
43        let sys = frames.entry(path.clone()).or_insert_with(|| {
44            System::new().unwrap_or_else(|err| {
45                eprintln!("error {err}");
46                std::process::exit(1);
47            })
48        });
49        let ready = loaded.get(&path).copied().unwrap_or(false);
50        if op != "read" && !ready {
51            if let Err(err) = sys.read(&path, 1, -1) {
52                eprintln!("error {err}");
53                std::process::exit(1);
54            }
55            loaded.insert(path.clone(), true);
56        }
57        let t0 = Instant::now();
58        let result = match op.as_str() {
59            "read" => sys.read(&path, 1, -1).map(|_| {
60                loaded.insert(path.clone(), true);
61                sink += f64::from(sys.count());
62            }),
63            "knn" => sys
64                .knn(&seams::KnnOptions {
65                    k: 4,
66                    cutoff: 3.5,
67                    mutual: true,
68                    ..seams::KnnOptions::default()
69                })
70                .and_then(|nb| {
71                    sink += nb.nnz()? as f64;
72                    Ok(())
73                }),
74            "steinhardt" => sys
75                .steinhardt(&seams::SteinhardtOptions {
76                    cutoff: 3.5,
77                    order: 6,
78                    average: true,
79                    ..seams::SteinhardtOptions::default()
80                })
81                .map(|q| {
82                    let extra = q.average.as_ref().map(|v| v[0]).unwrap_or(0.0);
83                    sink += q.local[0] + extra;
84                }),
85            "chill" => sys
86                .chill(&seams::ChillOptions {
87                    cutoff: 3.5,
88                    ..seams::ChillOptions::default()
89                })
90                .map(|ice| {
91                    sink += f64::from(ice.counts[1]);
92                }),
93            "rings" => sys
94                .rings(&seams::RingOptions {
95                    cutoff: 3.5,
96                    max_size: 6,
97                    ..seams::RingOptions::default()
98                })
99                .map(|rings| {
100                    sink += f64::from(rings.size());
101                }),
102            _ => {
103                eprintln!("error {op}");
104                std::process::exit(1);
105            }
106        };
107        let ms = t0.elapsed().as_secs_f64() * 1e3;
108        if let Err(err) = result {
109            eprintln!("error {err}");
110            std::process::exit(1);
111        }
112        writeln!(out, "{ms:.9}").ok();
113        out.flush().ok();
114    }
115    eprintln!("sink {sink:.6}");
116}
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);
Examples found in repository?
examples/ice_ih.rs (line 15)
11fn census(path: &str) -> String {
12    let mut system = System::new().expect("system");
13    system.read(path, 1, 1).expect("read");
14    let n = system.count();
15    let order = system.q4q6(3.5).expect("q6");
16    let mean = order.q6.iter().sum::<f64>() / order.q6.len() as f64;
17    let ice = system.chill_plus(&ChillOptions::default()).expect("chill+");
18    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
19    format!(
20        "rust ice nop {} q6 {:.6} hexagonal {} rings {}",
21        n,
22        mean,
23        ice.counts[Label::Hexagonal as usize],
24        six
25    )
26}
More examples
Hide additional examples
examples/minimal.rs (line 83)
71fn run(path: &str) -> String {
72    let (xyz, edges) = read_dump(path);
73    assert_eq!(xyz.len() / 3, 46);
74    set_num_threads(1).expect("threads");
75    assert_eq!(num_threads(), 1);
76    let mut system = System::new().expect("system");
77    system
78        .set_ortho(&xyz, edges[0], edges[1], edges[2])
79        .expect("frame");
80    assert_eq!(system.count(), 46);
81    let degree = system.neighbour_degree(3.5).expect("neighbours");
82    assert_eq!(degree.len(), 46);
83    let orders = system.q4q6(3.5).expect("q6");
84    let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
85    let ice = system
86        .chill_plus(&seams::ChillOptions::default())
87        .expect("chill+");
88    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
89    assert_eq!(ice.counts[4], 46);
90    assert_eq!(six, 54);
91    assert!(mean > 0.5);
92    format!("rust example ok {} q6 {:.3}", version(), mean)
93}
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 voronoi( &mut self, seed_radius: Option<f64>, ) -> Result<VoronoiCells, Error>

Tessellate the selected sites of a fully periodic frame.

Pass None to choose a search radius from the site density or supply an initial radius in angstroms. The result owns its geometry.

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);
Examples found in repository?
examples/lang_tasks.rs (line 28)
25fn census(path: &str) -> Result<String, Error> {
26    let mut frame = System::new()?;
27    frame.read(path, 1, -1)?;
28    let pairs = frame.neighbours(&NeighbourOptions::default())?.nnz()?;
29    let rings = frame
30        .rings(&RingOptions {
31            max_size: 6,
32            ..RingOptions::default()
33        })?
34        .histogram(6)?;
35    let chill = frame.chill_plus(&ChillOptions::default())?;
36    Ok(format!(
37        "pairs {pairs} rings {} chill {}",
38        joined(&rings),
39        joined(&chill.counts)
40    ))
41}
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);
Examples found in repository?
examples/binding_overhead.rs (lines 64-69)
17fn main() {
18    let mut frames: HashMap<String, System> = HashMap::new();
19    let mut loaded: HashMap<String, bool> = HashMap::new();
20    let mut sink = 0.0_f64;
21    let stdin = std::io::stdin();
22    let mut out = std::io::stdout();
23    for line in stdin.lock().lines() {
24        let line = line.unwrap_or_default();
25        if line.is_empty() {
26            continue;
27        }
28        if line.starts_with("quit") {
29            break;
30        }
31        let mut parts = line.split_whitespace();
32        let threads: i32 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
33        let op = parts.next().unwrap_or("").to_string();
34        let path = parts.next().unwrap_or("").to_string();
35        if threads < 1 || path.is_empty() {
36            eprintln!("error command");
37            std::process::exit(1);
38        }
39        if let Err(err) = retune(threads) {
40            eprintln!("error {err}");
41            std::process::exit(1);
42        }
43        let sys = frames.entry(path.clone()).or_insert_with(|| {
44            System::new().unwrap_or_else(|err| {
45                eprintln!("error {err}");
46                std::process::exit(1);
47            })
48        });
49        let ready = loaded.get(&path).copied().unwrap_or(false);
50        if op != "read" && !ready {
51            if let Err(err) = sys.read(&path, 1, -1) {
52                eprintln!("error {err}");
53                std::process::exit(1);
54            }
55            loaded.insert(path.clone(), true);
56        }
57        let t0 = Instant::now();
58        let result = match op.as_str() {
59            "read" => sys.read(&path, 1, -1).map(|_| {
60                loaded.insert(path.clone(), true);
61                sink += f64::from(sys.count());
62            }),
63            "knn" => sys
64                .knn(&seams::KnnOptions {
65                    k: 4,
66                    cutoff: 3.5,
67                    mutual: true,
68                    ..seams::KnnOptions::default()
69                })
70                .and_then(|nb| {
71                    sink += nb.nnz()? as f64;
72                    Ok(())
73                }),
74            "steinhardt" => sys
75                .steinhardt(&seams::SteinhardtOptions {
76                    cutoff: 3.5,
77                    order: 6,
78                    average: true,
79                    ..seams::SteinhardtOptions::default()
80                })
81                .map(|q| {
82                    let extra = q.average.as_ref().map(|v| v[0]).unwrap_or(0.0);
83                    sink += q.local[0] + extra;
84                }),
85            "chill" => sys
86                .chill(&seams::ChillOptions {
87                    cutoff: 3.5,
88                    ..seams::ChillOptions::default()
89                })
90                .map(|ice| {
91                    sink += f64::from(ice.counts[1]);
92                }),
93            "rings" => sys
94                .rings(&seams::RingOptions {
95                    cutoff: 3.5,
96                    max_size: 6,
97                    ..seams::RingOptions::default()
98                })
99                .map(|rings| {
100                    sink += f64::from(rings.size());
101                }),
102            _ => {
103                eprintln!("error {op}");
104                std::process::exit(1);
105            }
106        };
107        let ms = t0.elapsed().as_secs_f64() * 1e3;
108        if let Err(err) = result {
109            eprintln!("error {err}");
110            std::process::exit(1);
111        }
112        writeln!(out, "{ms:.9}").ok();
113        out.flush().ok();
114    }
115    eprintln!("sink {sink:.6}");
116}
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));
Examples found in repository?
examples/minimal.rs (line 81)
71fn run(path: &str) -> String {
72    let (xyz, edges) = read_dump(path);
73    assert_eq!(xyz.len() / 3, 46);
74    set_num_threads(1).expect("threads");
75    assert_eq!(num_threads(), 1);
76    let mut system = System::new().expect("system");
77    system
78        .set_ortho(&xyz, edges[0], edges[1], edges[2])
79        .expect("frame");
80    assert_eq!(system.count(), 46);
81    let degree = system.neighbour_degree(3.5).expect("neighbours");
82    assert_eq!(degree.len(), 46);
83    let orders = system.q4q6(3.5).expect("q6");
84    let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
85    let ice = system
86        .chill_plus(&seams::ChillOptions::default())
87        .expect("chill+");
88    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
89    assert_eq!(ice.counts[4], 46);
90    assert_eq!(six, 54);
91    assert!(mean > 0.5);
92    format!("rust example ok {} q6 {:.3}", version(), mean)
93}
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());
Examples found in repository?
examples/lang_tasks.rs (lines 30-33)
25fn census(path: &str) -> Result<String, Error> {
26    let mut frame = System::new()?;
27    frame.read(path, 1, -1)?;
28    let pairs = frame.neighbours(&NeighbourOptions::default())?.nnz()?;
29    let rings = frame
30        .rings(&RingOptions {
31            max_size: 6,
32            ..RingOptions::default()
33        })?
34        .histogram(6)?;
35    let chill = frame.chill_plus(&ChillOptions::default())?;
36    Ok(format!(
37        "pairs {pairs} rings {} chill {}",
38        joined(&rings),
39        joined(&chill.counts)
40    ))
41}
More examples
Hide additional examples
examples/binding_overhead.rs (lines 94-98)
17fn main() {
18    let mut frames: HashMap<String, System> = HashMap::new();
19    let mut loaded: HashMap<String, bool> = HashMap::new();
20    let mut sink = 0.0_f64;
21    let stdin = std::io::stdin();
22    let mut out = std::io::stdout();
23    for line in stdin.lock().lines() {
24        let line = line.unwrap_or_default();
25        if line.is_empty() {
26            continue;
27        }
28        if line.starts_with("quit") {
29            break;
30        }
31        let mut parts = line.split_whitespace();
32        let threads: i32 = parts.next().and_then(|s| s.parse().ok()).unwrap_or(0);
33        let op = parts.next().unwrap_or("").to_string();
34        let path = parts.next().unwrap_or("").to_string();
35        if threads < 1 || path.is_empty() {
36            eprintln!("error command");
37            std::process::exit(1);
38        }
39        if let Err(err) = retune(threads) {
40            eprintln!("error {err}");
41            std::process::exit(1);
42        }
43        let sys = frames.entry(path.clone()).or_insert_with(|| {
44            System::new().unwrap_or_else(|err| {
45                eprintln!("error {err}");
46                std::process::exit(1);
47            })
48        });
49        let ready = loaded.get(&path).copied().unwrap_or(false);
50        if op != "read" && !ready {
51            if let Err(err) = sys.read(&path, 1, -1) {
52                eprintln!("error {err}");
53                std::process::exit(1);
54            }
55            loaded.insert(path.clone(), true);
56        }
57        let t0 = Instant::now();
58        let result = match op.as_str() {
59            "read" => sys.read(&path, 1, -1).map(|_| {
60                loaded.insert(path.clone(), true);
61                sink += f64::from(sys.count());
62            }),
63            "knn" => sys
64                .knn(&seams::KnnOptions {
65                    k: 4,
66                    cutoff: 3.5,
67                    mutual: true,
68                    ..seams::KnnOptions::default()
69                })
70                .and_then(|nb| {
71                    sink += nb.nnz()? as f64;
72                    Ok(())
73                }),
74            "steinhardt" => sys
75                .steinhardt(&seams::SteinhardtOptions {
76                    cutoff: 3.5,
77                    order: 6,
78                    average: true,
79                    ..seams::SteinhardtOptions::default()
80                })
81                .map(|q| {
82                    let extra = q.average.as_ref().map(|v| v[0]).unwrap_or(0.0);
83                    sink += q.local[0] + extra;
84                }),
85            "chill" => sys
86                .chill(&seams::ChillOptions {
87                    cutoff: 3.5,
88                    ..seams::ChillOptions::default()
89                })
90                .map(|ice| {
91                    sink += f64::from(ice.counts[1]);
92                }),
93            "rings" => sys
94                .rings(&seams::RingOptions {
95                    cutoff: 3.5,
96                    max_size: 6,
97                    ..seams::RingOptions::default()
98                })
99                .map(|rings| {
100                    sink += f64::from(rings.size());
101                }),
102            _ => {
103                eprintln!("error {op}");
104                std::process::exit(1);
105            }
106        };
107        let ms = t0.elapsed().as_secs_f64() * 1e3;
108        if let Err(err) = result {
109            eprintln!("error {err}");
110            std::process::exit(1);
111        }
112        writeln!(out, "{ms:.9}").ok();
113        out.flush().ok();
114    }
115    eprintln!("sink {sink:.6}");
116}
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());
Examples found in repository?
examples/ice_ih.rs (line 18)
11fn census(path: &str) -> String {
12    let mut system = System::new().expect("system");
13    system.read(path, 1, 1).expect("read");
14    let n = system.count();
15    let order = system.q4q6(3.5).expect("q6");
16    let mean = order.q6.iter().sum::<f64>() / order.q6.len() as f64;
17    let ice = system.chill_plus(&ChillOptions::default()).expect("chill+");
18    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
19    format!(
20        "rust ice nop {} q6 {:.6} hexagonal {} rings {}",
21        n,
22        mean,
23        ice.counts[Label::Hexagonal as usize],
24        six
25    )
26}
More examples
Hide additional examples
examples/minimal.rs (line 88)
71fn run(path: &str) -> String {
72    let (xyz, edges) = read_dump(path);
73    assert_eq!(xyz.len() / 3, 46);
74    set_num_threads(1).expect("threads");
75    assert_eq!(num_threads(), 1);
76    let mut system = System::new().expect("system");
77    system
78        .set_ortho(&xyz, edges[0], edges[1], edges[2])
79        .expect("frame");
80    assert_eq!(system.count(), 46);
81    let degree = system.neighbour_degree(3.5).expect("neighbours");
82    assert_eq!(degree.len(), 46);
83    let orders = system.q4q6(3.5).expect("q6");
84    let mean = orders.q6.iter().sum::<f64>() / orders.q6.len() as f64;
85    let ice = system
86        .chill_plus(&seams::ChillOptions::default())
87        .expect("chill+");
88    let (six, _fraction) = system.six_ring_fraction(3.5).expect("rings");
89    assert_eq!(ice.counts[4], 46);
90    assert_eq!(six, 54);
91    assert!(mean > 0.5);
92    format!("rust example ok {} q6 {:.3}", version(), mean)
93}
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 directed_hbonds( &mut self, donor_types: &[i32], acceptor_types: &[i32], options: &DirectedBondOptions, ) -> Result<Vec<DirectedHbond>, Error>

Enumerate directed donor–hydrogen–acceptor bonds in the current frame.

Hydrogen assignment uses the molecule IDs from the trajectory. Donor and acceptor type sets may differ, for example to select water donors and framework acceptors. Indices are zero-based positions in the frame; keep the same atom order and selection when tracking pairs over time.

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.