예제 #1
0
def test_moments():
    padb = get_proatomdb_cp2k()
    record0 = padb.get_record(8, 0)
    record1 = padb.get_record(8, 1)
    m0 = record0.get_moment(3)
    m1 = record1.get_moment(3)
    assert m0 > m1
    assert abs(m0-21.84) < 1e-2
    assert abs(m1-12.17) < 1e-2
예제 #2
0
def test_moments():
    padb = get_proatomdb_cp2k()
    record0 = padb.get_record(8, 0)
    record1 = padb.get_record(8, 1)
    m0 = record0.get_moment(3)
    m1 = record1.get_moment(3)
    assert m0 > m1
    assert abs(m0 - 21.84) < 1e-2
    assert abs(m1 - 12.17) < 1e-2
예제 #3
0
def test_normalize():
    padb = get_proatomdb_cp2k()
    padb.compact(0.1)
    padb.normalize()
    for number in padb.get_numbers():
        rgrid = padb.get_rgrid(number)
        for charge in padb.get_charges(number):
            r = padb.get_record(number, charge)
            nel = rgrid.integrate(r.rho)
            nel_integer = r.pseudo_number - charge
            assert abs(nel - nel_integer) < 1e-10
예제 #4
0
def test_normalize():
    padb = get_proatomdb_cp2k()
    padb.compact(0.1)
    padb.normalize()
    for number in padb.get_numbers():
        rgrid = padb.get_rgrid(number)
        for charge in padb.get_charges(number):
            r = padb.get_record(number, charge)
            nel = rgrid.integrate(r.rho)
            nel_integer = r.pseudo_number - charge
            assert abs(nel - nel_integer) < 1e-10
예제 #5
0
def test_get_spline_pseudo():
    padb = get_proatomdb_cp2k()

    spline = padb.get_spline(8)
    check_spline_pop(spline, 6.0)
    check_spline_record(spline, padb.get_record(8, 0))

    spline = padb.get_spline(8, -1)
    check_spline_pop(spline, 7.0)
    check_spline_record(spline, padb.get_record(8, -1))

    spline = padb.get_spline(8, {0:0.5, -1:0.5})
    check_spline_pop(spline, 6.5)

    spline = padb.get_spline(14)
    check_spline_pop(spline, 4.0)
    check_spline_record(spline, padb.get_record(14, 0))
예제 #6
0
def test_get_spline_pseudo():
    padb = get_proatomdb_cp2k()

    spline = padb.get_spline(8)
    check_spline_pop(spline, 6.0)
    check_spline_record(spline, padb.get_record(8, 0))

    spline = padb.get_spline(8, -1)
    check_spline_pop(spline, 7.0)
    check_spline_record(spline, padb.get_record(8, -1))

    spline = padb.get_spline(8, {0: 0.5, -1: 0.5})
    check_spline_pop(spline, 6.5)

    spline = padb.get_spline(14)
    check_spline_pop(spline, 4.0)
    check_spline_record(spline, padb.get_record(14, 0))
