Infrared spectra
This tutorial shows how to calculate infrared spectra with MLatom using a commonly used way: calculate frequencies and infrared (IR) intensities of static molecules.
Please check out how to calculate vibrational spectra from molecular dynamics trajectories.
Theory
In the harmonic approximation, the frequencies of a stationary point can be calculated by diagonalizing its Hessian matrix (second derivatives of energy with respect to coordinates). The corresponding IR intensities need dipole derivatives (first derivatives of dipole moment with respect to coordinates):
\(I_{n} = \sum \limits _{t=1} ^{3} (\frac {\partial p_{t}} {\partial Q_{n}}) ^{2}\) ,
where \(t\) corresponds to each Cartesian dimension, \(p\) is the dipole moment of the molecule, \(Q_{n}\) is the \(n\) th normal coordinate. Usually we get dipole derivatives with respect to each atomic coordinate, so the above equation can be rewritten as:
\(I_{n} = \sum \limits _{t=1} ^{3} (\sum \limits _{x} \frac {\partial p_{t}} {\partial q_{x}} \frac {\partial q_{x}} {\partial Q_{n}}) ^{2}\) ,
where \(q_{x}\) is the component of atomic coordinates.
Example
We present a simple example of calculating harmonic frequencies and IR intensities of ethanol, whose geometry is provided here ethanol_init.xyz
. We need to optimize its geometry first and then calculate its frequencies as frequency calculations are only reasonable for stationary points (e.g., local minima and transition states).
警告
We recommend to use UAIQM methods for the IR calculations, example below is just to show that you can use other methods too.
Example with input file
First we need to optimize the geometry of ethanol. Below is the input file for this task. You can refer to geometry optimization tutorial for more details.
geomopt
B3LYP/6-31G*
xyzfile=ethanol_init.xyz
optxyz=ethanol_opt.xyz
备注
At the moment, simpler input described in this documentation only works for the MLatom@XACS version on the XACS cloud computing.
If you install MLatom locally, you always need specify additional keywords such as method=B3LYP/6-31G*
and qmprog=gaussian
etc. to make it work. Local version still has some other limitations such as using only a single CPU with PySCF by default (you need to specify nthreads
).
After getting the geometry of the optimized ethanol (ethanol_opt.xyz
) we can calculate its frequencies and IR intenities. For IR intenisties, the keyword ir
is needed. You can refer to frequencies tutorial for information of other keywords.
ir
B3LYP/6-31G*
xyzfile=ethanol_opt.xyz
You should be able to find in the MLatom output the vibrational analysis and IR intensities.
==============================================================================
Vibration analysis for molecule 1
==============================================================================
Multiplicity: 1
This is a nonlinear molecule
Mode Frequencies Reduced masses Force Constants IR intensities
(cm^-1) (AMU) (mDyne/A) (km/mol)
1 248.4747 1.1524 0.0419 32.3833
2 301.0663 1.0696 0.0571 99.1615
3 417.5299 2.6381 0.2710 11.2144
4 830.0330 1.0800 0.4384 0.0152
5 912.5116 2.2005 1.0796 9.7442
6 1042.3161 2.1512 1.3770 56.5354
7 1125.4816 2.2612 1.6876 23.7752
8 1193.9827 1.4953 1.2559 4.7774
9 1290.5694 1.2508 1.2275 87.6053
10 1310.5341 1.1222 1.1356 0.0903
11 1427.9291 1.2321 1.4802 0.4122
12 1480.9785 1.4590 1.8854 16.5845
13 1513.8300 1.0411 1.4058 4.4003
14 1532.0798 1.0458 1.4464 3.0858
15 1561.1233 1.0910 1.5666 2.6189
16 2980.0716 1.0552 5.5213 73.9417
17 3003.5497 1.1085 5.8921 78.0445
18 3058.1727 1.0352 5.7041 15.7969
19 3129.0297 1.1026 6.3606 31.5280
20 3133.5337 1.1038 6.3856 34.2645
21 3746.8800 1.0665 8.8215 10.4090
On XACS platform, we provide our own implementation of calculating IR intensities. IR intensities are available when using PySCF for HF and DFT, which are based on the pyscf.prop module.
Visualizing vibrations
There are several ways to visualize the vibrations:
Currently only on the XACS cloud computing:
At the end of the calculations via input file/command line using the options
freq
,ir
, orraman
, MLatom will dump thefreq_gaussian{mol_index}.log
file, which uses Gaussian-style output format for frequencies. You can open it in ChemCraft.You can also dump text output file using Gaussian-style format for frequencies from the Python API:
mymolecule.dump(filename='gauss.log', format='gaussian')
.
You can directly view the vibrations in
Jupyter notebook
by usingmymolecule.view(normal_mode=...)
, as shown below for an examplemolvibr.json
file:
import mlatom as ml
# let's load the molecule with the required properties
molvibr = ml.molecule()
molvibr.load(filename='molvibr.json')
# choose the normal mode to visualize
normal_mode = 1
# let's view it
molvibr.view(normal_mode=normal_mode)
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
# we can also check the information for this normal mode
print(f'Frequency: {molvibr.frequencies[normal_mode]:.2f} cm^-1')
print(f'Normal mode in Angstrom')
for atom in molvibr.atoms:
disp = atom.normal_modes[normal_mode]
print(f" {disp[0]:8.3f} {disp[1]:8.3f} {disp[2]:8.3f}")
Frequency: 288.70 cm^-1 Normal mode in Angstrom -0.000 0.000 -0.025 -0.085 0.168 -0.141 0.085 -0.168 -0.141 0.000 0.000 0.184 -0.000 -0.000 -0.003 0.018 -0.021 -0.014 -0.018 0.021 -0.014 0.000 0.000 0.085 -0.000 -0.000 -0.890
# the non-displaced geometry for reference
print(molvibr.get_xyz_string())
9 C -1.2121068000000 -0.2252488500000 0.0000164100000 H -1.2701429600000 -0.8599818400000 -0.8855315500000 H -1.2701264500000 -0.8599834500000 0.8855643400000 H -2.0710636400000 0.4504289000000 0.0000252100000 C 0.0804149500000 0.5556635800000 0.0000041500000 H 0.1395635900000 1.1970970800000 -0.8856250600000 H 0.1395848700000 1.1970854800000 0.8856411200000 O 1.1428329300000 -0.3971737900000 -0.0000106600000 H 1.9796722200000 0.0702558200000 -0.0001121300000
# non-displaced geometry
molvibr.view()
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
Any questions or suggestions?
If you have further questions, criticism, and suggestions, we would be happy to receive them in English or Chinese via email, Slack (preferred), or WeChat (please send an email to request to add you to the XACS user support group).