File: test_bandstructure_many.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (22 lines) | stat: -rw-r--r-- 854 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest
from ase.calculators.test import FreeElectrons
from ase.lattice import all_variants
from ase.spectrum.band_structure import calculate_band_structure
from ase import Atoms


@pytest.mark.parametrize("i, lat",
                         [pytest.param(i, lat, id=lat.variant)
                          for i, lat in enumerate(all_variants())
                          if lat.ndim == 3])
def test_lattice_bandstructure(i, lat, figure):
    xid = '{:02d}.{}'.format(i, lat.variant)
    path = lat.bandpath(density=10)
    path.write('path.{}.json'.format(xid))
    atoms = Atoms(cell=lat.tocell(), pbc=True)
    atoms.calc = FreeElectrons(nvalence=0, kpts=path.kpts)
    bs = calculate_band_structure(atoms, path)
    bs.write('bs.{}.json'.format(xid))

    ax = figure.gca()
    bs.plot(ax=ax, emin=0, emax=20, filename='fig.{}.png'.format(xid))