.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_wfk.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_wfk.py: Wavefunction file ================= This example shows how to analyze the wavefunctions stored in the WFK.nc file. .. GENERATED FROM PYTHON SOURCE LINES 9-49 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/images/sphx_glr_plot_wfk_001.png :alt: plot wfk :srcset: /gallery/images/sphx_glr_plot_wfk_001.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/images/sphx_glr_plot_wfk_002.png :alt: plot wfk :srcset: /gallery/images/sphx_glr_plot_wfk_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none ================================= File Info ================================= Name: si_nscf_WFK.nc Directory: /home/runner/work/abipy/abipy/abipy/data/refs/si_ebands Size: 389.84 kB Access Time: Wed Jul 2 08:07:29 2025 Modification Time: Wed Jul 2 08:00:59 2025 Change Time: Wed Jul 2 08:00:59 2025 ================================= Structure ================================= Full Formula (Si2) Reduced Formula: Si abc : 3.866975 3.866975 3.866975 angles: 60.000000 60.000000 60.000000 pbc : True True True Sites (2) # SP a b c --- ---- ---- ---- ---- 0 Si 0 0 0 1 Si 0.25 0.25 0.25 Abinit Spacegroup: spgid: 0, num_spatial_symmetries: 48, has_timerev: True, symmorphic: True ============================== Electronic Bands ============================== Number of electrons: 8.0, Fermi level: 5.598 (eV) nsppol: 1, nkpt: 14, mband: 8, nspinor: 1, nspden: 1 smearing scheme: none (occopt 1), tsmear_eV: 0.272, tsmear Kelvin: 3157.7 Direct gap: Energy: 2.532 (eV) Initial state: spin: 0, kpt: $\Gamma$ [+0.000, +0.000, +0.000], band: 3, eig: 5.598, occ: 2.000 Final state: spin: 0, kpt: $\Gamma$ [+0.000, +0.000, +0.000], band: 4, eig: 8.130, occ: 0.000 Fundamental gap: Energy: 0.524 (eV) Initial state: spin: 0, kpt: $\Gamma$ [+0.000, +0.000, +0.000], band: 3, eig: 5.598, occ: 2.000 Final state: spin: 0, kpt: [+0.000, +0.429, +0.429], band: 4, eig: 6.123, occ: 0.000 Bandwidth: 11.856 (eV) Valence maximum located at kpt index 6: spin: 0, kpt: $\Gamma$ [+0.000, +0.000, +0.000], band: 3, eig: 5.598, occ: 2.000 Conduction minimum located at kpt index 12: spin: 0, kpt: [+0.000, +0.429, +0.429], band: 4, eig: 6.123, occ: 0.000 TIP: Use `--verbose` to print k-point coordinates with more digits PWWaveFunction: nspinor: 1, spin: 0, band: 0 : kpoint: L [+0.500, +0.000, +0.000], ecut: 6.000000, npw: 180, istwfk: 1 Mesh3D: nx=18, ny=18, nz=18 | .. code-block:: Python from abipy.abilab import abiopen import abipy.data as abidata # Open the DEN.nc file ncfile = abiopen(abidata.ref_file("si_nscf_WFK.nc")) print(ncfile) # The DEN file has a `Structure` an `ElectronBands` object and wavefunctions. #print(ncfile.structure) # To plot the KS eigenvalues. #ncfile.ebands.plot() # Extract the wavefunction for the first spin, the first band and k=[0.5, 0, 0] wave = ncfile.get_wave(spin=0, kpoint=[0.5, 0, 0], band=0) print(wave) # This is equivalent to #wave = ncfile.get_wave(spin=0, kpoint=0, band=0) # because [0.5, 0, 0] is the first k-point in the WFK file # To visualize the total charge wih vesta #visu = wave.visualize_ur2("vesta"); visu() # To plot the wavefunction along the line connecting # the first and the second in the structure: #wave.plot_line(point1=0, point2=1) #wave.plot_line(point1=0, point2=1, with_krphase=True) # alternatively, one can define the line in terms of two points # in fractional coordinates: wave.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], with_krphase=False, num=400) wave.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], with_krphase=True, num=400) # To plot the wavefunction along the lines connect the firt atom in the structure # and all the neighbors within a sphere of radius 3 Angstrom: #wave.plot_line_neighbors(site_index=0, radius=3) ncfile.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.472 seconds) .. _sphx_glr_download_gallery_plot_wfk.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_wfk.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_wfk.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_wfk.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_