コード例 #1
0
ファイル: gromacsgrofile.py プロジェクト: andysim/openmm
def _construct_box_vectors(line):
    """Create the periodic box vectors based on the values stored in the file.

    @param[in] line The line containing the description
    """

    sline = line.split()
    values = [float(i) for i in sline]
    if len(sline) == 3:
        return (Vec3(values[0], 0, 0), Vec3(0, values[1], 0), Vec3(0, 0, values[2]))*nanometers
    return reducePeriodicBoxVectors((Vec3(values[0], values[3], values[4]), Vec3(values[5], values[1], values[6]), Vec3(values[7], values[8], values[2]))*nanometers)
コード例 #2
0
ファイル: gromacsgrofile.py プロジェクト: zhanglipku/openmm
def _construct_box_vectors(line):
    """Create the periodic box vectors based on the values stored in the file.

    @param[in] line The line containing the description
    """

    sline = line.split()
    values = [float(i) for i in sline]
    if len(sline) == 3:
        return (Vec3(values[0], 0, 0), Vec3(
            0, values[1], 0), Vec3(0, 0, values[2])) * nanometers
    return reducePeriodicBoxVectors(
        (Vec3(values[0], values[3],
              values[4]), Vec3(values[5], values[1], values[6]),
         Vec3(values[7], values[8], values[2])) * nanometers)
コード例 #3
0
    def testReducePBCVectors(self):
        """ Checks that reducePeriodicBoxVectors properly reduces vectors """
        a = Vec3(4.24388485, 0.0, 0.0)
        b = Vec3(-1.4146281691908937, 4.001173048368583, 0.0)
        c = Vec3(-1.4146281691908937, -2.0005862820516203, 3.4651176446201674)
        vecs = reducePeriodicBoxVectors((a, b, c)*nanometers)
        vecs2 = computePeriodicBoxVectors(4.24388485, 4.24388485, 4.24388485,
                109.4712190*degrees, 109.4712190*degrees, 109.4712190*degrees)

        # Check that the vectors are the same
        a1, a2, a3 = vecs
        b1, b2, b3 = vecs2
        for x, y in zip(a1, b1):
            self.assertAlmostEqual(strip_units(x), strip_units(y))
        for x, y in zip(a2, b2):
            self.assertAlmostEqual(strip_units(x), strip_units(y))
        for x, y in zip(a3, b3):
            self.assertAlmostEqual(strip_units(x), strip_units(y))
コード例 #4
0
ファイル: tools.py プロジェクト: pk-organics/openpathsampling
def reduced_box_vectors(snapshot):
    """Reduced box vectors for a snapshot (with units)

    See also
    --------
    reduce_trajectory_box_vectors

    Parameters
    ----------
    snapshot : :class:`.Snapshot`
        input snapshot

    Returns
    -------
    :class:`.Snapshot`
        snapshot with correctly reduced box vectors
    """
    nm = unit.nanometer
    return np.array(
        reducePeriodicBoxVectors(snapshot.box_vectors).value_in_unit(nm)) * nm
コード例 #5
0
    def testReducePBCVectors(self):
        """ Checks that reducePeriodicBoxVectors properly reduces vectors """
        a = Vec3(4.24388485, 0.0, 0.0)
        b = Vec3(-1.4146281691908937, 4.001173048368583, 0.0)
        c = Vec3(-1.4146281691908937, -2.0005862820516203, 3.4651176446201674)
        vecs = reducePeriodicBoxVectors((a, b, c) * nanometers)
        vecs2 = computePeriodicBoxVectors(4.24388485, 4.24388485, 4.24388485,
                                          109.4712190 * degrees,
                                          109.4712190 * degrees,
                                          109.4712190 * degrees)

        # Check that the vectors are the same
        a1, a2, a3 = vecs
        b1, b2, b3 = vecs2
        for x, y in zip(a1, b1):
            self.assertAlmostEqual(strip_units(x), strip_units(y))
        for x, y in zip(a2, b2):
            self.assertAlmostEqual(strip_units(x), strip_units(y))
        for x, y in zip(a3, b3):
            self.assertAlmostEqual(strip_units(x), strip_units(y))
コード例 #6
0
def reduced_box_vectors(snapshot):
    """Reduced box vectors for a snapshot (with units)

    See also
    --------
    reduce_trajectory_box_vectors

    Parameters
    ----------
    snapshot : :class:`.Snapshot`
        input snapshot

    Returns
    -------
    :class:`.Snapshot`
        snapshot with correctly reduced box vectors
    """
    nm = u.nanometer
    return np.array(
        reducePeriodicBoxVectors(snapshot.box_vectors).value_in_unit(nm)
    ) * nm