Lobster output files#

This example shows how to analyze the output files produced by Lobster.

Use

abiopen.py FILE

with the --expose or --print option for a command-line interface, and with --notebook to generate a Jupyter notebook from a Lobster FILE.

Note: The code in this notebook requires AbiPy >= 0.6.

Let’s start by importing the basic modules needed for this tutorial.

import warnings
warnings.filterwarnings("ignore")  # Ignore warnings

from abipy import abilab
abilab.enable_notebook() # This line tells AbiPy we are running inside a notebook
import abipy.data as abidata

# This line configures matplotlib to show figures embedded in the notebook.
# Replace `inline` with `notebook` in classic notebook
%matplotlib inline

# Option available in jupyterlab. See https://github.com/matplotlib/jupyter-matplotlib
#%matplotlib widget

How to analyze the COHPCAR file#

# Path to one of the reference file shipped with AbiPy
import os
dirpath = os.path.join(abidata.dirpath, "refs", "lobster_gaas")
filename = os.path.join(dirpath, "GaAs_COHPCAR.lobster.gz")

# Open the COHPCAR.lobster file (same API for COOPCAR.lobster)
cohp_file = abilab.abiopen(filename)
print(cohp_file)
Creating temporary file: /tmp/tmpiz1ow8ekGaAs_COHPCAR.lobster

COHP: Number of energies: 401, from -14.035 to 6.015 (eV) with E_fermi set 0 (was 2.298)
has_partial_projections: True, nsppol: 1
Number of pairs: 2
[0] Ga@0 --> As@1
[1] As@1 --> Ga@0

To plot the COHP averaged over all the specified atom pairs:

cohp_file.plot(title="GaAs COHP");
_images/aa8c91d30bb4c30cfe96e3d1d2735f7680a68bad8bba83ccb38bbca1aa997a98.png

To plot the integrated COHP averaged over all atom pairs:

cohp_file.plot(what="i", title="GaAs integrated COHP");
_images/b46767238d78fa04b8971e516c02059176b6d88e7b24f5e342406b42c1c36cd6.png

To plot the total overlap for all the sites listed in from_site_index:

cohp_file.plot_site_pairs_total(from_site_index=[0, 1], title="COHP total overlap for site index 0");
_images/f86e7262778c422d3756f6b1190d1182fb92503f0618f13868f49b4953fd8604.png

To plot the partial crystal orbital projections for all the sites listed in from_site_index:

cohp_file.plot_site_pairs_partial(from_site_index=[0, 1],
                                  title="COHP with orbital projections from site index 0",
                                  fontsize=6, tight_layout=True);
_images/ef0b8b2d394e6fd0bee2a7563e1b15bdee8e0170f0ddf04e1621b69c884a86e0.png
#cohp_file.plot_average_pairs(with_site_index=[0]);

How to analyze the ICOHPLIST file#

# Path to one of the AbiPy file
dirpath = os.path.join(abidata.dirpath, "refs", "lobster_gaas")
filename = os.path.join(dirpath, "GaAs_ICOHPLIST.lobster.gz")

# Open the ICOHPCAR.lobster file.
icohp_file = abilab.abiopen(filename)
print(icohp_file)
Creating temporary file: /tmp/tmpqznelwgoGaAs_ICOHPLIST.lobster
Number of pairs: 2
 index0  index1 type0 type1  spin  average distance n_bonds   pair
      0       1    Ga    As     0 -4.36062  2.49546    None (0, 1)
      1       0    As    Ga     0 -4.36062  2.49546    None (1, 0)

How to analyze the DOSCAR file#

dirpath = os.path.join(abidata.dirpath, "refs", "lobster_gaas")
filename = os.path.join(dirpath, "GaAs_DOSCAR.lobster.gz")

