Ejemplo n.º 1
0
def get_angles(mol):
    """Determine bond angle atom triplets from bond graph and get parameters.
    
    Search bond graph for bond angle triplets, and parameter tables for mm
    parameters. Use to create a new Angle object and append to Molecule.
    Count as angle if ij and jk are bonded in triplet ijk.
    
    Args:
        mol (mmlib.molecule.Molecule): Molecule object with bond graph of
            atom pairs within covalent radius cutoff threshold.
    """
    for j in range(mol.n_atoms):
        at2 = mol.atoms[j]
        for i in mol.bond_graph[j].keys():
            at1 = mol.atoms[i]
            r_ij = mol.bond_graph[i][j]
            for k in mol.bond_graph[j].keys():
                if (i >= k):
                    continue
                at3 = mol.atoms[k]
                r_jk = mol.bond_graph[j][k]
                a_ijk = geomcalc.get_a_ijk(at1.coords, at2.coords, at3.coords,
                                           r_ij, r_jk)
                k_a, a_eq = param.get_angle_param(at1.type, at2.type, at3.type)
                if (k_a > 0.0):
                    mol.angles.append(molecule.Angle(i, j, k, a_ijk, a_eq,
                                                     k_a))
    mol.angles = sorted(mol.angles, key=lambda a: a.at3)
    mol.angles = sorted(mol.angles, key=lambda a: a.at2)
    mol.angles = sorted(mol.angles, key=lambda a: a.at1)
    mol.n_angles = len(mol.angles)
Ejemplo n.º 2
0
def get_gdir_torsion(coords1,
                     coords2,
                     coords3,
                     coords4,
                     r_12=None,
                     r_23=None,
                     r_34=None):
    """Calculate direction of energy gradients between torsion atoms.
    
    Args:
        coords1 (float*): 3 cartesian coordinates [Angstrom] of atom1.
        coords2 (float*): 3 cartesian coordinates [Angstrom] of atom2.
        coords3 (float*): 3 cartesian coordinates [Angstrom] of atom3.
        coords4 (float*): 3 cartesian coordinates [Angstrom] of atom4.
        r_12 (float): Distance between atom1 and atom2 (default None).
        r_23 (float): Distance between atom2 and atom3 (default None).
        r_34 (float): Distance between atom3 and atom4 (default None).
    
    Returns:
        gdir1 (float*), gdir2 (float*), gdir3 (float*), gdir4 (float*):
            vectors in the direction of max increasing torsion angle.
    """
    if (not r_12):
        r_12 = geomcalc.get_r_ij(coords1, coords2)
    if (not r_23):
        r_23 = geomcalc.get_r_ij(coords2, coords3)
    if (not r_34):
        r_34 = geomcalc.get_r_ij(coords3, coords4)
    u_21 = geomcalc.get_u_ij(coords2, coords1, r_12)
    u_34 = geomcalc.get_u_ij(coords3, coords4, r_34)
    u_23 = geomcalc.get_u_ij(coords2, coords3, r_23)
    u_32 = -1.0 * u_23
    a_123 = geomcalc.get_a_ijk(coords1, coords2, coords3, r_12, r_23)
    a_432 = geomcalc.get_a_ijk(coords4, coords3, coords2, r_34, r_23)
    s_123 = math.sin(geomcalc.deg2rad() * a_123)
    s_432 = math.sin(geomcalc.deg2rad() * a_432)
    c_123 = math.cos(geomcalc.deg2rad() * a_123)
    c_432 = math.cos(geomcalc.deg2rad() * a_432)
    gdir1 = geomcalc.get_ucp(u_21, u_23) / (r_12 * s_123)
    gdir4 = geomcalc.get_ucp(u_34, u_32) / (r_34 * s_432)
    gdir2 = (r_12 / r_23 * c_123 - 1.0) * gdir1 - (r_34 / r_23 * c_432) * gdir4
    gdir3 = (r_34 / r_23 * c_432 - 1.0) * gdir4 - (r_12 / r_23 * c_123) * gdir1
    return gdir1, gdir2, gdir3, gdir4
