pub fn to_poscar(
        &self,
        cc_bond: Option<f64>,
        ch_bond: Option<f64>,
        vacuum_sep: Option<f64>,
    ) -> Poscar {
        use std::iter::once;
        use vasp_poscar::{Builder, Coords};

        let cc_bond = cc_bond.unwrap_or(1.42045);
        let ch_bond = ch_bond.unwrap_or(1.09047);
        let vacuum_sep = vacuum_sep.unwrap_or(15.0);

        // horizontal distance between each hexagonal "segment" of the GNR
        let dx = 1.5 * cc_bond;
        // vertical distance between each carbon atom in the GNR
        let dy = (f64::sqrt(3.0) * cc_bond) / 2.0;

        let spec = &self.spec;
        // compute the coordinates of all of the carbon atoms
        let coords = spec
            .iter()
            .enumerate()
            .flat_map(|(i, s)| {
                let x = i as f64 * dx;
                (s.0..s.1).step_by(2).flat_map(move |j| {
                    let y = j as f64 * dy;
                    let atom_1 = [x, y];
                    let atom_2 = [x + cc_bond, y];
                    Iterator::chain(once(atom_1), once(atom_2))
                })
            })
            .map(|[x, y]| {
                // adjust x/y and add z coord to center the structure nicely in the periodic cell
                [x - cc_bond / 2.0, y + vacuum_sep / 2.0, vacuum_sep / 2.0]
            })
            .collect_vec();

        let gnr_width = (self.width().unwrap() - 2) as f64 * dy;

        // build a Poscar from just the carbon atoms
        let poscar = Builder::new()
            .group_counts(vec![coords.len()])
            .group_symbols(vec!["C"])
            .lattice_vectors(&[
                [dx * self.len() as f64, 0.0, 0.0],
                [0.0, gnr_width + vacuum_sep, 0.0],
                [0.0, 0.0, vacuum_sep],
            ])
            .positions(Coords::Cart(coords))
            .build()
            .unwrap();

        // add hydrogen and that's it
        let cutoff_distance = cc_bond * 1.1;
        add_hydrogen(poscar, ch_bond, cutoff_distance)
    }
/// Build a Poscar from an AGNR
Build a Poscar from an AGNR
Build a Poscar from an AGNR
pub fn to_poscar(
        &self,
        cc_bond: Option<f64>,
        ch_bond: Option<f64>,
        vacuum_sep: Option<f64>,
    ) -> Poscar {
        use std::iter::once;
        use vasp_poscar::{Builder, Coords};
        let cc_bond = cc_bond.unwrap_or(1.42045);
        let ch_bond = ch_bond.unwrap_or(1.09047);
        let vacuum_sep = vacuum_sep.unwrap_or(15.0);
        // horizontal distance between each hexagonal "segment" of the GNR
        let dx = 1.5 * cc_bond;
        // vertical distance between each carbon atom in the GNR
        let dy = (f64::sqrt(3.0) * cc_bond) / 2.0;
        let spec = &self.spec;
        // compute the coordinates of all of the carbon atoms
        let coords = spec
            .iter()
            .enumerate()
            .flat_map(|(i, s)| {
                let x = i as f64 * dx;
                (s.0..s.1).step_by(2).flat_map(move |j| {
                    let y = j as f64 * dy;
                    let atom_1 = [x, y];
                    let atom_2 = [x + cc_bond, y];
                    Iterator::chain(once(atom_1), once(atom_2))
                })
            })
            .map(|[x, y]| {
                // adjust x/y and add z coord to center the structure nicely in the periodic cell
                [x - cc_bond / 2.0, y + vacuum_sep / 2.0, vacuum_sep / 2.0]
            })
            .collect_vec();
        let gnr_width = (self.width().unwrap() - 2) as f64 * dy;
        // build a Poscar from just the carbon atoms
        let poscar = Builder::new()
            .group_counts(vec![coords.len()])
            .group_symbols(vec!["C"])
            .lattice_vectors(&[
                [dx * self.len() as f64, 0.0, 0.0],
                [0.0, gnr_width + vacuum_sep, 0.0],
                [0.0, 0.0, vacuum_sep],
            ])
            .positions(Coords::Cart(coords))
            .build()
            .unwrap();
        // add hydrogen and that's it
        let cutoff_distance = cc_bond * 1.1;
        add_hydrogen(poscar, ch_bond, cutoff_distance)
    }
pub fn to_poscar ( & self , cc_bond : Option < f64 > , ch_bond : Option < f64 > , vacuum_sep : Option < f64 > , ) -> Poscar { use std :: iter :: once ; use vasp_poscar :: { Builder , Coords } ; let cc_bond = cc_bond . unwrap_or ( 1.42045 ) ; let ch_bond = ch_bond . unwrap_or ( 1.09047 ) ; let vacuum_sep = vacuum_sep . unwrap_or ( 15.0 ) ; // horizontal distance between each hexagonal "segment" of the GNR let dx = 1.5 * cc_bond ; // vertical distance between each carbon atom in the GNR let dy = ( f64 :: sqrt ( 3.0 ) * cc_bond ) / 2.0 ; let spec = & self . spec ; // compute the coordinates of all of the carbon atoms let coords = spec . iter ( ) . enumerate ( ) . flat_map ( | ( i , s ) | { let x = i as f64 * dx ; ( s . 0 .. s . 1 ) . step_by ( 2 ) . flat_map ( move | j | { let y = j as f64 * dy ; let atom_1 = [ x , y ] ; let atom_2 = [ x + cc_bond , y ] ; Iterator :: chain ( once ( atom_1 ) , once ( atom_2 ) ) } ) } ) . map ( | [ x , y ] | { // adjust x/y and add z coord to center the structure nicely in the periodic cell [ x - cc_bond / 2.0 , y + vacuum_sep / 2.0 , vacuum_sep / 2.0 ] } ) . collect_vec ( ) ; let gnr_width = ( self . width ( ) . unwrap ( ) - 2 ) as f64 * dy ; // build a Poscar from just the carbon atoms let poscar = Builder :: new ( ) . group_counts ( vec ! [ coords len ( ) ] ) . group_symbols ( vec ! [ " " ] ) . lattice_vectors ( & [ [ dx * self . len ( ) as f64 , 0.0 , 0.0 ] , [ 0.0 , gnr_width + vacuum_sep , 0.0 ] , [ 0.0 , 0.0 , vacuum_sep ] , ] ) . positions ( Coords :: Cart ( coords ) ) . build ( ) . unwrap ( ) ; // add hydrogen and that's it let cutoff_distance = cc_bond * 1.1 ; add_hydrogen ( poscar , ch_bond , cutoff_distance ) }
Build a Poscar from an AGNR
Build a Poscar from an AGNR
&self
cc_bond
Option<f64>
ch_bond
Option<f64>
vacuum_sep
Option<f64>
&self
cc_bond
Option<f64>
ch_bond
Option<f64>
vacuum_sep
Option<f64>