// the 'pair_coeff' in the name is meant to emphasize that this
// takes care of issues like ensuring I < J.
the 'pair_coeff' in the name is meant to emphasize that this
takes care of issues like ensuring I < J.
the ' pair_coeff ' in the name is meant to emphasize that this takes care of issues like ensuring I < J .
fn determine_pair_coeff_pairs(gaps: &[GapKind]) -> FailResult<Vec<(AtomType, AtomType)>>
    {Ok({
        let pairs: Vec<(AtomType, AtomType)> = match gaps.len() {
            0 => {
                // NOTE: This code path is probably unreachable due to these
                //       cases already being handled earlier.
                warn_once!(
                    "kolmogorov/crespi/z was used on a structure with no distinct layers. \
                    It will have no effect!"
                );
                vec![]
            },
            1 => match gaps[0] {
                // A single layer, vacuum-separated from its images.
                GapKind::Vacuum => vec![],
                // A single layer, close enough to its images to interact with them.
                GapKind::Interacting => {
                    bail!("kolmogorov/crespi/z cannot be used (or rather, has not yet \
                        been tested) on a layer that interacts with images of itself. \
                        Please take a supercell.")
                },
            },
            _ => {
                gaps.iter()
                    .enumerate()
                    .filter_map(|(i, &gap)| match gap {
                        GapKind::Interacting => {
                            let this = AtomType::from_index(i);
                            let next = AtomType::from_index((i + 1) % gaps.len());
                            Some((this, next))
                        },
                        GapKind::Vacuum => None,
                    })
                    .collect()
            },
        };
        // Canonicalize the entries, because:
        // - 'pair_coeff I J' is ignored by lammps if I > J
        let mut pairs: Vec<_> = pairs.into_iter()
            .map(|(a, b)| (a.min(b), a.max(b)))
            .collect();
        // - there might be duplicates (e.g. for two layers)
        pairs.sort();
        pairs.dedup();
        pairs
    })}
fn determine_pair_coeff_pairs ( gaps : & [ GapKind ] ) -> FailResult < Vec < ( AtomType , AtomType ) > > { Ok ( { let pairs : Vec < ( AtomType , AtomType ) > = match gaps . len ( ) { 0 => { // NOTE: This code path is probably unreachable due to these //       cases already being handled earlier. warn_once ! ( " \
 " ) ; vec ! [ ] } , 1 => match gaps [ 0 ] { // A single layer, vacuum-separated from its images. GapKind :: Vacuum => vec ! [ ] , // A single layer, close enough to its images to interact with them. GapKind :: Interacting => { bail ! ( " \
 \
 " ) } , } , _ => { gaps . iter ( ) . enumerate ( ) . filter_map ( | ( i , & gap ) | match gap { GapKind :: Interacting => { let this = AtomType :: from_index ( i ) ; let next = AtomType :: from_index ( ( i + 1 ) % gaps . len ( ) ) ; Some ( ( this , next ) ) } , GapKind :: Vacuum => None , } ) . collect ( ) } , } ; // Canonicalize the entries, because: // - 'pair_coeff I J' is ignored by lammps if I > J let mut pairs : Vec < _ > = pairs . into_iter ( ) . map ( | ( a , b ) | ( a . min ( b ) , a . max ( b ) ) ) . collect ( ) ; // - there might be duplicates (e.g. for two layers) pairs . sort ( ) ; pairs . dedup ( ) ; pairs } ) }
the 'pair_coeff' in the name is meant to emphasize that this
takes care of issues like ensuring I < J.
the ' pair_coeff ' in the name is meant to emphasize that this takes care of issues like ensuring I < J .
gaps
&[GapKind]