castep_param_io/param/units/
force_constant_unit.rs

1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5use crate::param::KeywordDisplay;
6
7#[derive(
8    Debug, Clone, Copy, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Default,
9)]
10/// This keyword specifies the units in which force constants will be reported.
11/// # Example
12/// `FORCE_CONSTANT_UNIT : n/m`
13pub enum ForceConstantUnit {
14    HartreePerBohr2,
15    #[default]
16    ElectronVoltsPerAng2,
17    NewtonPerMeter,
18    DynesPerCentimeter,
19}
20
21impl Display for ForceConstantUnit {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        match self {
24            ForceConstantUnit::HartreePerBohr2 => f.write_str("hartree/bohr**2"),
25            ForceConstantUnit::ElectronVoltsPerAng2 => f.write_str("ev/ang**2"),
26            ForceConstantUnit::NewtonPerMeter => f.write_str("n/m"),
27            ForceConstantUnit::DynesPerCentimeter => f.write_str("dyne/cm"),
28        }
29    }
30}
31
32impl KeywordDisplay for ForceConstantUnit {
33    fn field(&self) -> String {
34        "FORCE_CONSTANT_UNIT".to_string()
35    }
36}