# Open the ICOHPCAR.lobster file.
doscar = abilab.abiopen(filename)
print(doscar)
Creating temporary file: /tmp/tmph9twzqn9GaAs_DOSCAR.lobster
Number of energies: 401, from -14.035 to 6.015 (eV) with E_fermi set to 0 (was 2.298)
nsppol: 1
Number of sites in projected DOS: 2
0 --> {4s, 4p_y, 4p_z, 4p_x}
1 --> {4s, 4p_y, 4p_z, 4p_x}
doscar.plot();
_images/684866da11d1f9a561dd0e226f35d66b09d971e28b77ad70f119c55016ee199a.png
doscar.plot_pdos_site(site_index=[0, 1]);
_images/d9f780dfeee5f32d38a8828cea9df01f65bf9b3801cbb44879bea4c93d7cf06b.png

Analyzing all Lobster output files with LobsterAnalyzer#

Let’s assume we have a directory with the Lobster output files for COOP, COHP and DOS, and we need to produce plots showing all these results together. In this case, one can use the LobsterAnalyzer object and initialize it from the directory containing the output files:

dirpath = os.path.join(abidata.dirpath, "refs", "lobster_gaas")

# Open the all the lobster files produced in directory dirpath
# with the (optional) prefix GaAs_
lobana = abilab.LobsterAnalyzer.from_dir(dirpath, prefix="GaAs_")
print(lobana.to_string(verbose=1))
================================= COOP File =================================
Name: GaAs_COOPCAR.lobster.gz
Directory: /home/runner/work/abipy_book/abipy_book/abipy/abipy/data/refs/lobster_gaas
Size: 23.04 kB
Access Time: Wed Sep 30 16:03:44 2026
Modification Time: Wed Sep 30 15:58:18 2026
Change Time: Wed Sep 30 15:58:18 2026

COOP: Number of energies: 401, from -14.035 to 6.015 (eV) with E_fermi set 0 (was 2.298)
has_partial_projections: True, nsppol: 1
Number of pairs: 2
[0] Ga@0 --> As@1
[1] As@1 --> Ga@0

================================= COHP File =================================
Name: GaAs_COHPCAR.lobster.gz
Directory: /home/runner/work/abipy_book/abipy_book/abipy/abipy/data/refs/lobster_gaas
Size: 24.06 kB
Access Time: Wed Sep 30 16:03:43 2026
Modification Time: Wed Sep 30 15:58:18 2026
Change Time: Wed Sep 30 15:58:18 2026

COHP: Number of energies: 401, from -14.035 to 6.015 (eV) with E_fermi set 0 (was 2.298)
has_partial_projections: True, nsppol: 1
Number of pairs: 2
[0] Ga@0 --> As@1
[1] As@1 --> Ga@0

============================== ICHOHPLIST File ==============================
Number of pairs: 2
 index0  index1 type0 type1  spin  average distance n_bonds   pair
      0       1    Ga    As     0 -4.36062  2.49546    None (0, 1)
      1       0    As    Ga     0 -4.36062  2.49546    None (1, 0)

=============================== Lobster DOSCAR ===============================
Number of energies: 401, from -14.035 to 6.015 (eV) with E_fermi set to 0 (was 2.298)
nsppol: 1
Number of sites in projected DOS: 2
0 --> {4s, 4p_y, 4p_z, 4p_x}
1 --> {4s, 4p_y, 4p_z, 4p_x}

To plot COOP + COHP + DOS, use:

lobana.plot(title="COOP + COHP + DOS");
_images/dc218f8e8fdd7ab302df31af2f00b85c51f9be3368f5a5a04b7cdefd2c8de422.png

To plot the COHP for all the sites in from_site_index together with the Lobster DOS:

lobana.plot_coxp_with_dos(from_site_index=[0, 1]);
_images/fc1a1c924a4f0526461fe8f9456fe1017642a63c167ea50ff9bdd1ed4db7de8e.png
# Plot orbital projections.
lobana.plot_coxp_with_dos(from_site_index=[0], with_orbitals=True);
_images/4d50e36940e7f4fdfbe2a10e7f692d29d83fdc056f0c1b52357c1f1ae0f4a8a2.png
#lobana.plot_with_ebands(ebands="out_GSR.nc")