Generate Gaussian Inputs
For these examples we are going to assume that we have a folder named 'sdf_files' that contains a single file 'ethane.sdf' with a single conformer in .sdf format whose gaussian input file we want to generate. As you might have guessed in this specific example we will be working with Ethane.
The sdf file contents are as follows:
OpenBabel12082212193D
8 7 0 0 0 0 0 0 0 0999 V2000
0.9537 -0.0505 -0.0702 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4658 -0.0505 -0.0702 C 0 0 0 0 0 0 0 0 0 0 0 0
0.5694 -1.0113 -0.4254 H 0 0 0 0 0 0 0 0 0 0 0 0
0.5694 0.7375 -0.7247 H 0 0 0 0 0 0 0 0 0 0 0 0
0.5694 0.1223 0.9395 H 0 0 0 0 0 0 0 0 0 0 0 0
2.8501 -0.2233 -1.0799 H 0 0 0 0 0 0 0 0 0 0 0 0
2.8501 -0.8385 0.5843 H 0 0 0 0 0 0 0 0 0 0 0 0
2.8501 0.9103 0.2850 H 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
1 4 1 0 0 0 0
1 5 1 0 0 0 0
2 6 1 0 0 0 0
2 7 1 0 0 0 0
2 8 1 0 0 0 0
M END
$$$$
Note
The following code will also work for multiple conformers and/or molecules.
Note
AQME supports various formats for providing the geometries of the conformers. If we want to use a format to specify the molecule that does not contain 3D coordinates we will need to generate them beforehand, please see the Conformer Search section.
First we start importing the required modules.
from pathlib import Path
from aqme.qprep import qprep
Next we list all the files whose gaussian input we want.
sdf_files = [str(filepath) for filepath in Path('sdf_files').glob('*.sdf'))]
Now we proceed to generate the gaussian input files.
qprep(files=sdf_files,
qm_input='wb97xd/def2qzvpp scrf=(smd,solvent=acetonitrile)',
suffix='wb97xd-basic',
program='gaussian',
mem='16GB',
nprocs=8)
With this we have generated a new folder named QCALC that contains the file 'ethane_conf_1_wb97xd-basic.com' with the following contents:
%nprocshared=8
%mem=16GB
# wb97xd/def2qzvpp scrf=(smd,solvent=acetonitrile)
ethane_conf_1_wb97xd-basic
0 1
C 0.95370000 -0.05050000 -0.07020000
C 2.46580000 -0.05050000 -0.07020000
H 0.56940000 -1.01130000 -0.42540000
H 0.56940000 0.73750000 -0.72470000
H 0.56940000 0.12230000 0.93950000
H 2.85010000 -0.22330000 -1.07990000
H 2.85010000 -0.83850000 0.58430000
H 2.85010000 0.91030000 0.28500000
Enforce Charge and Multiplicity
If we had wanted to specify the charge and multiplicity we just need to add the appropriate keywords.
qprep(files=sdf_files,
charge=0,
mult=3,
qm_input='wb97xd/def2qzvpp scrf=(smd,solvent=acetonitrile)',
suffix='wb97xd-triplet',
program='gaussian',
mem='16GB',
nprocs=8)
Will lead to the creation of the file 'ethane_conf_1_wb97xd-triplet.com' with the following contents:
%nprocshared=8
%mem=16GB
# wb97xd/def2qzvpp scrf=(smd,solvent=acetonitrile)
ethane_conf_1_wb97xd-triplet
0 3
C 0.95370000 -0.05050000 -0.07020000
C 2.46580000 -0.05050000 -0.07020000
H 0.56940000 -1.01130000 -0.42540000
H 0.56940000 0.73750000 -0.72470000
H 0.56940000 0.12230000 0.93950000
H 2.85010000 -0.22330000 -1.07990000
H 2.85010000 -0.83850000 0.58430000
H 2.85010000 0.91030000 0.28500000
Include the gen or genecp section
If we want to include a genecp with automatic detection of the atoms in the molecule we have to add some extra keywords.
qprep(files=sdf_files,
bs_gen='def2svp', # Basis set to use in the atoms included in genECP
bs_nogen='6-31G*', # Basis set to use in the rest of the atoms
gen_atoms=['C'], # Atoms to include as genECP
qm_input='wb97xd/genecp scrf=(smd,solvent=acetonitrile)',
suffix='wb97xd-genecp',
program='gaussian',
mem='16GB',
nprocs=8)
Will lead to the creation of the file 'ethane_conf_1_wb97xd-genecp.com' with the following contents:
%nprocshared=8
%mem=16GB
# wb97xd/genecp scrf=(smd,solvent=acetonitrile)
ethane_conf_1_wb97xd-genecp
0 1
C 0.95370000 -0.05050000 -0.07020000
C 2.46580000 -0.05050000 -0.07020000
H 0.56940000 -1.01130000 -0.42540000
H 0.56940000 0.73750000 -0.72470000
H 0.56940000 0.12230000 0.93950000
H 2.85010000 -0.22330000 -1.07990000
H 2.85010000 -0.83850000 0.58430000
H 2.85010000 0.91030000 0.28500000
H 0
6-31G*
****
C 0
def2svp
****
C 0
def2svp
If we instead do not want to include the ECP section, or in other words we want
to use the gen
instead of genecp
we only need to substitute it in the
qm_input
parameter. AQME will automatically recognize it and write
the input file accordingly:
qprep(files=sdf_files,
bs_gen='def2svp', # Basis set to use in the atoms included in genECP
bs_nogen='6-31G*', # Basis set to use in the rest of the atoms
gen_atoms=['C'], # Atoms to include as genECP
qm_input='wb97xd/gen scrf=(smd,solvent=acetonitrile)',
suffix='wb97xd-gen',
program='gaussian',
mem='16GB',
nprocs=8)
Which will lead to the creation of the file 'ethane_conf_1_wb97xd-gen.com' with the following contents:
%nprocshared=8
%mem=16GB
# wb97xd/gen scrf=(smd,solvent=acetonitrile)
ethane_conf_1_wb97xd-gen
0 1
C 0.95370000 -0.05050000 -0.07020000
C 2.46580000 -0.05050000 -0.07020000
H 0.56940000 -1.01130000 -0.42540000
H 0.56940000 0.73750000 -0.72470000
H 0.56940000 0.12230000 0.93950000
H 2.85010000 -0.22330000 -1.07990000
H 2.85010000 -0.83850000 0.58430000
H 2.85010000 0.91030000 0.28500000
H 0
6-31G*
****
C 0
def2svp
****
Include instructions after the geometry section
Finally if we want to specify some extra instructions after the geometry which are required for some commands such as the modredundant optimization option or for nbo6 calculations. Here we use the NBO as an example.
qprep(files=sdf_files,
qm_end='$nbo bndidx $end', # Final lines after the coordinates section
qm_input='pop=(nbo6read,savenbos) wb97xd/def2svp',
suffix='wb97xd-nbo',
program='gaussian',
mem='16GB',
nprocs=8)
Will lead to the creation of the file 'ethane_conf_1_wb97xd-nbo.com' with the following contents:
%nprocshared=8
%mem=16GB
# pop=(nbo6read,savenbos) wb97xd/def2svp
ethane_conf_1_wb97xd-nbo
0 1
C 0.95370000 -0.05050000 -0.07020000
C 2.46580000 -0.05050000 -0.07020000
H 0.56940000 -1.01130000 -0.42540000
H 0.56940000 0.73750000 -0.72470000
H 0.56940000 0.12230000 0.93950000
H 2.85010000 -0.22330000 -1.07990000
H 2.85010000 -0.83850000 0.58430000
H 2.85010000 0.91030000 0.28500000
$nbo bndidx $end