Skip to content

Commit

Permalink
Add plot_gwr.py example
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Jan 23, 2025
1 parent 0e8561b commit e9a6c52
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion abipy/electrons/gwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ def yield_figs(self, **kwargs): # pragma: no cover
# TODO
for spin in range(self.nsppol):
for ik, kpoint in enumerate(self.sigma_kpoints):
kws = dict(spin=spin, include_bands = "gaps", show=False)
kws = dict(spin=spin, include_bands="gap", show=False)
yield self.plot_sigma_imag_axis(ik, **kws)
yield self.plot_sigma_real_axis(ik, **kws)

Expand Down
37 changes: 37 additions & 0 deletions abipy/examples/plot/plot_gwr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
r"""
Visualization of GWR results
============================
This example shows how to visualize the results produced by the GWR code.
"""
from abipy import abilab
import abipy.data as abidata

#%%
# Open the GWR.nc file
# Here we use one of the GSR files shipped with abipy.
# Replace filename with the path to your GSR file or your WFK file.

from abipy.electrons.gwr import GwrFile
gwr = GwrFile(abidata.ref_file("t01o_DS3_GWR.nc"))
print(gwr)

kpoint = 0
include_bands = "gap"

#%%
# Plot Sigma_nk(iw) along the imaginary axis for given k-point.
gwr.plot_sigma_imag_axis(kpoint=kpoint, include_bands=include_bands)

#%%
# Plot Sigma_nk(iw) along the real axis for given k-point.
gwr.plot_sigma_real_axis(kpoint=kpoint)

#%%
# Plot the spectral function A(w) along the real axis.
gwr.plot_spectral_functions()

#%%
# Plot qp-data versus KS energy
gwr.plot_qps_vs_e0()
7 changes: 3 additions & 4 deletions abipy/examples/plot/plot_xrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# Also available via the `abistruct.py xrd FILE` command line interface.
structure = abilab.Structure.from_file(abidata.ref_file("si_scf_WFK.nc"))

import sys
if sys.version[0:3] > '2.7':
# pmg broke py compatibility
structure.plot_xrd()
#%%
# Plot the XRD spectrum.
structure.plot_xrd()

0 comments on commit e9a6c52

Please sign in to comment.