Example #1
0
def test_o2_cc_pvtz_cart_num():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_cart")
    fchk = FCHKFile(fn_fchk)
    basis = GaussianBasis.from_fchk(fchk)
    assert(basis.num_shells==20)
    print basis.num_dof
    assert(basis.num_dof==70)
Example #2
0
def test_o2_cc_pvtz_cart_num():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_cart")
    fchk = FCHKFile(fn_fchk)
    basis = GaussianBasis.from_fchk(fchk)
    assert (basis.num_shells == 20)
    print basis.num_dof
    assert (basis.num_dof == 70)
Example #3
0
def test_orb0_hf_sto3g():
    tmpdir, fn_fchk = setup_gaussian("hf_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    points = ref_data_hf_sto3g_orb0[:,:3]
    fns = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1,-1)), points*angstrom, 1)[0]
    assert(abs(fns-ref_data_hf_sto3g_orb0[:,3]).max() < 1e-10)
Example #4
0
def test_orb0_o2_cc_pvtz_pure():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_pure")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    weights = weights[basis.g03_permutation]
    points = ref_data_o2_cc_pvtz_pure_orb0[:,:3]
    fns = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1,-1)), points*angstrom, 1)[0]
    assert(abs(fns-ref_data_o2_cc_pvtz_pure_orb0[:,3]).max() < 1e-10)
Example #5
0
def test_orb0_hf_sto3g():
    tmpdir, fn_fchk = setup_gaussian("hf_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    points = ref_data_hf_sto3g_orb0[:, :3]
    fns = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1, -1)),
                               points * angstrom, 1)[0]
    assert (abs(fns - ref_data_hf_sto3g_orb0[:, 3]).max() < 1e-10)
Example #6
0
def test_orb0_o2_cc_pvtz_pure():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_pure")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    weights = weights[basis.g03_permutation]
    points = ref_data_o2_cc_pvtz_pure_orb0[:, :3]
    fns = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1, -1)),
                               points * angstrom, 1)[0]
    assert (abs(fns - ref_data_o2_cc_pvtz_pure_orb0[:, 3]).max() < 1e-10)
Example #7
0
def test_orb0_h_sto3g():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    # real test for the output
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    points = ref_data_h_sto3g_orb0[:,:3]
    fns = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1,-1)), points*angstrom, 1)[0]
    assert(abs(fns-ref_data_h_sto3g_orb0[:,3]).max() < 1e-10)
    # test error mechanism
    basis.shell_types[0] = 102
    assert_raises(ValueError, basis.call_gint_grid, gint1_fns_basis, weights.reshape((1,-1)), points*angstrom, 1)
    basis.shell_types[0] = -763
    assert_raises(ValueError, basis.call_gint_grid, gint1_fns_basis, weights.reshape((1,-1)), points*angstrom, 1)
Example #8
0
def test_pot_h_sto3g():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    # real test for the output
    dmat = fchk.fields["Total SCF Density"]
    points = ref_data_h_sto3g_pot[:,:3]*angstrom
    radius = numpy.sqrt((points**2).sum(axis=1))
    ref_data_h_sto3g_pot[:,3] -= 1/radius
    potential = -basis.call_gint_grid(gint2_nai_dmat, dmat, points)
    assert(abs(potential-ref_data_h_sto3g_pot[:,3]).max() < 1e-8)
    # test error mechanism
    basis.shell_types[0] = 102
    assert_raises(ValueError, basis.call_gint_grid, gint2_nai_dmat, dmat, points*angstrom)
    basis.shell_types[0] = -763
    assert_raises(ValueError, basis.call_gint_grid, gint2_nai_dmat, dmat, points*angstrom)
