use std::fmt;
mod crystal;
mod element;
mod lattice;
mod parse;
#[cfg(feature = "spacegroup")]
mod spacegroup;
pub use crystal::{Cluster, ClusterAtom, Crystal, Potential, Site};
pub use element::{symbol_to_z, z_to_symbol};
pub use lattice::Lattice;
pub use parse::{FeffAtom, FeffInp};
#[cfg(feature = "spacegroup")]
pub use spacegroup::expand_sites;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Edge {
#[default]
K,
L1,
L2,
L3,
}
impl Edge {
pub fn as_str(self) -> &'static str {
match self {
Edge::K => "K",
Edge::L1 => "L1",
Edge::L2 => "L2",
Edge::L3 => "L3",
}
}
pub fn from_str_ci(s: &str) -> Option<Edge> {
match s.trim().to_ascii_uppercase().as_str() {
"K" => Some(Edge::K),
"L1" => Some(Edge::L1),
"L2" => Some(Edge::L2),
"L3" => Some(Edge::L3),
_ => None,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum Error {
AbsorberIndex(usize),
BadClusterSize(f64),
UnknownElement(String),
Parse(String),
SpaceGroup(u32),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::AbsorberIndex(i) => write!(f, "absorber index {i} is out of range"),
Error::BadClusterSize(r) => write!(f, "cluster size must be > 0 (got {r})"),
Error::UnknownElement(s) => write!(f, "unknown element symbol `{s}`"),
Error::Parse(m) => write!(f, "feff.inp parse error: {m}"),
Error::SpaceGroup(n) => write!(f, "space-group number {n} is out of range 1..=230"),
}
}
}
impl std::error::Error for Error {}