Sumo

2.4.0.post1 · active · verified Fri Apr 17

Sumo provides heavy-weight plotting tools specifically designed for analyzing ab initio solid-state calculations. It focuses on generating high-quality visualizations for electronic band structures, density of states (DOS), and phonon properties, often integrating seamlessly with `pymatgen` objects. The current version is 2.4.0.post1, and the library maintains an active release cadence, frequently addressing compatibility with its core dependencies like `pymatgen` and `phonopy`.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `sumo.plotting` functions for a band structure and density of states. In a real application, the `BandStructure` and `Dos` objects would typically be loaded from DFT calculation outputs using `pymatgen` parsers (e.g., `pymatgen.io.vasp.Vasprun`). Sumo then takes these `pymatgen` objects to generate publication-quality plots. Note that `matplotlib.pyplot.close()` is used to prevent figures from blocking execution in environments without an active GUI.

import os
from pymatgen.electronic_structure.band_structure import BandStructure, Kpoint
from pymatgen.electronic_structure.dos import Dos, CompleteDos
from sumo.plotting import plot_band, plot_dos
import matplotlib.pyplot as plt
import numpy as np

# --- Create dummy data for demonstration --- #
# In a real scenario, these would come from parsing DFT output (e.g., Vasprun.from_xml)

# Dummy BandStructure object
kpoints = [Kpoint([0,0,0], 0, '$\Gamma$'), Kpoint([0.5,0,0], 0.5, 'X')]
eig_val = {('spin_up', 0): np.array([[-1.0, -0.5], [0.5, 1.0]]), 
           ('spin_down', 0): np.array([[-1.1, -0.6], [0.4, 0.9]])}
efermi = 0.0
bs = BandStructure(kpoints, eig_val, efermi, structure=None, labels_dict={'G': [0,0,0], 'X': [0.5,0,0]})

# Dummy Dos object
energies = np.linspace(-2.0, 2.0, 200)
total_densities = np.exp(-(energies - 0.5)**2 / 0.5) + np.exp(-(energies + 0.5)**2 / 0.5)
tdos = Dos(efermi, energies, total_densities)
cdos = CompleteDos(None, tdos.energies, {'total': tdos.densities})

print("Plotting dummy band structure...")
fig_bs, ax_bs = plot_band(bs, dpi=150)
# To save: fig_bs.savefig("band_structure.png")
plt.close(fig_bs) # Close figure to avoid display issues in non-interactive environments
print("Dummy band structure plot generated and closed.")

print("Plotting dummy density of states...")
fig_dos, ax_dos = plot_dos(cdos, dpi=150)
# To save: fig_dos.savefig("dos.png")
plt.close(fig_dos)
print("Dummy DOS plot generated and closed.")

view raw JSON →