def main(args, parser): atoms = read(args.calculation) cell = atoms.get_cell() calc = atoms.calc bzkpts = calc.get_bz_k_points() ibzkpts = calc.get_ibz_k_points() efermi = calc.get_fermi_level() nibz = len(ibzkpts) nspins = 1 + int(calc.get_spin_polarized()) eps = np.array([[calc.get_eigenvalues(kpt=k, spin=s) for k in range(nibz)] for s in range(nspins)]) if not args.quiet: print('Spins, k-points, bands: {}, {}, {}'.format(*eps.shape)) try: size, offset = get_monkhorst_pack_size_and_offset(bzkpts) except ValueError: path = ibzkpts else: if not args.quiet: print('Interpolating from Monkhorst-Pack grid (size, offset):') print(size, offset) if args.path is None: err = 'Please specify a path!' try: cs = crystal_structure_from_cell(cell) except ValueError: err += ('\nGPAW cannot autimatically ' 'recognize this crystal structure') else: from ase.dft.kpoints import special_paths kptpath = special_paths[cs] err += ('\nIt looks like you have a {} crystal structure.' '\nMaybe you want its special path:' ' {}'.format(cs, kptpath)) parser.error(err) bz2ibz = calc.get_bz_to_ibz_map() path = bandpath(args.path, atoms.cell, args.points)[0] icell = atoms.get_reciprocal_cell() eps = monkhorst_pack_interpolate(path, eps.transpose(1, 0, 2), icell, bz2ibz, size, offset) eps = eps.transpose(1, 0, 2) emin, emax = (float(e) for e in args.range) bs = BandStructure(atoms.cell, path, eps, reference=efermi) bs.plot(emin=emin, emax=emax)
28.6214, 29.1794, 29.1794, 29.6229, 30.5584, 32.8451 ], [ -3.0876, -0.8863, 3.0037, 3.0037, 6.2623, 6.7765, 14.7728, 14.7728, 17.1201, 17.4077, 17.8504, 17.8504, 19.3349, 19.8627, 22.8644, 23.6249, 23.6249, 24.7429, 27.5978, 27.9651, 27.9651, 29.0422, 30.4427, 32.3347 ], [ -2.5785, -1.4744, 2.9437, 2.9437, 6.3021, 6.5565, 15.41, 15.41, 17.2036, 17.2036, 17.7555, 18.0538, 19.0775, 19.1146, 23.7456, 24.5645, 24.5645, 24.9649, 26.8166, 26.8167, 26.9285, 27.9975, 30.8961, 31.8679 ], [ -2.0397, -2.0397, 2.9235, 2.9235, 6.399, 6.3991, 15.775, 15.775, 16.8298, 16.8298, 18.4119, 18.4119, 18.6257, 18.6257, 24.5738, 24.5739, 25.3583, 25.3583, 25.9521, 25.9521, 27.1466, 27.1466, 31.3822, 31.3825 ]]]) # Update to new band structure stuff lattice = atoms.cell.get_bravais_lattice() bandpath = lattice.bandpath('WGX', npoints=30) maxerr = np.abs(bandpath.kpts - kpts).max() assert maxerr < 1e-5 bs = BandStructure(bandpath, energies=energies, reference=ref) bs.plot(emin=-13, filename='vasp_si_bandstructure.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() print(bs.labels) bs.write("hmm.json") bs = BandStructure(filename="hmm.json") print(bs.labels) assert "".join(bs.labels) == "GXWKGLUWLKUX" import matplotlib matplotlib.use("Agg", warn=False) bs.plot(emax=10, filename="bs.png")