Note
Go to the end to download the full example code.
Density of States (DOS) and Bandgap calculations with UPETΒΆ
Single-point evaluation of a bulk silicon cell with PET-MAD-DOS. The two silicon atoms
are displaced off their equilibrium positions and the DOS and bandgap is computed using
the PETMADDOSCalculator. Additionally, we showcase the
performance of the denoising algorithm. The DOS is plotted with and without denoising,
and the predicted bandgap is printed for both cases. The denoised DOS is less
oscillatory and non-negative compared to the raw DOS.

Downloading PET-MAD-DOS model version: 1.0
/home/runner/work/upet/upet/.tox/docs/lib/python3.13/site-packages/metatrain/utils/io.py:228: UserWarning: trying to upgrade an old model checkpoint with unknown version, this might fail and require manual modifications
warnings.warn(
/home/runner/work/upet/upet/.tox/docs/lib/python3.13/site-packages/metatomic_ase/_neighbors.py:78: UserWarning: `compute_requested_neighbors_from_options` is deprecated and will be removed in a future version. Please use `neighbor_lists_for_model` to get the calculators and call them directly.
vesin.metatomic.compute_requested_neighbors_from_options(
The keys in results is: dict_keys(['dos_raw', 'fermi_level', 'bandgap', 'dos_denoised'])
Predicted bandgap: 0.5021 eV
True Bandgap: 0.4667 eV (Under the same DFT paramters)
import matplotlib.pyplot as plt
import numpy as np
import torch
from ase.build import bulk
from upet.calculator import PETMADDOSCalculator
atoms = bulk("Si", cubic=True, a=5.43, crystalstructure="diamond")
calculator = PETMADDOSCalculator(version="latest", device="cpu")
with torch.no_grad():
results = calculator.calculate(atoms)
print(f"The keys in results is: {results.keys()}")
print(f"Predicted bandgap: {results['bandgap']:.4f} eV")
print("True Bandgap: 0.4667 eV (Under the same DFT paramters)")
energy_grid = np.arange(len(results["dos_raw"])) * calculator.energy_interval
plt.plot(energy_grid, results["dos_raw"], label="Raw DOS")
plt.plot(energy_grid, results["dos_denoised"], label="Denoised DOS")
plt.xlabel("Energy (eV)")
plt.ylabel("Density of States (States/eV)")
plt.title("Density of States for Bulk Silicon")
plt.legend()
plt.show()
Total running time of the script: (0 minutes 9.936 seconds)