Esempio n. 1
0
def get_gdir_angle(coords1, coords2, coords3, r_21=None, r_23=None):
    """Calculate direction of energy gradients between bond angle 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.
        r_21 (float): Distance between atom2 and atom1 (default None).
        r_23 (float): Distance between atom2 and atom3 (default None).

    Returns:
        gdir1 (float*), gdir2 (float*), gdir3 (float*): vectors in the
            direction of max increasing bond angle.
    """
    if (not r_21):
        r_21 = geomcalc.get_r_ij(coords2, coords1)
    if (not r_23):
        r_23 = geomcalc.get_r_ij(coords2, coords3)
    u_21 = geomcalc.get_u_ij(coords2, coords1, r_21)
    u_23 = geomcalc.get_u_ij(coords2, coords3, r_23)
    cp = geomcalc.get_ucp(u_21, u_23)
    gdir1 = geomcalc.get_ucp(u_21, cp) / r_21
    gdir3 = geomcalc.get_ucp(cp, u_23) / r_23
    gdir2 = -1.0 * (gdir1 + gdir3)
    return gdir1, gdir2, gdir3
Esempio n. 2
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
Esempio n. 3
0
def get_g_bound_i(k_box, bound, coord, origin, boundtype):
    """Calculate energy gradient magnitude of boundary energy.
    
    Args:
        k_box (float): Spring constant [kcal/(mol*A^2)] of boundary.
        bound (float): Distance from origin [Angstrom] of boundary.
        coords (float*): Array of cartesian coordinates [Angstrom]
            of atom.
        origin (float*): Array of cartesian coordiantes [Angstrom]
            of origin of simulation.
        boundtype (str): `cube` or `sphere`, type of boundary condition.
    
    Returns:
        g_bound_i (float): Magnitude of energy gradient [kcal/(mol*A)].
    """
    g_bound_i = numpy.zeros(3)
    if (boundtype == 'cube'):
        for j in range(3):
            sign = 1.0 if ((coord[j] - origin[j]) <= 0.0) else -1.0
            scale = 1.0 if (abs(coord[j] - origin[j]) >= bound) else 0.0
            g_bound_i[j] = (-2.0 * sign * scale * k_box *
                            (abs(coord[j]) - bound))
    elif (boundtype == 'sphere'):
        r_io = geomcalc.get_r_ij(origin, coord)
        u_io = geomcalc.get_u_ij(origin, coord)
        scale = 1.0 if (r_io >= bound) else 0.0
        g_bound_i = 2.0 * scale * k_box * (r_io - bound) * u_io
    return g_bound_i
Esempio n. 4
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
Esempio n. 5
0
def get_gdir_inter(coords1, coords2, r_12=None):
    """Calculate direction of energy gradient between atom pair.
    
    Args:
        coords1 (float*): 3 Cartesian coordinates [Angstrom] of atom1.
        coords2 (float*): 3 Cartesian coordiantes [Angstrom] of atom2.
        r_ij (float): Distance between atom1 and atom2 (default None).
    
    Returns:
        gdir1 (float*), gdir2 (float*): unit vectors in the direction
            of max increasing inter-atomic distance.
    """
    gdir1 = geomcalc.get_u_ij(coords2, coords1, r_12)
    gdir2 = -1.0 * gdir1
    return gdir1, gdir2