예제 #7
0
def test_hebasis():
    padb = get_proatomdb_cp2k()
    numbers = np.array([8, 14, 14, 8, 8])
    hebasis = HEBasis(numbers, padb)
    assert hebasis.get_nbasis() == 9 # 3 for every oxygen atom
    assert hebasis.get_atom_nbasis(0) == 3
    assert hebasis.get_atom_nbasis(1) == 0
    assert hebasis.get_atom_nbasis(2) == 0
    assert hebasis.get_atom_nbasis(3) == 3
    assert hebasis.get_atom_nbasis(4) == 3
    for i in 0, 3, 4:
        assert hebasis.get_lower_bound(i, 0) == -1
        assert hebasis.get_lower_bound(i, 1) == -1
        assert hebasis.get_lower_bound(i, 2) == 0
        assert hebasis.get_constant_lico(i) == {0: 1}
    assert (hebasis.get_initial_propars() == 0).all()
    propars = np.array([0.1, 0.5, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
    assert hebasis.get_total_lico(0, propars) == {+2: -0.1, +1: -0.4, 0: 1.2, -1: 0.3}
예제 #8
0
def test_hebasis():
    padb = get_proatomdb_cp2k()
    numbers = np.array([8, 14, 14, 8, 8])
    hebasis = HEBasis(numbers, padb)
    assert hebasis.get_nbasis() == 9 # 3 for every oxygen atom
    assert hebasis.get_atom_nbasis(0) == 3
    assert hebasis.get_atom_nbasis(1) == 0
    assert hebasis.get_atom_nbasis(2) == 0
    assert hebasis.get_atom_nbasis(3) == 3
    assert hebasis.get_atom_nbasis(4) == 3
    for i in 0, 3, 4:
        assert hebasis.get_lower_bound(i, 0) == -1
        assert hebasis.get_lower_bound(i, 1) == -1
        assert hebasis.get_lower_bound(i, 2) == 0
        assert hebasis.get_constant_lico(i) == {0: 1}
    assert (hebasis.get_initial_propars() == 0).all()
    propars = np.array([0.1, 0.5, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
    assert hebasis.get_total_lico(0, propars) == {+2: -0.1, +1: -0.4, 0: 1.2, -1: 0.3}
예제 #9
0
def test_db_basics_pseudo():
    padb = get_proatomdb_cp2k()
    assert padb.get_numbers() == [8, 14]
    assert padb.get_charges(8) == [2, 1, 0, -1, -2]
    assert padb.get_charges(8, safe=True) == [2, 1, 0, -1]
    assert padb.get_charges(14) == [0]
    assert not padb.get_record(8, -2).safe
    assert padb.get_rgrid(8) is padb.get_record(8, 1).rgrid
    r1 = padb.get_record(8, -1)
    assert r1.safe
    assert abs(r1.energy - -15.866511882272) < 1e-8
    assert abs(r1.homo_energy - 0.192773) < 1e-5
    assert abs(r1.ipot_energy - (padb.get_record(8, 0).energy - r1.energy)) < 1e-5
    r2 = padb.get_record(8, -2)
    assert not r2.safe
    assert abs(r2.energy - -15.464982778766) < 1e-8
    assert abs(r2.homo_energy - 0.606458) < 1e-5
    assert abs(r2.ipot_energy - (r1.energy - r2.energy)) < 1e-5
    assert padb.get_record(8, +2).ipot_energy is None
예제 #10
0
def test_db_basics_pseudo():
    padb = get_proatomdb_cp2k()
    assert padb.get_numbers() == [8, 14]
    assert padb.get_charges(8) == [2, 1, 0, -1, -2]
    assert padb.get_charges(8, safe=True) == [2, 1, 0, -1]
    assert padb.get_charges(14) == [0]
    assert not padb.get_record(8, -2).safe
    assert padb.get_rgrid(8) is padb.get_record(8, 1).rgrid
    r1 = padb.get_record(8, -1)
    assert r1.safe
    assert abs(r1.energy - -15.866511882272) < 1e-8
    assert abs(r1.homo_energy - 0.192773) < 1e-5
    assert abs(r1.ipot_energy -
               (padb.get_record(8, 0).energy - r1.energy)) < 1e-5
    r2 = padb.get_record(8, -2)
    assert not r2.safe
    assert abs(r2.energy - -15.464982778766) < 1e-8
    assert abs(r2.homo_energy - 0.606458) < 1e-5
    assert abs(r2.ipot_energy - (r1.energy - r2.energy)) < 1e-5
    assert padb.get_record(8, +2).ipot_energy is None
예제 #11
0
def test_empty_proatom():
    padb = get_proatomdb_cp2k()
    assert (padb.get_rho(8, {}) == 0.0).all()
예제 #12
0
def test_compact():
    padb = get_proatomdb_cp2k()
    padb.compact(0.1)
    assert padb.get_rgrid(8).size < 100
    assert padb.get_rgrid(14).size < 100
예제 #13
0
def test_empty_proatom():
    padb = get_proatomdb_cp2k()
    assert (padb.get_rho(8, {}) == 0.0).all()
예제 #14
0
def test_compact():
    padb = get_proatomdb_cp2k()
    padb.compact(0.1)
    assert padb.get_rgrid(8).size < 100
    assert padb.get_rgrid(14).size < 100