.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_den.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_den.py: Density ======= This example shows how to analyze the electronic density stored in the DEN.nc file. .. GENERATED FROM PYTHON SOURCE LINES 9-18 .. code-block:: default from abipy.abilab import abiopen import abipy.data as abidata # Open the DEN.nc file ncfile = abiopen(abidata.ref_file("si_DEN.nc")) # The DEN file has a `Density`, a `Structure` and an `ElectronBands` object print(ncfile.structure) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Full Formula (Si2) Reduced Formula: Si abc : 3.866975 3.866975 3.866975 angles: 60.000000 60.000000 60.000000 Sites (2) # SP a b c --- ---- ---- ---- ---- 0 Si 0 0 0 1 Si 0.25 0.25 0.25 Abinit Spacegroup: spgid: 227, num_spatial_symmetries: 48, has_timerev: True, symmorphic: True .. GENERATED FROM PYTHON SOURCE LINES 19-20 To plot the KS eigenvalues. .. GENERATED FROM PYTHON SOURCE LINES 20-28 .. code-block:: default ncfile.ebands.plot() density = ncfile.density print(density) # To visualize the total charge wih vesta #visu = density.visualize("vesta"); visu() .. image:: /gallery/images/sphx_glr_plot_den_001.png :alt: plot den :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Density: nspinor: 1, nsppol: 1, nspden: 1 Mesh3D: nx=18, ny=18, nz=18 .. GENERATED FROM PYTHON SOURCE LINES 29-31 To plot the density along the line connecting the first and the second in the structure: .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: default density.plot_line(point1=0, point2=1) .. image:: /gallery/images/sphx_glr_plot_den_002.png :alt: plot den :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 34-36 alternatively, one can define the line in terms of two points in fractional coordinates: .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: default density.plot_line(point1=[0, 0, 0], point2=[2.25, 2.25, 2.25], num=300) .. image:: /gallery/images/sphx_glr_plot_den_003.png :alt: plot den :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 39-41 To plot the density along the lines connect the firt atom in the structure and all the neighbors within a sphere of radius 3 Angstrom: .. GENERATED FROM PYTHON SOURCE LINES 41-42 .. code-block:: default density.plot_line_neighbors(site_index=0, radius=3) .. image:: /gallery/images/sphx_glr_plot_den_004.png :alt: Si, [0.25 0.25 0.25], dist=2.368 A, Si, [ 0.25 0.25 -0.75], dist=2.368 A, Si, [-0.75 0.25 0.25], dist=2.368 A, Si, [ 0.25 -0.75 0.25], dist=2.368 A :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.693 seconds) .. _sphx_glr_download_gallery_plot_den.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/abinit/abipy/gh-pages?filepath=notebooks/gallery/plot_den.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_den.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_den.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_