def test_bandstructure(plt):
    from ase.build import bulk
    from ase.calculators.test import FreeElectrons
    from ase.dft.kpoints import special_paths
    from ase.dft.band_structure import BandStructure

    a = bulk('Cu')
    path = special_paths['fcc']
    a.calc = FreeElectrons(nvalence=1,
                           kpts={'path': path, 'npoints': 200})
    a.get_potential_energy()
    bs = a.calc.band_structure()
    coords, labelcoords, labels = bs.get_labels()
    print(labels)
    bs.write('hmm.json')
    bs = BandStructure.read('hmm.json')
    coords, labelcoords, labels = bs.get_labels()
    print(labels)
    assert ''.join(labels) == 'GXWKGLUWLKUX'
    bs.plot(emax=10, filename='bs.png')
def test_bandstructure_json():
    from ase.build import bulk
    from ase.dft.band_structure import calculate_band_structure, BandStructure
    from ase.io.jsonio import read_json
    from ase.calculators.test import FreeElectrons

    atoms = bulk('Au')
    lat = atoms.cell.get_bravais_lattice()
    path = lat.bandpath(npoints=100)

    atoms.calc = FreeElectrons()

    bs = calculate_band_structure(atoms, path)
    bs.write('bs.json')
    bs.path.write('path.json')

    bs1 = read_json('bs.json')
    bs2 = BandStructure.read('bs.json')
    path1 = read_json('path.json')
    assert type(bs1) == type(bs)  # noqa
    assert type(bs2) == type(bs)  # noqa
    assert type(path1) == type(bs.path)  # noqa
Exemple #3
0
import matplotlib
from ase.build import bulk
from ase.calculators.test import FreeElectrons
from ase.dft.kpoints import special_paths
from ase.dft.band_structure import BandStructure

a = bulk('Cu')
path = special_paths['fcc']
a.calc = FreeElectrons(nvalence=1, kpts={'path': path, 'npoints': 200})
a.get_potential_energy()
bs = a.calc.band_structure()
coords, labelcoords, labels = bs.get_labels()
print(labels)
bs.write('hmm.json')
bs = BandStructure.read('hmm.json')
coords, labelcoords, labels = bs.get_labels()
print(labels)
assert ''.join(labels) == 'GXWKGLUWLKUX'
matplotlib.use('Agg', warn=False)
bs.plot(emax=10, filename='bs.png')
from ase.build import bulk
from ase.calculators.test import FreeElectrons
from ase.dft.kpoints import special_paths
from ase.dft.band_structure import BandStructure

a = bulk('Cu')
path = special_paths['fcc']
a.calc = FreeElectrons(nvalence=1,
                       kpts={'path': path, 'npoints': 200})
a.get_potential_energy()
bs = a.calc.band_structure()
coords, labelcoords, labels = bs.get_labels()
print(labels)
bs.write('hmm.json')
bs = BandStructure.read('hmm.json')
coords, labelcoords, labels = bs.get_labels()
print(labels)
assert ''.join(labels) == 'GXWKGLUWLKUX'
import matplotlib
matplotlib.use('Agg', warn=False)
bs.plot(emax=10, filename='bs.png')