Coverage for gpaw/test/rpa/test_rpa_energy_Ni.py: 100%
21 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
1import pytest
2from ase.build import bulk
3from gpaw import GPAW, FermiDirac
4from gpaw.mpi import serial_comm
5from gpaw.xc.rpa import RPACorrelation
6from gpaw.xc.fxc import FXCCorrelation
9@pytest.mark.rpa
10@pytest.mark.response
11def test_rpa_rpa_energy_Ni(in_tmp_dir):
12 Ni = bulk('Ni', 'fcc')
13 Ni.set_initial_magnetic_moments([0.7])
15 calc = GPAW(mode='pw',
16 kpts=(3, 3, 3),
17 occupations=FermiDirac(0.001),
18 setups={'Ni': '10'},
19 communicator=serial_comm)
20 Ni.calc = calc
21 Ni.get_potential_energy()
22 calc.diagonalize_full_hamiltonian(nbands=50)
24 rpa = RPACorrelation(calc, nfrequencies=8, skip_gamma=True, ecut=[50])
25 E_rpa = rpa.calculate()
27 fxc = FXCCorrelation(calc, nlambda=16, nfrequencies=8, skip_gamma=True,
28 ecut=[50])
29 E_fxc = fxc.calculate()
31 assert E_rpa == pytest.approx(-7.826, abs=0.01)
32 assert E_fxc == pytest.approx(-7.826, abs=0.01)