use std::fmt::Display;
use crate::InvLengthUnit;
pub mod mp_settings;
pub mod nc_settings;
#[derive(Debug, Clone, Copy, Default)]
pub enum KpointTask {
#[default]
#[allow(clippy::upper_case_acronyms)]
SCF,
Spectral,
Phonon,
}
#[derive(Debug, Clone, Copy, Default)]
pub enum KpointQuality {
#[default]
Coarse,
Medium,
Fine,
}
impl KpointQuality {
pub fn spacing_value(&self, metal_selected: bool) -> f64 {
if metal_selected {
match self {
KpointQuality::Coarse => 0.07,
KpointQuality::Medium => 0.05,
KpointQuality::Fine => 0.04,
}
} else {
match self {
KpointQuality::Coarse => 0.1,
KpointQuality::Medium => 0.08,
KpointQuality::Fine => 0.07,
}
}
}
}
#[derive(Debug, Clone)]
pub enum KpointSettings {
List(KpointListBlock),
MPGrid(KpointMPGrid),
MPSpacing(KpointMPSpacing),
}
impl Display for KpointSettings {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let content = match self {
KpointSettings::List(list_block) => format!("{}", list_block),
KpointSettings::MPGrid(grid) => format!("{}", grid),
KpointSettings::MPSpacing(spacing) => format!("{}", spacing),
};
write!(f, "{content}")
}
}
#[derive(Debug, Clone)]
pub enum NCKpointSettings {
List(KpointListBlock),
Path(BSKpointPath),
PathSpacing(BSKpointPathSpacing),
}
impl Display for NCKpointSettings {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let content = match self {
NCKpointSettings::List(l) => format!("{}", l),
NCKpointSettings::Path(pth) => format!("{}", pth),
NCKpointSettings::PathSpacing(pth_spacing) => format!("{}", pth_spacing),
};
write!(f, "{content}")
}
}
#[derive(Debug, Clone)]
pub struct KpointListBlock {
task: KpointTask,
kpoint_list: Vec<[f64; 4]>,
}
impl KpointListBlock {
pub fn new(task: KpointTask, kpoint_list: Vec<[f64; 4]>) -> Self {
Self { task, kpoint_list }
}
}
#[derive(Debug, Clone, Copy)]
pub struct KpointMPGrid {
task: KpointTask,
grid: [u32; 3],
}
impl KpointMPGrid {
pub fn new(task: KpointTask, grid: [u32; 3]) -> Self {
Self { task, grid }
}
}
#[derive(Debug, Clone, Copy)]
pub struct KpointMPSpacing {
task: KpointTask,
spacing: f64,
unit: InvLengthUnit,
}
impl KpointMPSpacing {
pub fn new(task: KpointTask, spacing: f64, unit: InvLengthUnit) -> Self {
Self {
task,
spacing,
unit,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct KpointMPOffset {
offset: [f64; 3],
}
impl KpointMPOffset {
pub fn new(offset: [f64; 3]) -> Self {
Self { offset }
}
}
#[derive(Debug, Clone)]
pub struct BSKpointPath {
paths: Vec<[f64; 3]>,
}
impl BSKpointPath {
pub fn new(paths: Vec<[f64; 3]>) -> Self {
Self { paths }
}
}
#[derive(Debug, Clone)]
pub struct BSKpointPathSpacing {
unit: InvLengthUnit,
spacing: f64,
}
impl BSKpointPathSpacing {
pub fn new(unit: InvLengthUnit, spacing: f64) -> Self {
Self { unit, spacing }
}
}