castep_param_io/param/electro_min/
max_sd_steps.rs

1use castep_param_derive::KeywordDisplay;
2use serde::{Deserialize, Serialize};
3
4use super::ElectronicMinimizer;
5/// This keyword determines the maximum number of steepest descent steps in an SCF cycle.
6/// # Default
7/// The default depends on the value of ELECTRONIC_MINIMIZER:
8/// SD then MAX_SD_STEPS : 10
9/// CG then MAX_SD_STEPS : 1
10/// RMM/DIIS then MAX_SD_STEPS : 1
11/// If ELECTRONIC_MINIMIZER is not defined, the default is 1.
12/// # Example
13/// MAX_SD_STEPS : 5
14#[derive(
15    Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, KeywordDisplay,
16)]
17#[keyword_display(field="MAX_SD_STEPS", from=u32,value= u32, default_value=1)]
18pub struct MaxSdSteps(u32);
19
20impl MaxSdSteps {
21    fn default_value(electronic_minimizer: ElectronicMinimizer) -> Self {
22        match electronic_minimizer {
23            ElectronicMinimizer::SD => Self(10),
24            ElectronicMinimizer::CG => Self(1),
25        }
26    }
27}