diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec806345..bc67c703 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,11 +20,11 @@ jobs: env cmake -DWITH_CINT2_INTERFACE=1 -DWITH_RANGE_COULOMB=1 -DWITH_COULOMB_ERF=1 -DWITH_F12=1 -DWITH_4C1E=1 -Bbuild -DKEEP_GOING=1 . cmake --build build + pip install numpy mpmath pyscf - name: Test for rys-roots if: startsWith(matrix.os, 'ubuntu') run: | cd ${{ github.workspace }}/testsuite - pip install numpy mpmath pyscf python test_rys_roots.py - name: Unittest if: startsWith(matrix.os, 'ubuntu') diff --git a/testsuite/test_int1e.py b/testsuite/test_int1e.py index 826010aa..ae59e9d3 100644 --- a/testsuite/test_int1e.py +++ b/testsuite/test_int1e.py @@ -63,6 +63,7 @@ def run(intor, comp=1, suffix='_sph', thr=1e-9): args = (mol._atm.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(mol.natm), mol._bas.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(mol.nbas), mol._env.ctypes.data_as(ctypes.c_void_p), cintopt) + failed = False for i in range(mol.nbas): for j in range(mol.nbas): ref = mol.intor_by_shell(intor, [i,j], comp=comp) @@ -79,10 +80,15 @@ def run(intor, comp=1, suffix='_sph', thr=1e-9): mol._env.ctypes.data_as(ctypes.c_void_p)) if numpy.linalg.norm(ref-buf) > thr: print(intor, '| nopt', i, j, numpy.linalg.norm(ref-buf))#, ref, buf + failed = True #fn(buf.ctypes.data_as(ctypes.c_void_p), # (ctypes.c_int*2)(i,j), *args) #if numpy.linalg.norm(ref-buf) > 1e-7: # print('|', i, j, numpy.linalg.norm(ref-buf)) + if failed: + print('failed') + else: + print('pass') run('int1e_ovlp') run('int1e_nuc') diff --git a/testsuite/test_int1e_grids.py b/testsuite/test_int1e_grids.py index 4595086f..ffdbc06c 100644 --- a/testsuite/test_int1e_grids.py +++ b/testsuite/test_int1e_grids.py @@ -175,7 +175,11 @@ def test_int1e_grids_sph1(name, vref, dim, place): dat = op[:ref.size].reshape(dj, di).T if abs(dat - ref).max() > 1e-12: print(i, j, abs(dat - ref).max()) - print('sum', v1) + print('sum', v1, 'diff', v1 - vref) + if abs(v1 - vref) < 1e-10: + print('pass') + else: + print('failed') def test_int1e_grids_sph(name, vref, dim, place): intor = getattr(_cint, name) @@ -199,7 +203,11 @@ def test_int1e_grids_sph(name, vref, dim, place): env_g.ctypes.data_as(ctypes.c_void_p), opt) v1 += abs(op[:ngrids*di*dj*dim]).sum() cnt += ngrids*di*dj*dim - print('sum', v1) + print('sum', v1, 'diff', v1 - vref) + if abs(v1 - vref) < 1e-10: + print('pass') + else: + print('failed') def test_mol1(): import time @@ -215,6 +223,14 @@ def test_mol1(): numpy.random.seed(12) ngrids = 201 grids = numpy.random.random((ngrids, 3)) * 12 - 5 + + def check(intor, ref): + j3c = mol.intor(intor, grids=grids) + diff = abs(j3c - ref).max() + print(diff) + return diff > 1e-12 + + failed = False for omega in (0, 0.1, -0.1): for zeta in (0, 10, 1e16): print('omega, zeta', omega, zeta) @@ -227,27 +243,26 @@ def test_mol1(): mol.set_rinv_zeta(zeta) fmol = pyscf.gto.fakemol_for_charges(grids, expnt) ref = df.incore.aux_e2(mol, fmol, intor='int3c2e').transpose(2,0,1) - j3c = mol.intor('int1e_grids', grids=grids) - print(abs(j3c - ref).max()) + failed = check('int1e_grids', ref) or failed ref = df.incore.aux_e2(mol, fmol, intor='int3c2e_ip1').transpose(0,3,1,2) - j3c = mol.intor('int1e_grids_ip', grids=grids) - print(abs(j3c - ref).max()) + failed = check('int1e_grids_ip', ref) or failed ref = df.incore.aux_e2(mol, fmol, intor='int3c2e_ip1_cart').transpose(0,3,1,2) - j3c = mol.intor('int1e_grids_ip_cart', grids=grids) - print(abs(j3c - ref).max()) + failed = check('int1e_grids_ip_cart', ref) or failed ref = df.incore.aux_e2(mol, fmol, intor='int3c2e_ip1_spinor').transpose(0,3,1,2) - j3c = mol.intor('int1e_grids_ip_spinor', grids=grids) - print(abs(j3c - ref).max()) + failed = check('int1e_grids_ip_spinor', ref) or failed ref = df.r_incore.aux_e2(mol, fmol, intor='int3c2e_spsp1_spinor').transpose(2,0,1) - j3c = mol.intor('int1e_grids_spvsp_spinor', grids=grids) - print(abs(j3c - ref).max()) + failed = check('int1e_grids_spvsp_spinor', ref) or failed + if failed: + print('failed') + else: + print('pass') -test_int1e_grids_sph1('cint1e_grids_sph', 0, 1, 9) -test_int1e_grids_sph('cint1e_grids_ip_sph', 0, 1, 9) +test_int1e_grids_sph1('cint1e_grids_sph', 36.81452996003706, 1, 9) +test_int1e_grids_sph('cint1e_grids_ip_sph', 3279.92861109671, 1, 9) try: test_mol1() except ImportError: diff --git a/testsuite/test_int2c2e.py b/testsuite/test_int2c2e.py index ba93f13e..82d97290 100644 --- a/testsuite/test_int2c2e.py +++ b/testsuite/test_int2c2e.py @@ -66,6 +66,7 @@ def run(intor, comp=1, suffix='_sph', thr=1e-7): mol._bas.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(mol.nbas), mol._env.ctypes.data_as(ctypes.c_void_p), cintopt) + failed = False for i in range(mol.nbas): for j in range(mol.nbas): ref = mol.intor_by_shell(intor2, [i,j], comp=comp) @@ -82,12 +83,16 @@ def run(intor, comp=1, suffix='_sph', thr=1e-7): mol._env.ctypes.data_as(ctypes.c_void_p), lib.c_null_ptr()) if numpy.linalg.norm(ref-buf) > thr: print(intor, '| nopt', i, j, numpy.linalg.norm(ref-buf))#, ref, buf - exit() + failed = True fn1(buf.ctypes.data_as(ctypes.c_void_p), (ctypes.c_int*2)(i,j), *args) if numpy.linalg.norm(ref-buf) > thr: print(intor, '|', i, j, numpy.linalg.norm(ref-buf)) - exit() + failed = True + if failed: + print('failed') + else: + print('pass') run('int2c2e') run('int2c2e_ip1', 3) diff --git a/testsuite/test_int3c1e.py b/testsuite/test_int3c1e.py index 8cbb6410..cc3afeb7 100644 --- a/testsuite/test_int3c1e.py +++ b/testsuite/test_int3c1e.py @@ -69,6 +69,7 @@ def run(intor, comp=1, suffix='_sph', thr=1e-7): args = (mol._atm.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(mol.natm), mol._bas.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(mol.nbas), mol._env.ctypes.data_as(ctypes.c_void_p), cintopt) + failed = False for i in range(mol.nbas): for j in range(mol.nbas): for k in range(mol.nbas): @@ -86,10 +87,16 @@ def run(intor, comp=1, suffix='_sph', thr=1e-7): mol._env.ctypes.data_as(ctypes.c_void_p), lib.c_null_ptr()) if numpy.linalg.norm(ref-buf) > thr: print(intor, '| nopt', i, j, k, numpy.linalg.norm(ref-buf))#, ref, buf + failed = True fn1(buf.ctypes.data_as(ctypes.c_void_p), (ctypes.c_int*3)(i,j,k), *args) if numpy.linalg.norm(ref-buf) > thr: print(intor, '|', i, j, k, numpy.linalg.norm(ref-buf)) + failed = True + if failed: + print('failed') + else: + print('pass') run('int3c1e') #run('int3c1e_p2')