use crate::elements::element_by_symbol;
use crate::{Error, Structure};
pub fn bond_lengths(structure: &Structure) -> Result<Vec<f64>, Error> {
Ok(structure
.bond_graph()?
.bonds
.iter()
.map(|bond| bond.distance)
.collect())
}
pub fn coordination_numbers(structure: &Structure) -> Result<Vec<usize>, Error> {
let graph = structure.bond_graph()?;
Ok((0..graph.n_atoms())
.map(|index| graph.degree(index))
.collect())
}
#[must_use]
pub fn atom_charges(structure: &Structure) -> Vec<Option<f64>> {
structure.sites().iter().map(|site| site.charge()).collect()
}
pub fn atom_masses(structure: &Structure) -> Result<Vec<f64>, Error> {
structure
.sites()
.iter()
.map(|site| Ok(element_by_symbol(site.element())?.mass))
.collect()
}