Example #9
0
def test_dens_h_sto3g():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    weights = weights[basis.g03_permutation]
    points = ref_data_h_sto3g_orb0[:,:3]
    orb0 = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1,-1)), points*angstrom, 1)[0]
    num_dmat = (basis.num_dof*(basis.num_dof+1))/2
    dmat = fchk.fields["Total SCF Density"][:num_dmat]
    density = basis.call_gint_grid(gint1_fn_dmat, dmat, points*angstrom)
    assert(abs(orb0**2-density).max() < 1e-10)
    # test error mechanism
    basis.shell_types[0] = 102
    assert_raises(ValueError, basis.call_gint_grid, gint1_fn_dmat, dmat, points*angstrom, 1)
    basis.shell_types[0] = -763
    assert_raises(ValueError, basis.call_gint_grid, gint1_fn_dmat, dmat, points*angstrom, 1)
Example #10
0
def test_orb0_h_sto3g():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    # real test for the output
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    points = ref_data_h_sto3g_orb0[:, :3]
    fns = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1, -1)),
                               points * angstrom, 1)[0]
    assert (abs(fns - ref_data_h_sto3g_orb0[:, 3]).max() < 1e-10)
    # test error mechanism
    basis.shell_types[0] = 102
    assert_raises(ValueError, basis.call_gint_grid, gint1_fns_basis,
                  weights.reshape((1, -1)), points * angstrom, 1)
    basis.shell_types[0] = -763
    assert_raises(ValueError, basis.call_gint_grid, gint1_fns_basis,
                  weights.reshape((1, -1)), points * angstrom, 1)
Example #11
0
def test_pot_o2_cc_pvtz_pure():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_pure")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    dmat = fchk.fields["Total SCF Density"]
    reorder_dmat(dmat, basis.g03_permutation)
    points = ref_data_o2_cc_pvtz_pure_pot[:, :3] * angstrom
    ref_potential = ref_data_o2_cc_pvtz_pure_pot[:, 3]
    nuc_potential = 0.0
    for i in xrange(fchk.molecule.size):
        center = fchk.molecule.coordinates[i]
        Z = fchk.molecule.numbers[i]
        radius = numpy.sqrt(((points - center)**2).sum(axis=1))
        nuc_potential += Z / radius
    ref_potential -= nuc_potential
    potential = -basis.call_gint_grid(gint2_nai_dmat, dmat, points)
    assert (abs(potential - ref_potential).max() < 1e-6)
Example #12
0
def test_pot_o2_cc_pvtz_pure():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_pure")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    dmat = fchk.fields["Total SCF Density"]
    reorder_dmat(dmat, basis.g03_permutation)
    points = ref_data_o2_cc_pvtz_pure_pot[:,:3]*angstrom
    ref_potential = ref_data_o2_cc_pvtz_pure_pot[:,3]
    nuc_potential = 0.0
    for i in xrange(fchk.molecule.size):
        center = fchk.molecule.coordinates[i]
        Z = fchk.molecule.numbers[i]
        radius = numpy.sqrt(((points-center)**2).sum(axis=1))
        nuc_potential += Z/radius
    ref_potential -= nuc_potential
    potential = -basis.call_gint_grid(gint2_nai_dmat, dmat, points)
    assert(abs(potential-ref_potential).max() < 1e-6)
Example #13
0
def test_pot_h_sto3g():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    # real test for the output
    dmat = fchk.fields["Total SCF Density"]
    points = ref_data_h_sto3g_pot[:, :3] * angstrom
    radius = numpy.sqrt((points**2).sum(axis=1))
    ref_data_h_sto3g_pot[:, 3] -= 1 / radius
    potential = -basis.call_gint_grid(gint2_nai_dmat, dmat, points)
    assert (abs(potential - ref_data_h_sto3g_pot[:, 3]).max() < 1e-8)
    # test error mechanism
    basis.shell_types[0] = 102
    assert_raises(ValueError, basis.call_gint_grid, gint2_nai_dmat, dmat,
                  points * angstrom)
    basis.shell_types[0] = -763
    assert_raises(ValueError, basis.call_gint_grid, gint2_nai_dmat, dmat,
                  points * angstrom)
