Coverage for gpaw/new/hamiltonian.py: 80%

20 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-20 00:19 +0000

1from __future__ import annotations 

2 

3import numpy as np 

4from gpaw.core import UGArray 

5from gpaw.core.arrays import DistributedArrays as XArray 

6 

7 

8class Hamiltonian: 

9 band_local = True 

10 # Used for knowing if wavefunctions can be sliced 

11 # along bands, when applying the hamiltonian. 

12 

13 def apply(self, 

14 vt_sR: UGArray, 

15 dedtaut_sR: UGArray | None, 

16 ibzwfs, 

17 D_asii, 

18 psit_nG: XArray, 

19 out: XArray, 

20 spin: int) -> XArray: 

21 self.apply_local_potential(vt_sR[spin], psit_nG, out) 

22 if dedtaut_sR is not None: 

23 self.apply_mgga(dedtaut_sR[spin], psit_nG, out) 

24 self.apply_orbital_dependent(ibzwfs, D_asii, psit_nG, spin, out) 

25 return out 

26 

27 def apply_local_potential(self, 

28 vt_R: UGArray, 

29 psit_nG: XArray, 

30 out: XArray) -> None: 

31 raise NotImplementedError 

32 

33 def apply_mgga(self, 

34 dedtaut_R: UGArray, 

35 psit_nG: XArray, 

36 vt_nG: XArray) -> None: 

37 raise NotImplementedError 

38 

39 def apply_orbital_dependent(self, 

40 ibzwfs, 

41 D_asii, 

42 psit_nG: XArray, 

43 spin: int, 

44 out: XArray) -> None: 

45 pass 

46 

47 def create_preconditioner(self, blocksize, xp=np): 

48 raise NotImplementedError