castep_param_io/param/units/
force_unit.rs

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