Spectroscopy ============= It is available for MLatom to simulate different kinds of spectra. Here we will show how to use MLatom for power spectra and IR spectra. - :ref:`Power spectra ` - :ref:`IR spectra ` .. _Power spectra: Power spectra ~~~~~~~~~~~~~ MD trajectory can be used to generate the power spectra. Here we choose ethanol as example. To generate the power spectrum of ethanol in command line, we should prepare the input file :download:`ethanol_ps.inp ` and the auxiliary file :download:`ethanol_traj.h5 ` documenting the molecular dynamics trajectory of ethanol. .. code-block:: # ethanol_ps.inp MD2vibr # Calculate vibrational spectrum from MD trajH5MDin=ethanol_traj.h5 # Read MD trajectory output=ps # Calculate power spectrum Run it. .. code-block:: mlatom ethanol_ps.inp Import a specific module in Python so that the result will appear in ``.png`` format. .. code-block:: from IPython.display import Image Image(filename='ps.png') .. _IR spectra: IR spectra ~~~~~~~~~~~ MD trajectory can also be used to generate IR spectra. Similar with the power spectra, in command line we need to prepare the input file :download:`ethanol_ir.inp ` and the MD trajectory :download:`ethanol_traj.h5 `. .. code-block:: # ethanol_ir.inp MD2vibr # Calculate vibrational spectrum from MD trajH5MDin=ethanol_traj.h5 # Read MD trajectory output=ir # Calculate infrared spectrum Run the input file. .. code-block:: mlatom ethanol_ir.inp Import a specific module in Python so that the result will appear in ``.png`` format. .. code-block:: from IPython.display import Image Image(filename='ir.png') There is the code for simulating IR spectra in Python. You can see the spectrum (``ir.png``) in your folder after the computation is finished: .. figure:: _static/ir-aiqm1.png :width: 100% :align: center Below, for comparison, is the spectrum from the NIST database: .. figure:: _static/ir-nist.png :width: 100% :align: center .. code-block:: import mlatom as ml traj = ml.data.molecular_trajectory() traj.load('ethanol_traj.h5',format='h5md') dt = traj.steps[1].time - traj.steps[0].time moldb = ml.data.molecular_database() moldb.molecules = [each.molecule for each in traj.steps] vib = ml.vibrational_spectrum(molecular_database=moldb, dt=dt) vib.plot_infrared_spectrum(filename='ir_api.png') from IPython.display import Image Image(filename='ir_api.png') .. include:: ml-nea.rst .. include:: ml-tpa.rst