Simulate IR spectrum¶
Create molecular system from xyz block¶
First we create a molecular system from the xyz file of an N-acetylated disaccharide, and optimize it with xtb (which will also be used for the frequency calculations).
[1]:
""" load xyz string of sugar to xyz_string """
from tqchem.xtb_api import xtb_optimize
from tqchem.molgraph import molecularSystem
from tqchem.viewer import plot_3D_molecule
xyz_string = """51
energy=-2460.3493445538547, objective=-2460.3493445538547
C -1.183415093959497 1.107550643151138 -1.255378131371672
O -0.183143197850699 1.630493109727825 -0.427071233583650
C -0.603740394814199 0.926600641999042 -2.660938464707594
O -1.523294936301506 0.332541994738805 -3.547344252231523
C -0.189073970300791 2.309984966448409 -3.186127162309993
O 0.410365201821380 2.224558472621841 -4.447982289526450
C -1.379328663652860 3.292542319635274 -3.182959114231037
C -2.245543509560783 3.177832438501631 -4.452453366316851
O -3.457191880571815 3.877981646135524 -4.299708392001270
O -2.183993825830461 3.231984964483391 -1.998662326788726
C -2.414989176654948 2.025874240713562 -1.336529359584866
O -3.459597478881328 1.273009325311941 -1.927965125091708
C -4.715034837026844 1.282001196611986 -1.274008895710392
C -5.807879504842207 0.788541348326031 -2.244773865508919
C -5.557224510430674 1.203731614867076 -3.712356800771206
O -4.468398850798219 0.553106544630348 -4.310195991097058
O -6.047168808217727 -0.613842724549636 -2.153872145088098
C -4.983827843356512 -1.437498753782370 -1.782970688956385
O -3.928158649648683 -1.471921078650516 -2.684263682078334
C -4.452889174678131 -1.083210489606104 -0.374532429203084
N -5.019414713626197 -1.989365809394280 0.606286745778364
C -4.472985806353854 -2.208036086340388 1.821706330768321
C -5.077292091702532 -3.379369337124817 2.555047275070394
O -3.585116090873787 -1.506097165944243 2.271640667712120
C -4.754148678488613 0.386426370758548 -0.015975328528959
O -3.864043356818723 0.881102885413059 0.946333814406024
H -1.524238485062721 0.128189007642343 -0.878558651348017
H -0.547228295234976 1.786483179756658 0.453497836199010
H 0.301925107786201 0.307339614367292 -2.591681649382910
H -1.959821935642861 -0.415251239331364 -3.116596970203390
H 0.577194647753042 2.692084410268601 -2.503958811088717
H -0.128171426560111 1.634961121904027 -4.990506366947304
H -0.990476558794590 4.316256992461168 -3.152015323767648
H -1.709685812610016 3.629123864272596 -5.293399737166181
H -2.441296405191949 2.123940475383617 -4.685411408622509
H -3.648586632538890 3.897543090506430 -3.349309392848674
H -2.706792768877701 2.321597959310331 -0.320362410741438
H -4.952122729465665 2.310971972944048 -0.965653027143653
H -6.758417016806406 1.238479047138751 -1.930350276365333
H -6.434158692435479 0.914114377986876 -4.294905828332474
H -5.434040214094964 2.290614806864093 -3.766601891159170
H -3.652426145674124 0.878495222725086 -3.889214388162086
H -5.454612075085539 -2.439263395007074 -1.747333068320020
H -4.188955534605606 -0.959115610450881 -3.486141753151807
H -3.364846139620822 -1.215841808895630 -0.383742009081975
H -5.784287598616999 -2.573185715616032 0.306660311477709
H -6.135545715846943 -3.194429475992891 2.731582419086121
H -4.977249381512319 -4.284063346185799 1.957281916464755
H -4.565701064663073 -3.511991331139032 3.504122023244435
H -5.791391945119907 0.432443525698394 0.359707730156589
H -3.674814925822007 0.156118128599562 1.581342986393859
"""
molecule = molecularSystem(xyz_string)
optimized, energy = xtb_optimize(molecule)
plot_3D_molecule(optimized.ase).show()
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
Calculate and plot the IR spectrum¶
Now we calculate IR excitation frequencies and corresponding intensities. These individual excitations are plotted as a spectrum by first broadening them using Lorentzians with a given width.
[2]:
from tqchem.spectra import plot_spectrum
from tqchem.xtb_api import xtb_ir_spectrum
frequencies, intensities = xtb_ir_spectrum(optimized, method="gfn1-xtb")
fig = plot_spectrum(frequencies, intensities, 0, 3700, broaden_type="lorentzian")
fig.show()
Data type cannot be displayed: application/vnd.plotly.v1+json