From e5bb2d1b80d9f08a19134de35d851b4fc151f443 Mon Sep 17 00:00:00 2001 From: "Oleg E. Peil" Date: Tue, 10 May 2016 11:48:28 +0200 Subject: [PATCH] Fixed a bug in the calculation of the total energy In the calculation of the Hamiltonian correction to the total energy the arrays were not always aligned if the number of bands varied inside the energy window. --- python/sumk_dft.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/sumk_dft.py b/python/sumk_dft.py index 1afdb959..343ce33a 100644 --- a/python/sumk_dft.py +++ b/python/sumk_dft.py @@ -1233,8 +1233,9 @@ class SumkDFT: dens[bname] += self.bz_weights[ik] * G_latt_iw[bname].total_density() if dm_type == 'vasp': # In 'vasp'-mode subtract the DFT density matrix - diag_inds = numpy.diag_indices(self.n_orbitals[ik, ntoi[bname]]) - deltaN[bname][ik][diag_inds] -= dens_mat_dft[bname][ik] + nb = self.n_orbitals[ik, ntoi[bname]] + diag_inds = numpy.diag_indices(nb) + deltaN[bname][ik][diag_inds] -= dens_mat_dft[bname][ik][:nb] dens[bname] -= self.bz_weights[ik] * dens_mat_dft[bname][ik].sum().real isp = ntoi[bname] b1, b2 = self.band_window[isp][ik, :2]