Beispiel #1
0
 def test_diff_bond(self):
     for a1, a2 in yield_bonds():
         d = numpy.random.normal(0,eps,6) # random displacements
         b1 = a1+d[:3] # displaced
         b2 = a2+d[3:] # displaced
         qa, ga, ha = ic.bond_length(a1,a2,2)
         qb, gb, hb = ic.bond_length(b1,b2,2)
         delta1 = qb - qa
         delta2 = numpy.dot(0.5*(ga+gb).ravel(), d)
         error = abs(delta1-delta2)
         oom = abs(delta1)
         self.assert_(error*1e5 < oom)
         delta1 = (gb - ga).ravel()
         delta2 = numpy.dot(0.5*(ha+hb).reshape((6,6)), d)
         error = ((delta1-delta2)**2).mean()
         oom = (delta1**2).mean()
         self.assert_(error*1e5 < oom)
Beispiel #2
0
def get_bonds_angles(geometries, atoms):
    """
    This functions takes an array with the geometries, and a list with a group of atoms
    and returns the bond or angle evolution during the simulation

    """
    number_of_steps, number_of_atoms, _ = geometries.shape
    colvar = np.empty(number_of_steps)
    if len(atoms) == 2:
        for frame in range(number_of_steps):
            colvar[frame] = bond_length(geometries[frame, atoms])[0]
    elif len(atoms) == 3:
        for frame in range(number_of_steps):
            colvar[frame] = bend_angle(geometries[frame, atoms])[0]
    return colvar
Beispiel #3
0
def bond_length(mol, i0, i1):
    c = mol.coordinates
    return ic.bond_length(c[i0], c[i1])[0]
Beispiel #4
0
def bond_length(mol, i0, i1):
    c = mol.coordinates
    return ic.bond_length(c[i0], c[i1])[0]