castep_param_io/param/density_mixing_params/
mix_metric_q.rs

1use castep_param_derive::KeywordDisplayStruct;
2use derive_builder::Builder;
3use serde::{Deserialize, Serialize};
4
5use crate::param::InvLengthUnit;
6
7#[derive(
8    Debug, Clone, Copy, PartialEq, PartialOrd, Serialize, Deserialize, KeywordDisplayStruct, Builder,
9)]
10#[keyword_display(field = "MIX_METRIC_Q", display_format = "{} {}", from=f64, default_value=-1.0)]
11/// This keyword determines the weighting factor for the densities used in
12/// the density mixing scheme.
13/// CASTEP uses a weighting factor when evaluating scalar products of densities.
14/// The factor depends on the wave vector q, according to:
15/// `f(q) = (q2 + q12)/q2`
16/// where q1 is the value of the MIX_METRIC_Q parameter.
17/// CASTEP sets the value of q1 automatically if MIX_METRIC_Q is not specified.
18/// # Default
19/// -1 - CASTEP will automatically select the appropriate value
20/// # Example
21/// `MIX_METRIC_Q : 20.0 1/ang`
22pub struct MixMetricQ {
23    pub q: f64,
24    #[keyword_display(is_option = true)]
25    pub unit: Option<InvLengthUnit>,
26}
27
28#[cfg(test)]
29mod test {
30    use crate::param::KeywordDisplay;
31
32    use super::MixMetricQ;
33
34    #[test]
35    fn mix_metric_q() {
36        let q = MixMetricQ::default();
37        println!("{}", q.output());
38        let q = MixMetricQ::from(20.0);
39        println!("{}", q.output());
40    }
41}