1from gpaw import GPAW, restart, FD 2from ase.build import molecule 3from gpaw.test import equal 4 5 6def test_complex(in_tmp_dir): 7 Eini0 = -17.8037610364 8 energy_eps = 0.0005 9 esolvers = ['cg', 'rmm-diis', 'dav'] 10 11 calc = GPAW(xc='LDA', 12 h=0.21, 13 eigensolver='cg', 14 convergence={'eigenstates': 3.5e-5, 'energy': energy_eps}, 15 mode=FD(force_complex_dtype=True)) 16 17 mol = molecule('N2') 18 mol.center(vacuum=3.0) 19 mol.calc = calc 20 21 Eini = mol.get_potential_energy() 22 Iini = calc.get_number_of_iterations() 23 print('%10s: %12.6f eV in %3d iterations' % ('init(cg)', Eini, Iini)) 24 equal(Eini, Eini0, energy_eps * calc.get_number_of_electrons()) 25 26 calc.write('N2_complex.gpw', mode='all') 27 28 for esolver in esolvers: 29 mol, calc = restart('N2_complex.gpw') 30 31 assert calc.wfs.dtype == complex 32 assert calc.wfs.kpt_u[0].psit_nG.dtype == complex 33 34 calc.set(convergence={'eigenstates': 3.5e-9, 'energy': energy_eps}) 35 calc.set(eigensolver=esolver) 36 E = mol.get_potential_energy() 37 equal(E, Eini, energy_eps * calc.get_number_of_electrons()) 38