Skip to main content

ice_ih/
ice_ih.rs

1// Copyright (c) d-SEAMS developers
2//! Ice Ih census through the safe seams crate.
3//!
4//! `cargo run --example ice_ih [dump]` reads `tests/data/ice1h.lammpstrj`
5//! when no path is given.
6use seams::{ChillOptions, Label, System};
7use std::env;
8
9const FIXTURE: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/data/ice1h.lammpstrj");
10
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}
27
28fn main() {
29    let path = env::args().nth(1).unwrap_or_else(|| FIXTURE.to_string());
30    println!("{}", census(&path));
31}
32
33#[test]
34fn ice_ih_census() {
35    assert_eq!(
36        census(FIXTURE),
37        "rust ice nop 128 q6 0.625855 hexagonal 128 rings 256"
38    );
39}