Ejemplo n.º 3
0
def update_angles(mol):
    """Update all bond angles [degrees] within a molecule object.
    
    Args:
        mol (mmlib.molecule.Molecule): Molecule object with angle data.
    """
    for p in range(mol.n_angles):
        a = mol.angles[p]
        r12 = mol.bond_graph[a.at1][a.at2]
        r23 = mol.bond_graph[a.at2][a.at3]
        c1 = mol.atoms[a.at1].coords
        c2 = mol.atoms[a.at2].coords
        c3 = mol.atoms[a.at3].coords
        a.a_ijk = geomcalc.get_a_ijk(c1, c2, c3, r12, r23)
Ejemplo n.º 4
0
def get_gdir_outofplane(coords1,
                        coords2,
                        coords3,
                        coords4,
                        oop,
                        r_31=None,
                        r_32=None,
                        r_34=None):
    """Calculate direction of energy gradients between outofplane atoms.
    
    Args:
        coords1 (float*): 3 cartesian coordinates [Angstrom] of atom1.
        coords2 (float*): 3 cartesian coordinates [Angstrom] of atom2.
        coords3 (float*): 3 cartesian coordinates [Angstrom] of atom3.
        coords4 (float*): 3 cartesian coordinates [Angstrom] of atom4.
        oop (float): Out-of-plane angles bewteen atoms 1, 2, 3, and 4.
        r_31 (float): Distance between atom3 and atom1 (default None).
        r_32 (float): Distance between atom3 and atom2 (default None).
        r_34 (float): Distance between atom3 and atom4 (default None).
    
    Returns:
        gdir1 (float*), gdir2 (float*), gdir3 (float*), gdir4 (float*):
            vectors in the direction of max increasing outofplane angle.
    """
    if (not r_31):
        r_31 = geomcalc.get_r_ij(coords3, coords1)
    if (not r_32):
        r_32 = geomcalc.get_r_ij(coords3, coords2)
    if (not r_34):
        r_34 = geomcalc.get_r_ij(coords3, coords4)
    u_31 = geomcalc.get_u_ij(coords3, coords1, r_31)
    u_32 = geomcalc.get_u_ij(coords3, coords2, r_32)
    u_34 = geomcalc.get_u_ij(coords3, coords4, r_34)
    cp_3234 = geomcalc.get_cp(u_32, u_34)
    cp_3431 = geomcalc.get_cp(u_34, u_31)
    cp_3132 = geomcalc.get_cp(u_31, u_32)
    a_132 = geomcalc.get_a_ijk(coords1, coords3, coords2)
    s_132 = math.sin(geomcalc.deg2rad() * a_132)
    c_132 = math.cos(geomcalc.deg2rad() * a_132)
    c_oop = math.cos(geomcalc.deg2rad() * oop)
    t_oop = math.tan(geomcalc.deg2rad() * oop)
    gdir1 = ((1.0 / r_31) * (cp_3234 / (c_oop * s_132) - (t_oop / s_132**2) *
                             (u_31 - c_132 * u_32)))
    gdir2 = ((1.0 / r_32) * (cp_3431 / (c_oop * s_132) - (t_oop / s_132**2) *
                             (u_32 - c_132 * u_31)))
    gdir4 = ((1.0 / r_34) * (cp_3132 / (c_oop * s_132) - (t_oop * u_34)))
    gdir3 = -1.0 * (gdir1 + gdir2 + gdir4)
    return gdir1, gdir2, gdir3, gdir4
Ejemplo n.º 5
0
def get_angle(mol, record):
    """Parse angle record into an angle object and append to molecule.
    
    Appends mmlib.molecule.Angle object to mmlib.molecule.Molecule
    object. Contents of angle object include (int) 3 atomic indices,
    (float) spring constant [kcal/(mol*radian^2)], (float) equilibrium
    bond angle [degrees], and (float) bond angle [degrees].
    
    Args:
        mol (mmlib.molecule.Molecule): Molecule to append angle.
        record (str*): Array of strings from line of prm file.
    """
    at1, at2, at3 = int(record[1])-1, int(record[2])-1, int(record[3])-1
    k_a, a_eq = float(record[4]), float(record[5])
    c1, c2, c3 = (mol.atoms[at1].coords, mol.atoms[at2].coords,
        mol.atoms[at3].coords)
    a_ijk = geomcalc.get_a_ijk(c1, c2, c3)
    angle = molecule.Angle(at1, at2, at3, a_ijk, a_eq, k_a)
    mol.angles.append(angle)