castep_model_core/model_type/
mod.rs1use std::fmt::Debug;
2
3use crate::{CellModel, MsiModel};
4
5pub mod cell;
6pub mod msi;
7
8pub trait ModelInfo: Debug + Clone + Default {}
9
10#[derive(Clone, Debug, PartialEq)]
11pub struct Settings<T: ModelInfo> {
12 kpoints_list: Vec<[f64; 4]>,
14 kpoints_grid: [u8; 3],
16 kpoints_mp_spacing: Option<f64>,
18 kpoints_mp_offset: [f64; 3],
20 fix_all_cell: bool,
22 fix_com: bool,
24 external_efield: [f64; 3],
26 external_pressure: [f64; 6],
28 cry_display: (u32, u32),
30 periodic_type: u8,
32 space_group: String,
34 cry_tolerance: f64,
36 format_marker: T,
37}
38
39impl Settings<MsiModel> {
40 pub fn new_msi_settings(periodic_type: u8, space_group: &str, cry_tolerance: f64) -> Self {
41 Self {
42 periodic_type,
43 space_group: space_group.into(),
44 cry_tolerance,
45 ..Default::default()
46 }
47 }
48}
49
50impl<T: ModelInfo> Default for Settings<T> {
51 fn default() -> Self {
52 Self {
53 kpoints_list: vec![[0.0, 0.0, 0.0, 1.0]],
54 kpoints_grid: [1, 1, 1],
55 kpoints_mp_spacing: None,
56 kpoints_mp_offset: [0.0, 0.0, 0.0],
57 fix_all_cell: true,
58 fix_com: false,
59 external_efield: [0.0, 0.0, 0.0],
60 external_pressure: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
61 periodic_type: 100_u8,
62 space_group: "1 1".to_string(),
63 cry_tolerance: 0.05,
64 cry_display: (192, 256),
65 format_marker: T::default(),
66 }
67 }
68}
69
70impl Settings<CellModel> {
72 pub fn kpoints_list(&self) -> &[[f64; 4]] {
73 self.kpoints_list.as_ref()
74 }
75
76 pub fn kpoints_grid(&self) -> [u8; 3] {
77 self.kpoints_grid
78 }
79
80 pub fn kpoints_mp_spacing(&self) -> Option<f64> {
81 self.kpoints_mp_spacing
82 }
83
84 pub fn kpoints_mp_offset(&self) -> [f64; 3] {
85 self.kpoints_mp_offset
86 }
87
88 pub fn fix_all_cell(&self) -> bool {
89 self.fix_all_cell
90 }
91
92 pub fn fix_com(&self) -> bool {
93 self.fix_com
94 }
95
96 pub fn external_efield(&self) -> [f64; 3] {
97 self.external_efield
98 }
99
100 pub fn external_pressure(&self) -> [f64; 6] {
101 self.external_pressure
102 }
103}
104
105impl Settings<MsiModel> {
107 pub fn periodic_type(&self) -> u8 {
108 self.periodic_type
109 }
110
111 pub fn space_group(&self) -> &str {
112 self.space_group.as_ref()
113 }
114
115 pub fn cry_tolerance(&self) -> f64 {
116 self.cry_tolerance
117 }
118}
119
120pub trait DefaultExport<T: ModelInfo> {
121 fn export(&self) -> String;
122}
123
124pub trait BandStructureExport<T: ModelInfo> {
125 fn export(&self) -> String;
126}