def test_bandstructure_transform_mcl(testdir):
    # Test that bandpath() correctly transforms the band path from
    # reference (canonical) cell to actual cell provided by user.

    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
예제 #2
0
def test_bands(siesta_factory):
    atoms = bulk('Si')
    path = atoms.cell.bandpath('GXWK', density=10)
    atoms.calc = siesta_factory.calc(kpts=[2, 2, 2])
    bs = calculate_band_structure(atoms, path)
    print(bs)
    bs.write('bs.json')
예제 #3
0
def test_lattice_bandstructure(testdir, 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))
예제 #4
0
    def free_electron_band_structure(
            self, **kwargs) -> 'ase.spectrum.band_structure.BandStructure':
        """Return band structure of free electrons for this bandpath.

        Keyword arguments are passed to
        :class:`~ase.calculators.test.FreeElectrons`.

        This is for mostly testing and visualization."""
        from ase import Atoms
        from ase.calculators.test import FreeElectrons
        from ase.spectrum.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
예제 #5
0
def test_bandstructure_json(testdir):
    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
def test_bandstructure_json():
    from ase.build import bulk
    from ase.spectrum.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