.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated_examples/1-ase-simulations/plot_dos_gap.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_generated_examples_1-ase-simulations_plot_dos_gap.py: 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 :py:class:`~upet.calculator.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. .. GENERATED FROM PYTHON SOURCE LINES 12-39 .. image-sg:: /generated_examples/1-ase-simulations/images/sphx_glr_plot_dos_gap_001.png :alt: Density of States for Bulk Silicon :srcset: /generated_examples/1-ase-simulations/images/sphx_glr_plot_dos_gap_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 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) | .. code-block:: Python 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() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.936 seconds) .. _sphx_glr_download_generated_examples_1-ase-simulations_plot_dos_gap.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_dos_gap.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_dos_gap.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_dos_gap.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_