Coverage for gpaw/test/lcao/test_basismaker.py: 100%

19 statements  

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

1import pytest 

2 

3from gpaw.atom.all_electron import ValenceData 

4from gpaw.atom.basis import BasisMaker 

5from gpaw.atom.configurations import parameters 

6from gpaw.atom.generator import Generator 

7 

8 

9def test_basismaker_onthefly_potentials(): 

10 """Test on-the-fly potentials. 

11 

12 Specifically, test that generated basis functions are 

13 approximately equal whether using on-the-fly potentials or not. 

14 

15 We expect them to be the same except for a mixing step which the 

16 generator performs, which will affect historic basis sets but will 

17 not be present in basis sets generated directly from 

18 files/setupdata. 

19 

20 """ 

21 

22 sym = 'Ti' 

23 gen = Generator(sym, xcname='PBE') 

24 setup = gen.run(write_xml=False, **parameters[sym]) 

25 

26 valdata1 = ValenceData.from_setupdata_and_potentials( 

27 setup, vr_g=gen.vr, r2dvdr_g=gen.r2dvdr, scalarrel=gen.scalarrel) 

28 valdata2 = ValenceData.from_setupdata_onthefly_potentials(setup) 

29 

30 basis1 = BasisMaker(valdata1).generate() 

31 basis2 = BasisMaker(valdata2).generate() 

32 

33 assert len(basis1.bf_j) == len(basis2.bf_j) 

34 for bf1, bf2 in zip(basis1.bf_j, basis2.bf_j): 

35 assert bf1.l == bf2.l 

36 assert bf1.n == bf2.n 

37 assert bf1.rc == pytest.approx(bf2.rc) 

38 assert bf1.phit_g == pytest.approx(bf2.phit_g, abs=1e-6, rel=1e-6)