Clean up tests

parent c495bf3b
......@@ -337,6 +337,9 @@ tests = [
'tpss.py', # ~18s
'tddft/td_na2.py', # ~18s
'exx/coarse.py', # ~18s
'exx/kpts.py',
'exx/double_cell.py',
'exx/derivs.py',
'corehole/si.py', # ~18s
'mgga/mgga_sc.py', # ~19s
'Hubbard_U_Zn.py', # ~20s
......
# flake8: noqa
import numpy as np
from ase import Atoms
from gpaw import GPAW, PW, Davidson
from gpaw.xc.hf import Hybrid
from gpaw.xc.hybrid import HybridXC as H1
k = 2
L = 3.0
a = Atoms('H',
#magmoms=[3],
cell=[L, L, 1],
pbc=(0, 0, 1))
if k == 1:
a *= (1, 1, 2)
# xc = Hybrid(xc='LDA', exx_fraction=0)
# xc.name = 'LDA'
# xc = Hybrid(None, 'LDA', 0.0, 0.0)
D = np.linspace(1.005, 1.015, 7)
E = []
for d in D:
#a.positions[1, 0] = d
#a.center()#######################
es = Davidson(1)
es.keep_htpsit = True#False
#xc = Hybrid('EXX')
xc = Hybrid('PBE0')
# xc = H1('EXX')
a.calc = GPAW(
mode=PW(400, force_complex_dtype=True),
# h=0.12,
#setups='p1',
#setups='ae',
kpts={'size': (1, 1, k), 'gamma': True},
nbands=1,
eigensolver=es,
# eigensolver='rmm-diis',
# txt='h2.txt',
#xc='PBE',
xc=xc
)
e = a.get_potential_energy()
raise SystemExit
#a.calc.set(xc=xc)
#e = a.get_potential_energy()
E.append(e)
print(d, e)
a = a[:1]
a[0].magmom = 1
es = Davidson(1)
es.keep_htpsit = False
# xc = Hybrid('EXX')
xc = H1('EXX')
a.calc = GPAW(
# mode=PW(500, force_complex_dtype=True),
h=0.12,
setups='ae',
nbands=1,
# eigensolver=es,
eigensolver='rmm-diis',
txt='h.txt',
xc=xc)
e = a.get_potential_energy()
print(2 * e - min(E))
if 1:
import matplotlib.pyplot as plt
plt.plot(D, E)
plt.show()
import sys
# import numpy as np
from ase import Atoms
from gpaw import GPAW, PW, Davidson
from gpaw.hybrids import HybridXC
k = int(sys.argv[1])
L = 8.0
a = Atoms('H2',
cell=[L, L, L],
pbc=1)
a.positions[1, 0] = 0.75
a.center()
es = Davidson(1)
es.keep_htpsit = True
xc = HybridXC('HSE06')
a.calc = GPAW(
mode=PW(400, force_complex_dtype=True),
kpts={'size': (1, 1, k), 'gamma': not True},
symmetry='off',
nbands=1,
eigensolver=es,
xc=xc)
e = a.get_potential_energy()
......@@ -12,7 +12,7 @@ def test(kpts, setup, spinpol, symmetry):
setups=setup,
kpts=kpts,
spinpol=spinpol,
#nbands=1,
# nbands=1,
symmetry=symmetry,
txt=None,
xc='PBE')
......@@ -26,51 +26,35 @@ def check(atoms, xc):
xc1.initialize(c.density, c.hamiltonian, c.wfs, c.occupations)
xc1.set_positions(c.spos_ac)
e = xc1.calculate_energy()
# print(e)
xc1.calculate_eigenvalues(0, 2, None)
# print('A', xc1.e_skn * Ha)
xc2 = EXX(c, xc=xc, bands=(0, 2), txt=None)
xc2.calculate()
e0 = xc2.get_exx_energy()
eps0 = xc2.get_eigenvalue_contributions()
# print('B', eps0)
assert np.allclose(eps0, xc1.e_skn * Ha)
# print(e0, e[0] + e[1])
assert np.allclose(e0, e[0] + e[1])
# print(xc1.description)
ecv, evv, v_skn = xc1.test()
# print('C', v_skn)
assert np.allclose(e0, ecv + evv)
#print(v_skn / eps0)
assert np.allclose(v_skn, eps0)
def main():
for spinpol in [False,
True
]:
for setup in ['ae',
'paw'
]:
for symmetry in ['off',
{}]:
for kpts in [
(1, 1, 1),
(1, 1, 2),
(1, 1, 3),
(1, 1, 4),
(2, 2, 1),
[(0, 0, 0.5)],
[(0, 0, 0), (0, 0, 0.5)]]:
for spinpol in [False, True]:
for setup in ['ae', 'paw']:
for symmetry in ['off', {}]:
for kpts in [(1, 1, 1),
(1, 1, 2),
(1, 1, 3),
(1, 1, 4),
(2, 2, 1),
[(0, 0, 0.5)],
[(0, 0, 0), (0, 0, 0.5)]]:
atoms = test(kpts, setup, spinpol, symmetry)
for xc in ['EXX',
'PBE0', 'HSE06'
]:
for xc in ['EXX', 'PBE0', 'HSE06']:
print(spinpol, setup, symmetry, kpts, xc,
len(atoms.calc.wfs.mykpts))
check(atoms, xc)
#break
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment