.. _li_mgo_epr: ******************************* Electron paramagnetic resonance ******************************* .. note:: The files for this section of the tutorial can be found in ``li_mgo/5_li-mgo_epr``. The input files in this directory were obtained using a Py-ChemShell geometry optimisation on the optimised Li doped MgO cluster where the electron hole is localised on one oxygen. This section of the tutorial will illustrate how to calculate the electron paramagnetic resonance (EPR) g tensor of the Li doped MgO cluster. The g tensor is a spin-Hamiltonian parameter, which arises from the electron spin interacting with an external magnetic field. The EPR calculation is set up using NWChem. This is done by modifying the ``_nwchem.inp`` file. First, any current ``task dft`` options are removed and the following settings are added to the end of the file:: task dft task dft property Next, the settings required to calculate the g tensor are defined by inserting the following settings underneath the ``end`` keyword of the ``dft`` section:: relativistic zora on zora:cutoff 1d-30 end property gshift end This requests a property analysis to calculate the g shift tensor using the the zeroth order approximation (ZORA) to the Dirac equation. This approximation is convenient as it supports a wide range of density functionals and is computationally tractable. The calculation can now be run using NWChem. On a local machine, the command for this is simply :guilabel:`nwchem _nwchem.inp`. .. note:: If there are any issues running this, please use the ``_nwchem.inp.reference`` file. Additionally, this calculation should be run in a clean directory to avoid any potential issues. Once the calculation has finished, under the heading **'Total g shift Tensor'** in the NWChem output, there will be a 3x3 matrix, corresponding to the g shift tensor:: Total g shift Tensor 27.9973 -0.0002 -0.0022 -0.0002 27.8769 -0.0032 -0.0022 -0.0032 11.0372 To obtain the g values, matrix operations must be applied. This can be done using the numpy Python module. In the script ``g_calc.py``, numpy is imported using ``import numpy``. Next the g value of a free electron in a vacuum is specified and the g shift tensor is defined as a numpy matrix array. .. literalinclude:: ../../samples/li_mgo/5_li-mgo_epr/g_calc.py :lines: 4-10 Using these parameters, the g tensor can then be obtained. Here, the ``eye3`` variable corresponds to a 3x3 identity matrix and the multiplication constant converts the tensor from units of parts per thousand to parts per million. .. literalinclude:: ../../samples/li_mgo/5_li-mgo_epr/g_calc.py :lines: 17-18 To obtain the g values from the g tensor, the g.g :sup:`T` eigenvalues are calculated and the square root of these are taken. .. literalinclude:: ../../samples/li_mgo/5_li-mgo_epr/g_calc.py :lines: 20-21 This script can then be run using the command :guilabel:`python g_calc.py`. You should find that the theoretical g values are 2.013 and 2.030. Compared to the `experimental values `_ of 2.004 and 2.054, the agreement is sufficient. It is worth highlighting that these results are sensitive to the functional and basis set quality, so using a higher quality basis set could lead to better agreement.