Coverage for gpaw/test/new/test_calc_info.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 numpy as np
2import pytest
4from ase.build import bulk
6from gpaw import get_calculation_info
7from gpaw.mpi import world
10def test_calc_info():
11 atoms = bulk('Si')
12 info = get_calculation_info(atoms,
13 h=0.3,
14 xc='LDA',
15 kpts={'density': 1, 'gamma': True},
16 mode={'name': 'lcao'},
17 basis='sz(dzp)',
18 spinpol=True,
19 comm=world,
20 txt=None)
21 assert len(info.ibz) == 4
22 assert (info.grid.size == np.array([12, 12, 12])).all()
23 assert info.nspins == 2
24 assert info.nbands == 8
25 assert info.wf_description is None
26 assert info.dft_calculation() is not None
28 atoms.calc = info.ase_calculator()
29 atoms.get_potential_energy()
31 info2 = info.update_params(mode={'name': 'pw'})
32 assert info2.wf_description is not None
33 atoms.calc = info2.ase_calculator()
35 with pytest.raises(TypeError):
36 get_calculation_info(atoms, atoms)