def test_tot_dos(self): tot_dos = self.bztInterp.get_dos(T=200,npts_mu = 100) self.assertIsNotNone(tot_dos) self.assertEqual(len(tot_dos.energies),100) self.assertAlmostEqual(tot_dos.densities[Spin.up][0],1.42859939,5) dos_up = self.bztI_up.get_dos(partial_dos=False,npts_mu = 100) dos_dn = self.bztI_dn.get_dos(partial_dos=False,npts_mu = 100) cdos = merge_up_down_doses(dos_up,dos_dn) self.assertAlmostEqual(cdos.densities[Spin.down][50],92.87836778,5) self.assertAlmostEqual(cdos.densities[Spin.up][45],9.564067,5) self.assertEqual(len(cdos.energies),100)
def test_tot_dos(self): tot_dos = self.bztInterp.get_dos(T=200, npts_mu=100) self.assertIsNotNone(tot_dos) self.assertEqual(len(tot_dos.energies), 100) self.assertAlmostEqual(tot_dos.densities[Spin.up][0], 1.42859939, 5) dos_up = self.bztI_up.get_dos(partial_dos=False, npts_mu=100) dos_dn = self.bztI_dn.get_dos(partial_dos=False, npts_mu=100) cdos = merge_up_down_doses(dos_up, dos_dn) self.assertAlmostEqual(cdos.densities[Spin.down][50], 92.87836778, 5) self.assertAlmostEqual(cdos.densities[Spin.up][45], 9.564067, 5) self.assertEqual(len(cdos.energies), 100)
def dos_from_boltztrap(bs_dict, energy_grid=0.005, avoid_projections=False): """ Function to just interpolate a DOS from a bandstructure using BoltzTrap Args: bs_dict(dict): A MSONable dictionary for a bandstructure object energy_grid(float): the energy_grid spacing for the DOS in eV avoid_projections(bool): don't interpolate projections even if present """ bs = BandStructure.from_dict(bs_dict) st = bs.structure energy_grid = energy_grid * units.eV projections = True if bs.projections and not avoid_projections else False if bs.is_spin_polarized: data_up = BandstructureLoader(bs, st, spin=1) data_dn = BandstructureLoader(bs, st, spin=-1) min_bnd = min(data_up.ebands.min(), data_dn.ebands.min()) max_bnd = max(data_up.ebands.max(), data_dn.ebands.max()) data_up.set_upper_lower_bands(min_bnd, max_bnd) data_dn.set_upper_lower_bands(min_bnd, max_bnd) bztI_up = BztInterpolator(data_up, energy_range=np.inf, curvature=False) bztI_dn = BztInterpolator(data_dn, energy_range=np.inf, curvature=False) npts_mu = int((max_bnd - min_bnd) / energy_grid) dos_up = bztI_up.get_dos(partial_dos=projections, npts_mu=npts_mu) dos_dn = bztI_dn.get_dos(partial_dos=projections, npts_mu=npts_mu) cdos = merge_up_down_doses(dos_up, dos_dn) else: data = BandstructureLoader(bs, st) min_bnd = min(data.ebands.min(), data.ebands.min()) max_bnd = max(data.ebands.max(), data.ebands.max()) npts_mu = int((max_bnd - min_bnd) / energy_grid) bztI = BztInterpolator(data, energy_range=np.inf, curvature=False) cdos = bztI.get_dos(partial_dos=projections, npts_mu=npts_mu) return cdos.as_dict()