コード例 #1
0
def test_bands():
    atoms = bulk('Si')
    path = atoms.cell.bandpath('GXWK', density=10)
    atoms.calc = NWChem(kpts=[2, 2, 2])
    bs = calculate_band_structure(atoms, path)
    print(bs)
    bs.write('bs.json')
コード例 #2
0
def test_bandstructure_transform_mcl():
    # Test that bandpath() correctly transforms the band path from
    # reference (canonical) cell to actual cell provided by user.
    import numpy as np
    from ase import Atoms
    from ase.utils import workdir
    from ase.dft.band_structure import calculate_band_structure
    from ase.calculators.test import FreeElectrons
    from ase.cell import Cell

    def _atoms(cell):
        atoms = Atoms(cell=cell, pbc=True)
        atoms.calc = FreeElectrons()
        return atoms


    # MCL with beta > 90, which is a common convention -- but ours is
    # alpha < 90.  We want the bandpath returned by that cell to yield the
    # exact same band structure as our own (alpha < 90) version of the
    # same cell.
    cell = Cell.new([3., 5., 4., 90., 110., 90.])
    lat = cell.get_bravais_lattice()

    density = 10.0
    cell0 = lat.tocell()
    path0 = lat.bandpath(density=density)

    print(cell.cellpar().round(3))
    print(cell0.cellpar().round(3))

    with workdir('files', mkdir=True):
        bs = calculate_band_structure(_atoms(cell),
                                      cell.bandpath(density=density))
        bs.write('bs.json')
        # bs.plot(emin=0, emax=20, filename='fig.bs.svg')

        bs0 = calculate_band_structure(_atoms(cell0), path0)
        bs0.write('bs0.json')
        # bs0.plot(emin=0, emax=20, filename='fig.bs0.svg')

    maxerr = np.abs(bs.energies - bs0.energies).max()
    assert maxerr < 1e-12, maxerr
コード例 #3
0
    def free_electron_band_structure(self, **kwargs):
        """Return band structure of free electrons for this bandpath.

        This is for mostly testing."""
        from ase import Atoms
        from ase.calculators.test import FreeElectrons
        from ase.dft.band_structure import calculate_band_structure
        atoms = Atoms(cell=self.cell, pbc=True)
        atoms.calc = FreeElectrons(**kwargs)
        bs = calculate_band_structure(atoms, path=self)
        return bs
コード例 #4
0
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))
コード例 #5
0
ファイル: test_bands.py プロジェクト: martin-stoehr/ase-devel
def test_bands():
    from ase.build import bulk
    from ase.calculators.siesta import Siesta
    from ase.utils import workdir
    from ase.dft.band_structure import calculate_band_structure

    atoms = bulk('Si')
    with workdir('files', mkdir=True):
        path = atoms.cell.bandpath('GXWK', density=10)
        atoms.calc = Siesta(kpts=[2, 2, 2])
        bs = calculate_band_structure(atoms, path)
        print(bs)
        bs.write('bs.json')
コード例 #6
0
ファイル: bandstructure_many.py プロジェクト: wes-amat/ase
def test():
    ax = plt.gca()

    for i, lat in enumerate(all_variants()):
        if lat.ndim == 2:
            break
        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))
        bs.plot(ax=ax, emin=0, emax=20, filename='fig.{}.png'.format(xid))
        ax.clear()
コード例 #7
0
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
コード例 #8
0
from ase.build import bulk
from ase.calculators.siesta import Siesta
from ase.utils import workdir
from ase.dft.band_structure import calculate_band_structure

atoms = bulk('Si')
with workdir('files', mkdir=True):
    path = atoms.cell.bandpath('GXWK', density=10)
    atoms.calc = Siesta(kpts=[2, 2, 2])
    bs = calculate_band_structure(atoms, path)
    print(bs)
    bs.write('bs.json')
コード例 #9
0
    atoms = Atoms(cell=cell, pbc=True)
    atoms.calc = FreeElectrons()
    return atoms


# MCL with beta > 90, which is a common convention -- but ours is
# alpha < 90.  We want the bandpath returned by that cell to yield the
# exact same band structure as our own (alpha < 90) version of the
# same cell.
cell = Cell.new([3., 5., 4., 90., 110., 90.])
lat = cell.get_bravais_lattice()

density = 10.0
cell0 = lat.tocell()
path0 = lat.bandpath(density=density)

print(cell.cellpar().round(3))
print(cell0.cellpar().round(3))

with workdir('files', mkdir=True):
    bs = calculate_band_structure(_atoms(cell), cell.bandpath(density=density))
    bs.write('bs.json')
    # bs.plot(emin=0, emax=20, filename='fig.bs.svg')

    bs0 = calculate_band_structure(_atoms(cell0), path0)
    bs0.write('bs0.json')
    # bs0.plot(emin=0, emax=20, filename='fig.bs0.svg')

maxerr = np.abs(bs.energies - bs0.energies).max()
assert maxerr < 1e-12, maxerr