Skip to content

Commit

Permalink
Add more flags (#46)
Browse files Browse the repository at this point in the history
* Add more flags to gen command

* Fix templates
  • Loading branch information
caprilesport authored Feb 4, 2024
1 parent d580b1b commit 7de42b9
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 26 deletions.
10 changes: 6 additions & 4 deletions gedent.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ default_extension = "inp"
[parameters]
basis_set = "def2svp"
charge = 1
functional = "BP86"
functional_class = "GGA"
memory = 3000
multiplicity = 1
method = "BP86"
method_class = "GGA"
mem = 3000
mult = 1
nprocs = 20
solvation = false
solvent = "water"
split_index = 10
hessian = false
solvation_model = "CPCM"
dispersion = "D3"
91 changes: 82 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,46 @@ enum Mode {
Gen {
/// The template to look for in ~/.config/gedent/templates
template_name: String,
// TODO: Make this a flag
/// xyz files
#[arg(value_name = "XYZ files")]
xyz_files: Option<Vec<PathBuf>>,
/// Print to screen and don't save file
#[arg(short, long, default_value_t = false)]
print: bool,
/// Set method
#[arg(long, default_value = None)]
method: Option<String>,
/// Set basis_set
#[arg(long, default_value = None)]
basis_set: Option<String>,
/// Set dispersion
#[arg(long, default_value = None)]
dispersion: Option<String>,
/// Set solvent to value and solvation to true
#[arg(short, long, default_value = None)]
solvent: Option<Option<String>>,
/// Set solvation_model
#[arg(long, default_value = None)]
solvation_model: Option<String>,
/// Set charge
#[arg(short, long, default_value = None)]
charge: Option<usize>,
/// Set multiplicity
/// Set hessian
#[arg(long, default_value_t = false)]
hessian: bool,
#[arg(short, long, default_value = None)]
multiplicity: Option<usize>,
/// Set mult
#[arg(short, long, default_value = None)]
mult: Option<usize>,
/// Set nprocs
#[arg(long, default_value = None)]
nprocs: Option<usize>,
/// Set mem
#[arg(long, default_value = None)]
mem: Option<usize>,
/// Set split_index
#[arg(long, default_value = None)]
split_index: Option<usize>,
},
// Subcommand to deal with configurations
/// Access gedent configuration
Expand Down Expand Up @@ -157,9 +181,17 @@ fn main() -> Result<()> {
template_name,
xyz_files,
print,
method,
basis_set,
dispersion,
solvent,
solvation_model,
charge,
multiplicity,
hessian,
mult,
nprocs,
mem,
split_index,
} => {
let mut molecules: Vec<Molecule> = vec![];
if let Some(files) = xyz_files {
Expand All @@ -168,7 +200,21 @@ fn main() -> Result<()> {
}
};
let template = Template::get(template_name)?;
let results = generate_input(template, molecules, solvent, multiplicity, charge)?;
let results = generate_input(
template,
molecules,
solvent,
mult,
charge,
method,
basis_set,
dispersion,
solvation_model,
hessian,
nprocs,
mem,
split_index,
)?;
for input in results {
if print {
println!("{}", input.content);
Expand Down Expand Up @@ -338,6 +384,14 @@ fn generate_input(
solvation: Option<Option<String>>,
mult: Option<usize>,
charge: Option<usize>,
method: Option<String>,
basis_set: Option<String>,
dispersion: Option<String>,
solvation_model: Option<String>,
hessian: bool,
nprocs: Option<usize>,
mem: Option<usize>,
split_index: Option<usize>,
) -> Result<Vec<Input>, Error> {
let mut context = tera::Context::new();
let config = Config::get()?;
Expand All @@ -353,12 +407,31 @@ fn generate_input(
}
}

if let Some(mult) = mult {
context.insert("multiplicity", &mult);
if hessian {
context.insert("hessian", &hessian);
}

if let Some(charge) = charge {
context.insert("charge", &charge);
for (k, v) in [
("charge", charge),
("mult", mult),
("nprocs", nprocs),
("mem", mem),
("split_index", split_index),
] {
if let Some(v) = v {
context.insert(k, &v);
}
}

for (k, v) in [
("method", method),
("basis_set", basis_set),
("dispersion", dispersion),
("solvation_model", solvation_model),
] {
if let Some(v) = v {
context.insert(k, &v);
}
}

let extension = match &template.options.extension {
Expand Down
2 changes: 1 addition & 1 deletion templates/adf/eda
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Engine adf

XC
Dispersion Grimme3 BJDAMP
{{ functional_class }} {{ functional }}
{{ method_class }} {{ functional }}
end

Beckegrid
Expand Down
2 changes: 1 addition & 1 deletion templates/adf/sp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Engine ADF
end

XC
{{ functional_class }} {{ functional }}
{{ method_class }} {{ functional }}
Dispersion Grimme3 BJDAMP
end

Expand Down
4 changes: 2 additions & 2 deletions templates/gaussian/nbo_del
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ extension = "gjf"
--@
%chk={{ Molecule.filename }}.chk
%nproc={{ nprocs }}
%mem={{ memory }}GB
# {{ functional }}/{{ basis_set }} pop=nbo6del nosymm
%mem={{ mem }}GB
# {{ method }}/{{ basis_set }} pop=nbo6del nosymm

job title: {{ Molecule.filename }}

Expand Down
4 changes: 2 additions & 2 deletions templates/gaussian/opt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ extension = "gjf"
{%endif-%}
%chk={{ Molecule.filename }}.chk
%nproc={{ nprocs }}
%mem={{ memory }}GB
# {{ functional }}/{{ basis_set }} opt freq=noraman {{ solvent }}
%mem={{ mem }}GB
# {{ method }}/{{ basis_set }} opt freq=noraman {{ solvent }}

job title: {{ Molecule.filename }}

Expand Down
4 changes: 2 additions & 2 deletions templates/gaussian/sp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extension = "gjf"
{%set solvent=""-%}
{%endif-%}
%nproc={{ nprocs }}
%mem={{ memory }}GB
# {{ functional }}/{{ basis_set }} freq=noraman scrf=(smd,solvent=ethanol) temperature=353
%mem={{ mem }}GB
# {{ method }}/{{ basis_set }} freq=noraman scrf=(smd,solvent=ethanol) temperature=353

job title: {{ Molecule.filename }}

Expand Down
4 changes: 2 additions & 2 deletions templates/orca/neb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! {{ functional }} {{ basis_set }}
! {{ method }} {{ basis_set }}
! NEB-TS NumFreq IRC

*xyzfile {{ charge }} {{ mult }} {{ xyz_file }}
Expand All @@ -7,7 +7,7 @@
nprocs {{ nprocs }}
end

%maxcore {{ memory }}
%maxcore {{ mem }}

{% if solvation -%}
%cpcm
Expand Down
4 changes: 2 additions & 2 deletions templates/orca/opt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
--@
extension = "inp"
--@
! {{ functional }} {{ basis_set }}
! {{ method }} {{ basis_set }}
! Opt freq D3BJ

%pal
nprocs {{ nprocs }}
end

%maxcore {{ memory }}
%maxcore {{ mem }}

{% if solvation -%}
%cpcm
Expand Down
2 changes: 1 addition & 1 deletion templates/orca/scan
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! {{ functional }} {{ basis_set }}
! {{ method }} {{ basis_set }}
! Opt

{% if solvation -%}
Expand Down

0 comments on commit 7de42b9

Please sign in to comment.