Example #14
0
def test_dens_h_sto3g():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    weights = fchk.fields["Alpha MO coefficients"][:basis.num_dof]
    weights = weights[basis.g03_permutation]
    points = ref_data_h_sto3g_orb0[:, :3]
    orb0 = basis.call_gint_grid(gint1_fns_basis, weights.reshape((1, -1)),
                                points * angstrom, 1)[0]
    num_dmat = (basis.num_dof * (basis.num_dof + 1)) / 2
    dmat = fchk.fields["Total SCF Density"][:num_dmat]
    density = basis.call_gint_grid(gint1_fn_dmat, dmat, points * angstrom)
    assert (abs(orb0**2 - density).max() < 1e-10)
    # test error mechanism
    basis.shell_types[0] = 102
    assert_raises(ValueError, basis.call_gint_grid, gint1_fn_dmat, dmat,
                  points * angstrom, 1)
    basis.shell_types[0] = -763
    assert_raises(ValueError, basis.call_gint_grid, gint1_fn_dmat, dmat,
                  points * angstrom, 1)
Example #15
0
def test_dens_o2_cc_pvtz_pure():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_pure")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    num_dmat = (basis.num_dof*(basis.num_dof+1))/2

    points = ref_data_o2_cc_pvtz_pure_orb0[:,:3]

    dmat = fchk.fields["Total SCF Density"][:num_dmat]
    reorder_dmat(dmat, basis.g03_permutation)
    density = basis.call_gint_grid(gint1_fn_dmat, dmat, points*angstrom)

    num_alpha = fchk.fields["Number of alpha electrons"]
    weights = fchk.fields["Alpha MO coefficients"][:num_alpha*basis.num_dof]
    weights = weights.reshape((num_alpha, basis.num_dof))
    weights = weights[:,basis.g03_permutation]
    orbitals = basis.call_gint_grid(gint1_fns_basis, weights, points*angstrom, num_alpha)
    assert(orbitals.shape == (num_alpha, len(points)))
    expected_density = 2*(orbitals**2).sum(axis=0)

    assert(abs(density-expected_density).max() < 1e-6)
Example #16
0
def test_dens_o2_cc_pvtz_pure():
    tmpdir, fn_fchk = setup_gaussian("o2_cc_pvtz_pure")
    fchk = FCHKFile(fn_fchk)
    shutil.rmtree(tmpdir)
    basis = GaussianBasis.from_fchk(fchk)
    num_dmat = (basis.num_dof * (basis.num_dof + 1)) / 2

    points = ref_data_o2_cc_pvtz_pure_orb0[:, :3]

    dmat = fchk.fields["Total SCF Density"][:num_dmat]
    reorder_dmat(dmat, basis.g03_permutation)
    density = basis.call_gint_grid(gint1_fn_dmat, dmat, points * angstrom)

    num_alpha = fchk.fields["Number of alpha electrons"]
    weights = fchk.fields["Alpha MO coefficients"][:num_alpha * basis.num_dof]
    weights = weights.reshape((num_alpha, basis.num_dof))
    weights = weights[:, basis.g03_permutation]
    orbitals = basis.call_gint_grid(gint1_fns_basis, weights,
                                    points * angstrom, num_alpha)
    assert (orbitals.shape == (num_alpha, len(points)))
    expected_density = 2 * (orbitals**2).sum(axis=0)

    assert (abs(density - expected_density).max() < 1e-6)
Example #17
0
def test_h_sto3g_num():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    basis = GaussianBasis.from_fchk(fchk)
    assert(basis.num_shells==1)
    assert(basis.num_dof==1)
Example #18
0
def test_h_sto3g_num():
    tmpdir, fn_fchk = setup_gaussian("h_sto3g")
    fchk = FCHKFile(fn_fchk)
    basis = GaussianBasis.from_fchk(fchk)
    assert (basis.num_shells == 1)
    assert (basis.num_dof == 1)