Skip to main content

uff_relax/atom/
mod.rs

1use glam::DVec3;
2use serde::{Deserialize, Serialize};
3
4/// Represents an atom type label in UFF (e.g., "C_3", "N_R").
5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
6pub struct UffAtomType(pub String);
7
8impl UffAtomType {
9    pub fn as_str(&self) -> &str {
10        &self.0
11    }
12    pub fn unknown() -> Self {
13        Self("Unknown".to_string())
14    }
15}
16
17/// Represents an individual atom in the system.
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct Atom {
20    /// Atomic number (e.g., 1 for H, 6 for C).
21    pub element: usize,
22    /// Position in Cartesian coordinates (Å).
23    pub position: DVec3,
24    /// Current force acting on the atom (kcal/mol/Å).
25    pub force: DVec3,
26    /// Internal UFF atom type label (assigned automatically).
27    pub uff_type: UffAtomType,
28}
29
30impl Atom {
31    /// Creates a new atom with the given atomic number and position.
32    pub fn new(element: usize, position: DVec3) -> Self {
33        Self {
34            element,
35            position,
36            force: DVec3::ZERO,
37            uff_type: UffAtomType::unknown(),
38        }
39    }
40}
41
42/// Represents a chemical bond between two atoms.
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct Bond {
45    /// Indices of the two atoms in the `System::atoms` vector.
46    pub atom_indices: (usize, usize),
47    /// Bond order (1.0 for single, 1.5 for aromatic, 2.0 for double).
48    pub order: f32,
49}