コード例 #1
0
def GetGdirAngle(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 r_21 is not None:
        r_21 = geomcalc.GetRij(coords2, coords1)
    if r_23 is not None:
        r_23 = geomcalc.GetRij(coords2, coords3)
    u_21 = geomcalc.GetUij(coords2, coords1, r_21)
    u_23 = geomcalc.GetUij(coords2, coords3, r_23)
    cp = geomcalc.GetUcp(u_21, u_23)
    gdir1 = geomcalc.GetUcp(u_21, cp) / r_21
    gdir3 = geomcalc.GetUcp(cp, u_23) / r_23
    gdir2 = -1.0 * (gdir1 + gdir3)
    return gdir1, gdir2, gdir3
コード例 #2
0
def GetGDirTorsion(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.
  """
  u_21 = geomcalc.GetUij(coords2, coords1, r_12)
  u_34 = geomcalc.GetUij(coords3, coords4, r_34)
  u_23 = geomcalc.GetUij(coords2, coords3, r_23)
  u_32 = -1.0 * u_23
  a_123 = geomcalc.GetAijk(coords1, coords2, coords3, r_12, r_23)
  a_432 = geomcalc.GetAijk(coords4, coords3, coords2, r_34, r_23)
  s_123 = math.sin(const.DEG2RAD * a_123)
  s_432 = math.sin(const.DEG2RAD * a_432)
  c_123 = math.cos(const.DEG2RAD * a_123)
  c_432 = math.cos(const.DEG2RAD * a_432)
  gdir1 = geomcalc.GetUcp(u_21, u_23) / (r_12*s_123)
  gdir4 = geomcalc.GetUcp(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
コード例 #3
0
def GetGdirOutofplane(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 r_31 is not None:
        r_31 = geomcalc.GetRij(coords3, coords1)
    if r_32 is not None:
        r_32 = geomcalc.GetRij(coords3, coords2)
    if r_34 is not None:
        r_34 = geomcalc.GetRij(coords3, coords4)
    u_31 = geomcalc.GetUij(coords3, coords1, r_31)
    u_32 = geomcalc.GetUij(coords3, coords2, r_32)
    u_34 = geomcalc.GetUij(coords3, coords4, r_34)
    cp_3234 = geomcalc.GetCp(u_32, u_34)
    cp_3431 = geomcalc.GetCp(u_34, u_31)
    cp_3132 = geomcalc.GetCp(u_31, u_32)
    a_132 = geomcalc.GetAijk(coords1, coords3, coords2)
    s_132 = math.sin(const.DEG2RAD * a_132)
    c_132 = math.cos(const.DEG2RAD * a_132)
    c_oop = math.cos(const.DEG2RAD * oop)
    t_oop = math.tan(const.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
コード例 #4
0
def GetEBoundI(k_box, bound, coords, origin, boundtype):
    """Calculate simulation boundary energy of an atom.
  
  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:
    e_bound_i (float): Boundary energy [kcal/mol] of atom.
  """
    e_bound_i = 0.0
    if (boundtype == 'cube'):
        for j in range(const.NUMDIM):
            scale = 1.0 if (abs(coords[j] - origin[j]) >= bound) else 0.0
            e_bound_i += (scale * k_box *
                          (abs(coords[j] - origin[j]) - bound)**2)
    elif (boundtype == 'sphere'):
        r_io = geomcalc.GetRij(origin, coords)
        u_io = geomcalc.GetUij(origin, coords)
        scale = 1.0 if (r_io >= bound) else 0.0
        e_bound_i += scale * k_box * (r_io - bound)**2
    return e_bound_i
コード例 #5
0
def GetGBoundI(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(const.NUMDIM)
    if boundtype == 'cube':
        for j in range(const.NUMDIM):
            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.GetRij(origin, coord)
        u_io = geomcalc.GetUij(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
コード例 #6
0
def GetGdirInter(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.GetUij(coords2, coords1, r_12)
    gdir2 = -1.0 * gdir1
    return gdir1, gdir2
コード例 #7
0
 def testAntiReflexive(self):
     """Asserts opposite value for inverted order of inputs."""
     params = ARBITRARY_XYZ2, ARBITRARY_XYZ1
     self.assertListAlmostEqual(geomcalc.GetUij(*params), UNIT_VECTOR_21)
コード例 #8
0
 def testArbitrary(self):
     """Asserts correct unit vector between arbitrary points in 3d space."""
     params = ARBITRARY_XYZ1, ARBITRARY_XYZ2
     self.assertListAlmostEqual(geomcalc.GetUij(*params), UNIT_VECTOR_12)
コード例 #9
0
 def testOnAxisZ(self):
     """Asserts correct on-axis unit vector between points on the z-axis."""
     params = POSITIVE_ARBITRARY_Z, NEGATIVE_ARBITRARY_Z
     self.assertListAlmostEqual(geomcalc.GetUij(*params), NEGATIVE_UNIT_Z)
コード例 #10
0
 def testUnitLength(self):
     """Asserts correct direction for points separated by unit distance."""
     params = POSITIVE_UNIT_X, ORIGIN
     self.assertListAlmostEqual(geomcalc.GetUij(*params), NEGATIVE_UNIT_X)
コード例 #11
0
 def testSamePoint(self):
     """Asserts zero vector between identical points."""
     params = ARBITRARY_XYZ1, ARBITRARY_XYZ1
     self.assertListAlmostEqual(geomcalc.GetUij(*params), ORIGIN)