Coverage for gpaw/test/mixing/test_co.py: 100%

15 statements  

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

1import pytest 

2from ase.build import bulk 

3from gpaw import GPAW 

4from gpaw.mixer import MixerFull 

5from gpaw.mpi import world 

6 

7 

8@pytest.mark.skipif( 

9 world.size > 4, 

10 reason='non-collinear calculation can only parallelize over k-points') 

11def test_co_new_mixing(): 

12 atoms = bulk('Co', crystalstructure='fcc', a=2.51 * 2**0.5) 

13 atoms.set_initial_magnetic_moments([2]) 

14 kpts = (3, 3, 3) 

15 atoms.calc = GPAW(mode='pw', 

16 kpts=kpts, 

17 mixer=MixerFull()) 

18 e1 = atoms.get_potential_energy() 

19 atoms.calc = GPAW(mode='pw', 

20 kpts=kpts, 

21 symmetry='off', 

22 experimental=dict(magmoms=[[1, -1, 1]]), 

23 mixer=MixerFull()) 

24 e2 = atoms.get_potential_energy() 

25 assert e1 == pytest.approx(e2, abs=0.002)