コード例 #1
0
ファイル: test_vlist.py プロジェクト: molmod/yaff
def test_vlist_quartz_bend_cos():
    system = get_system_quartz()
    dlist = DeltaList(system)
    iclist = InternalCoordinateList(dlist)
    vlist = ValenceList(iclist)
    angles = []
    for i1 in range(system.natom):
        for i0 in system.neighs1[i1]:
            for i2 in system.neighs1[i1]:
                if i0 > i2:
                    vlist.add_term(Harmonic(1.1+0.01*i0, -0.2, BendCos(i0, i1, i2)))
                    angles.append((i0, i1, i2))
    dlist.forward()
    iclist.forward()
    energy = vlist.forward()
    # compute energy manually
    check_energy = 0.0
    counter = 0
    for row, (i0, i1, i2) in enumerate(angles):
        delta0 = system.pos[i0] - system.pos[i1]
        system.cell.mic(delta0)
        delta2 = system.pos[i2] - system.pos[i1]
        system.cell.mic(delta2)
        c = bend_cos([delta0, np.zeros(3, float), delta2])[0]
        check_term = 0.5*(1.1+0.01*i0)*(c+0.2)**2
        assert abs(check_term - vlist.vtab[counter]['energy']) < 1e-10
        check_energy += check_term
        counter += 1
    assert abs(energy - check_energy) < 1e-8
コード例 #2
0
def test_vlist_quartz_bend_cos():
    system = get_system_quartz()
    dlist = DeltaList(system)
    iclist = InternalCoordinateList(dlist)
    vlist = ValenceList(iclist)
    angles = []
    for i1 in xrange(system.natom):
        for i0 in system.neighs1[i1]:
            for i2 in system.neighs1[i1]:
                if i0 > i2:
                    vlist.add_term(
                        Harmonic(1.1 + 0.01 * i0, -0.2, BendCos(i0, i1, i2)))
                    angles.append((i0, i1, i2))
    dlist.forward()
    iclist.forward()
    energy = vlist.forward()
    # compute energy manually
    check_energy = 0.0
    counter = 0
    for row, (i0, i1, i2) in enumerate(angles):
        delta0 = system.pos[i0] - system.pos[i1]
        system.cell.mic(delta0)
        delta2 = system.pos[i2] - system.pos[i1]
        system.cell.mic(delta2)
        c = bend_cos([delta0, np.zeros(3, float), delta2])[0]
        check_term = 0.5 * (1.1 + 0.01 * i0) * (c + 0.2)**2
        assert abs(check_term - vlist.vtab[counter]['energy']) < 1e-10
        check_energy += check_term
        counter += 1
    assert abs(energy - check_energy) < 1e-8
コード例 #3
0
def test_iclist_quartz_bend_cos():
    system = get_system_quartz()
    dlist = DeltaList(system)
    iclist = InternalCoordinateList(dlist)
    angles = []
    for i1 in xrange(system.natom):
        for i0 in system.neighs1[i1]:
            for i2 in system.neighs1[i1]:
                if i0 > i2:
                    iclist.add_ic(BendCos(i0, i1, i2))
                    angles.append((i0, i1, i2))
    dlist.forward()
    iclist.forward()
    for row, (i0, i1, i2) in enumerate(angles):
        delta0 = system.pos[i1] - system.pos[i0]
        system.cell.mic(delta0)
        delta2 = system.pos[i1] - system.pos[i2]
        system.cell.mic(delta2)
        assert abs(iclist.ictab[row]['value'] - bend_cos([delta0, np.zeros(3, float), delta2])[0]) < 1e-5
コード例 #4
0
ファイル: test_iclist.py プロジェクト: mcoolsce/yaff
def test_iclist_quartz_bend_cos():
    system = get_system_quartz()
    dlist = DeltaList(system)
    iclist = InternalCoordinateList(dlist)
    angles = []
    for i1 in range(system.natom):
        for i0 in system.neighs1[i1]:
            for i2 in system.neighs1[i1]:
                if i0 > i2:
                    iclist.add_ic(BendCos(i0, i1, i2))
                    angles.append((i0, i1, i2))
    dlist.forward()
    iclist.forward()
    for row, (i0, i1, i2) in enumerate(angles):
        delta0 = system.pos[i1] - system.pos[i0]
        system.cell.mic(delta0)
        delta2 = system.pos[i1] - system.pos[i2]
        system.cell.mic(delta2)
        assert abs(iclist.ictab[row]['value'] -
                   bend_cos([delta0, np.zeros(3, float), delta2])[0]) < 1e-5