示例#1
0
def test_wrapper_grid_from_file_o2():
    with path('chemtools.data', 'o2_uhf.wfn') as fpath:
        grid = MolecularGrid.from_file(fpath, 'veryfine')
        mol = Molecule.from_file(fpath)
    assert grid.weights.ndim == 1
    assert grid.points.shape[0] == grid.weights.shape[0]
    assert grid.points.shape == (grid.npoints, 3)
    # check integrate
    assert_allclose(16.,
                    grid.integrate(mol.compute_density(grid.points)),
                    rtol=0.,
                    atol=1.e-4)
示例#2
0
def test_wrapper_grid_raises():
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as fpath:
        assert_raises(TypeError, MolecularGrid.from_molecule, fpath,
                      'exp:1e-5:20:40:50')
        assert_raises(ValueError, MolecularGrid.from_file, fpath,
                      'ex:1e-5:20:40:50')
        assert_raises(ValueError, MolecularGrid.from_file, fpath,
                      'exp:1e-5:-20:40:50')
        assert_raises(ValueError, MolecularGrid.from_file, fpath,
                      'exp:1e-5:20:40:10')
        assert_raises(ValueError, MolecularGrid.from_file, fpath,
                      'pow:1e-5:20:40:50')
        assert_raises(ValueError, MolecularGrid.from_file, fpath, 'veryfin')
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as fpath:
        grid = MolecularGrid.from_file(fpath)
    assert_raises(ValueError, grid.integrate, np.array([[1., 2., 3.]]))
    assert_raises(NotImplementedError, grid.compute_spherical_average, None)