castep_param_io/param/units/
pressure_unit.rs

1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5use crate::param::KeywordDisplay;
6
7#[derive(Debug, Clone, Copy, Serialize, Deserialize, Hash, PartialEq, Eq, PartialOrd, Ord)]
8/// This keyword specifies the units in which pressure will be reported.
9/// # Example
10/// `PRESSURE_UNIT : atm`
11pub enum PressureUnit {
12    HartreePerBohr3,
13    ElectronVoltsPerAng3,
14    Pascal,
15    Megapascal,
16    Gigapascal,
17    Atmosphere,
18    Bar,
19    Megabar,
20}
21
22impl Display for PressureUnit {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        match self {
25            PressureUnit::HartreePerBohr3 => f.write_str("hartree/bohr**3"),
26            PressureUnit::ElectronVoltsPerAng3 => f.write_str("ev/ang**3"),
27            PressureUnit::Pascal => f.write_str("pa"),
28            PressureUnit::Megapascal => f.write_str("mpa"),
29            PressureUnit::Gigapascal => f.write_str("gpa"),
30            PressureUnit::Atmosphere => f.write_str("atm"),
31            PressureUnit::Bar => f.write_str("bar"),
32            PressureUnit::Megabar => f.write_str("mbar"),
33        }
34    }
35}
36
37impl KeywordDisplay for PressureUnit {
38    fn field(&self) -> String {
39        "PRESSURE_UNIT".to_string()
40    }
41}