Coverage for gpaw/new/lcao/ibzwfs.py: 48%
29 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-19 00:19 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-19 00:19 +0000
1from math import pi
2from gpaw.new.ibzwfs import IBZWaveFunctions
3from gpaw.new.density import Density
4from gpaw.core.matrix import MatrixWithNoData
7class LCAOIBZWaveFunctions(IBZWaveFunctions):
8 def has_wave_functions(self):
9 return not isinstance(self.wfs_qs[0][0].C_nM, MatrixWithNoData)
11 def move(self, relpos_ac, atomdist):
12 from gpaw.new.lcao.builder import tci_helper
14 super().move(relpos_ac, atomdist)
16 for wfs in self:
17 basis = wfs.basis
18 setups = wfs.setups
19 break
20 basis.set_positions(relpos_ac)
21 myM = (basis.Mmax + self.band_comm.size - 1) // self.band_comm.size
22 basis.set_matrix_distribution(
23 min(self.band_comm.rank * myM, basis.Mmax),
24 min((self.band_comm.rank + 1) * myM, basis.Mmax))
26 S_qMM, T_qMM, P_qaMi, tciexpansions, tci_derivatives = tci_helper(
27 basis, self.ibz, self.domain_comm, self.band_comm, self.kpt_comm,
28 relpos_ac, atomdist,
29 self.grid, self.dtype, setups)
31 for wfs in self:
32 wfs.tci_derivatives = tci_derivatives
33 wfs.S_MM = S_qMM[wfs.q]
34 wfs.T_MM = T_qMM[wfs.q]
35 wfs.P_aMi = P_qaMi[wfs.q]
37 def normalize_density(self, density: Density) -> None:
38 """Normalize density.
40 Basis functions may extend outside box!
41 """
42 pseudo_charge = density.nt_sR.integrate().sum()
43 ccc_aL = density.calculate_compensation_charge_coefficients()
44 comp_charge = (4 * pi)**0.5 * sum(float(ccc_L[0])
45 for ccc_L in ccc_aL.values())
46 comp_charge = ccc_aL.layout.atomdist.comm.sum_scalar(comp_charge)
47 density.nt_sR.data *= -comp_charge / pseudo_charge