.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_examples_plot_overlap_population_plot_overlap_population.py:
=================================================================
Plotting cyrstal orbital overlap population obtained from lobster
=================================================================
This example shows how to plot overlap population data
See http://www.cohp.de/ for details
.. code-block:: default
import os
import numpy as np
import matplotlib.pyplot as plt
from pdos_overlap.overlap_population import get_example_data
from pdos_overlap.overlap_population import OVERLAP_POPULATION
from pdos_overlap.plotting_tools import set_figure_settings
Load COOPCAR file
-----------------
First we will, get the example data, load a COOPCAR file and use it to
instantiate an OVERLAP_POPULATION object
.. code-block:: default
set_figure_settings('paper')
example_path = get_example_data()
COOPCAR = os.path.join(example_path, 'C2H4/COOPCAR.lobster')
POP = OVERLAP_POPULATION(COOPCAR)
Identify bonding interactions and check for spin
------------------------------------------------
.. code-block:: default
print(POP.interactions)
print(POP.is_spin)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
['No.1:C1->C2(1.3399356553485977)', 'No.2:C1->H3(1.0931450325373071)', 'No.3:C1->H4(1.0932440535076346)', 'No.4:C2->H5(1.093162987441443)', 'No.5:C2->H6(1.0932085731970578)']
True
Obtain projected overlap
------------------------
We projected orbital overlap for the C-C bond and C-H bonds in C2H4
We group the CH bonds and ensure to sum for spins as all electrons are paired
.. code-block:: default
CC_overlap = POP.get_pcoop(interactions=[0], sum_pcoop=False, sum_spin=True)
CH_overlap = POP.get_pcoop(interactions=[1,2,3,4], sum_pcoop=True, sum_spin=True)
Plot the bonding populaiton with respect to the CC and CH bonds
---------------------------------------------------------------
A positive value on the x-axis indicates are greater proportion of states in
in the bond than outside of the bond
.. code-block:: default
plt.figure(figsize=(3,5))
plt.plot(CC_overlap, POP.get_energies(), zorder=3)
plt.plot(CH_overlap, POP.get_energies(), zorder=2)
plt.plot([np.min([CC_overlap, CH_overlap]), np.max([CC_overlap, CH_overlap])]\
,[POP.e_fermi, POP.e_fermi],'k--', zorder=1, linewidth=5)
plt.legend(['C-C overlap population','C-H overlap population','fermi level'],loc='best')
plt.xlabel('Orbital overlap')
plt.ylabel('Energy [eV]')
plt.show()
.. image:: /auto_examples/plot_overlap_population/images/sphx_glr_plot_overlap_population_001.png
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
C:\Users\lansf\Box Sync\Synced_Files\Coding\Python\Github\pDOS_overlap\examples\plot_overlap_population\plot_overlap_population.py:63: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.294 seconds)
.. _sphx_glr_download_auto_examples_plot_overlap_population_plot_overlap_population.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_overlap_population.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_overlap_population.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_