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
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
def get_g_angle(a_ijk, a_eq, k_a): """Calculate energy gradient magnitude of angle bend. Args: a_ijk (float): Angle [degrees] between atoms i, j, and k. a_eq (float): Equilibrium bond angle [degrees] of angle ijk. k_a (float): Spring constant [kcal/(mol*rad^2)] of angle ijk. Returns: g_angle (float): Magnitude of energy gradient [kcal/(mol*A)]. """ g_angle = 2.0 * k_a * (geomcalc.deg2rad() * (a_ijk - a_eq)) return g_angle
def get_g_outofplane(o_ijkl, v_n): """Calculate energy gradient magnitude of outofplane bend. Args: o_ijkl (float): Outofplane angle [degrees] between atoms i, j, k, and l. v_n (float): Half-barrier height [kcal/mol] of outofplane ijkl. Returns: g_outofplane (float): Magnitude of energy gradient [kcal/(mol*A)]. """ g_outofplane = (-v_n * 2.0 * math.sin(geomcalc.deg2rad() * (2.0 * o_ijkl - 180.0))) return g_outofplane
def get_g_torsion(t_ijkl, v_n, gamma, n_fold, paths): """Calculate energy gradient magnitude of torsion strain. Args: t_ijkl (float): Torsion [degrees] between atoms i, j, k, and l. v_n (float): Half-barrier height [kcal/mol] of torsion ijkl. gamma (float): Barrier offset [degrees] of torsion ijkl. n_fold (int): Barrier frequency of torsion ijkl. paths (int): Number of distinct paths in torsion ijkl. Returns: g_torsion (float): Magnitude of energy gradient [kcal/(mol*A)]. """ g_torsion = (-v_n * n_fold * math.sin(geomcalc.deg2rad() * (n_fold * t_ijkl - gamma)) / paths) return g_torsion