use crate::{structure_files::Cell, structure_files::Msi, ModelFormat};
#[derive(Clone, Debug, PartialEq)]
pub struct Settings<T: ModelFormat> {
kpoints_list: Vec<[f64; 4]>,
kpoints_grid: [u8; 3],
kpoints_mp_spacing: Option<f64>,
kpoints_mp_offset: [f64; 3],
fix_all_cell: bool,
fix_com: bool,
external_efield: [f64; 3],
external_pressure: [f64; 6],
cry_display: (u32, u32),
periodic_type: u8,
space_group: String,
cry_tolerance: f64,
format_marker: T,
}
impl Settings<Msi> {
pub fn new_msi_settings(periodic_type: u8, space_group: &str, cry_tolerance: f64) -> Self {
Self {
periodic_type,
space_group: space_group.into(),
cry_tolerance,
..Default::default()
}
}
}
impl<T: ModelFormat> Default for Settings<T> {
fn default() -> Self {
Self {
kpoints_list: vec![[0.0, 0.0, 0.0, 1.0]],
kpoints_grid: [1, 1, 1],
kpoints_mp_spacing: None,
kpoints_mp_offset: [0.0, 0.0, 0.0],
fix_all_cell: true,
fix_com: false,
external_efield: [0.0, 0.0, 0.0],
external_pressure: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
periodic_type: 100_u8,
space_group: "1 1".to_string(),
cry_tolerance: 0.05,
cry_display: (192, 256),
format_marker: T::default(),
}
}
}
impl Settings<Cell> {
pub fn kpoints_list(&self) -> &[[f64; 4]] {
self.kpoints_list.as_ref()
}
pub fn kpoints_grid(&self) -> [u8; 3] {
self.kpoints_grid
}
pub fn kpoints_mp_spacing(&self) -> Option<f64> {
self.kpoints_mp_spacing
}
pub fn kpoints_mp_offset(&self) -> [f64; 3] {
self.kpoints_mp_offset
}
pub fn fix_all_cell(&self) -> bool {
self.fix_all_cell
}
pub fn fix_com(&self) -> bool {
self.fix_com
}
pub fn external_efield(&self) -> [f64; 3] {
self.external_efield
}
pub fn external_pressure(&self) -> [f64; 6] {
self.external_pressure
}
}
impl Settings<Msi> {
pub fn periodic_type(&self) -> u8 {
self.periodic_type
}
pub fn space_group(&self) -> &str {
self.space_group.as_ref()
}
pub fn cry_tolerance(&self) -> f64 {
self.cry_tolerance
}
}
pub trait DefaultExport<T: ModelFormat> {
fn export(&self) -> String;
}
pub trait BandStructureExport<T: ModelFormat> {
fn export(&self) -> String;
}