use std::{
io,
path::{Path, PathBuf},
};
use crate::{Xyz, load_xyz_trajectory, orca::make_inp_block};
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Thermostat {
Berendensen,
Csvr,
Nhc,
None,
}
impl Thermostat {
pub fn keyword(self) -> String {
match self {
Self::Berendensen => "Berendensen",
Self::Csvr => "CSVR",
Self::Nhc => "NHC",
Self::None => "None",
}
.to_string()
}
}
#[derive(Clone, Debug)]
pub struct Dynamics {
pub timestep: f32,
pub init_vel: f32,
pub thermostat: Thermostat,
pub thermostat_temp: f32,
pub thermostat_timecon: f32,
pub traj_out_dir: PathBuf,
pub steps: u32,
}
impl Dynamics {
pub fn make_inp(&self) -> String {
let contents = vec![
("Timestep", format!("{:.1}_fs", self.timestep)),
("Initvel", format!("{:.1}_K", self.init_vel)),
(
"Thermostat",
format!(
"{} {:.1}_K Timecon {:.1}_fs",
self.thermostat.keyword(),
self.thermostat_temp,
self.thermostat_timecon
),
),
(
"Dump",
format!(
"Position Stride 1 Filename \"{}\"",
self.traj_out_dir.to_str().unwrap()
),
),
("Run", self.steps.to_string()),
];
make_inp_block("md", &contents, &[])
}
}
#[derive(Clone, Debug)]
pub struct DynamicsOutput {
pub text: String,
pub trajectory: Vec<Xyz>,
}
impl DynamicsOutput {
pub fn new(traj_path: &Path, text: String) -> io::Result<Self> {
let trajectory = load_xyz_trajectory(traj_path)?;
Ok(Self { text, trajectory })
}
}