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);Examples found in repository?
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
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}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}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}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}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);Examples found in repository?
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
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}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());Examples found in repository?
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
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}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}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);Examples found in repository?
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
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}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}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);Examples found in repository?
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}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());Examples found in repository?
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
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}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}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}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);Examples found in repository?
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}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);Examples found in repository?
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
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}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);Examples found in repository?
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}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);Examples found in repository?
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}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));Examples found in repository?
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}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());Examples found in repository?
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
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}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());Examples found in repository?
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
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}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()?;