use super::make_inp_block;
#[derive(Clone, Copy, PartialEq, Debug, Default)]
pub enum SolvatorClusterMode {
#[default]
None,
Stochastic,
}
impl SolvatorClusterMode {
pub fn keyword(self) -> String {
match self {
Self::None => String::new(),
Self::Stochastic => "stochastic".to_owned(),
}
}
}
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum ImplicitSolvationSurfaceType {
VdwGaussian,
}
impl ImplicitSolvationSurfaceType {
pub fn keyword(self) -> String {
match self {
Self::VdwGaussian => "vdw_gaussian",
}
.to_owned()
}
}
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum ImplicitSolvationModel {
Cpcm,
Smd,
OpenCosmo,
Alpb,
}
#[derive(Clone, Debug)]
pub struct SolvatorImplicit {
pub model: ImplicitSolvationModel,
pub solvent: Solvent,
pub surface_type: Option<ImplicitSolvationSurfaceType>,
pub epsilon: Option<f32>,
pub rsolv: Option<f32>,
pub draco: bool,
pub soln: Option<f32>,
pub soln25: Option<f32>,
}
impl SolvatorImplicit {
pub fn make_inp(&self) -> String {
let mut contents: Vec<(&str, String)> = vec![("solvent", self.solvent.keyword())];
if let Some(st) = &self.surface_type {
contents.push(("surface_type", st.keyword()));
}
if let Some(v) = self.epsilon {
contents.push(("epsilon", format!("{v:.6}")));
}
if let Some(v) = self.rsolv {
contents.push(("rsolv", format!("{v:.6}")));
}
if self.draco {
contents.push(("draco", "true".to_owned()));
}
if let Some(v) = self.soln {
contents.push(("soln", format!("{v:.6}")));
}
if let Some(v) = self.soln25 {
contents.push(("soln25", format!("{v:.6}")));
}
match self.model {
ImplicitSolvationModel::Cpcm => make_inp_block("cpcm", &contents, &[]),
ImplicitSolvationModel::Smd => {
contents.push(("smd", "true".to_owned()));
make_inp_block("cpcm", &contents, &[])
}
_ => unimplemented!(),
}
}
}
impl ImplicitSolvationModel {
pub fn keyword(self) -> String {
match self {
Self::Cpcm => "cpcm",
Self::Smd => "smd",
Self::OpenCosmo => "cosmors",
Self::Alpb => "alpb",
}
.to_owned()
}
}
#[derive(Clone, Debug)]
pub struct Solvator {
pub solvent: Solvent,
pub num_mols: u16,
pub cluster_mode: SolvatorClusterMode,
pub droplet: bool,
}
impl Solvator {
pub fn make_inp(&self) -> String {
let mut contents = vec![
("nsolv", self.num_mols.to_string()),
("clustermode", self.cluster_mode.keyword()),
];
if self.droplet {
contents.push(("droplet", "true".to_string()));
}
make_inp_block("solvator", &contents, &[])
}
}
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Solvent {
Water,
Ethanol,
Methanol,
Phenol,
Amonia,
}
impl Solvent {
pub fn keyword(self) -> String {
match self {
Self::Water => "water",
Self::Ethanol => "ethanol",
Self::Methanol => "methanol",
Self::Phenol => "phenol",
Self::Amonia => "amonia",
}
.to_owned()
}
}