예제 #1
0
    def test_1(self):
        l = [1., 2., 3.]
        Vec3(l)
        from parmed.vec3 import Vec3 as chem_v3
        cv3 = chem_v3.__new__(chem_v3, *l)

        Vec3(cv3)
예제 #2
0
def get_forces_from_xvg(frcfile):
    with open(frcfile, 'r') as f:
        frc = [float(x) for x in f.readline().split()[1:]]
        return [
            Vec3(frc[i], frc[i + 1], frc[i + 2])
            for i in range(0, len(frc), 3)
        ]
예제 #3
0
    def test_1(self):
        l = [1., 2., 3.]
        v1 = Vec3(l)
        from parmed.vec3 import Vec3 as chem_v3
        cv3 = chem_v3.__new__(chem_v3, *l)

        v2 = Vec3(cv3)
예제 #4
0
def has_old_vec3():
    from parmed.vec3 import Vec3
    v1 = Vec3(1, 2, 3)
    if not hasattr(v1, 'x') or v1.x != 1:
        return True
    try:
        v2 = -v1
    except TypeError:
        return True
    return False
예제 #5
0
파일: geometry.py 프로젝트: maaren/ParmEd
def reduce_box_vectors(a, b, c):
    """
    This function puts three unit cell vectors in a reduced form where a is
    "mostly" in x, b is "mostly" in y, and c is "mostly" in z. This form is
    necessary for some programs (notably OpenMM and Gromacs)

    Parameters
    ----------
    a : 3-element collection of float
        First unit cell vector
    b : 3-element collection of float
        Second unit cell vector
    c : 3-element collection of float
        Third unit cell vector

    Returns
    -------
    red_a, red_b, red_c : Vec3, Vec3, Vec3
        The reduced unit cell vectors in units of angstroms

    Notes
    -----
    The implementation here is taken from the OpenMM Python application layer
    written by Peter Eastman
    """
    if u.is_quantity(a):
        a = a.value_in_unit(u.angstroms)
    if u.is_quantity(b):
        b = b.value_in_unit(u.angstroms)
    if u.is_quantity(c):
        c = c.value_in_unit(u.angstroms)

    a = Vec3(*a)
    b = Vec3(*b)
    c = Vec3(*c)

    c = c - b * round(c[1] / b[1])
    c = c - a * round(c[0] / a[0])
    b = b - a * round(b[0] / a[0])

    return a, b, c
예제 #6
0
def zero_ep_frc(frc, struct):
    vec0 = Vec3(0.0, 0.0, 0.0)
    for i, atom in enumerate(struct.atoms):
        if isinstance(atom, ExtraPoint):
            frc[i] = vec0
예제 #7
0
파일: xmlfile.py 프로젝트: xy21hb/ParmEd
 def positions(self):
     return [Vec3(*xyz) for xyz in self.coordinates[0]]
예제 #8
0
 def positions(self):
     return [Vec3(*xyz) for xyz in self._coordinates[0]] * u.angstroms
예제 #9
0
파일: charmmcrds.py 프로젝트: xy21hb/ParmEd
 def positionsold(self):
     """ Old atomic positions with units """
     return [Vec3(*xyz) for xyz in self.coordsold[0]] * u.angstroms
예제 #10
0
파일: charmmcrds.py 프로젝트: xy21hb/ParmEd
 def positions(self):
     """ Atomic positions with units """
     return [Vec3(*xyz) for xyz in self.coords[0]] * u.angstroms
예제 #11
0
파일: charmmcrds.py 프로젝트: xy21hb/ParmEd
 def positions(self):
     """
     Atomic coordinates with units attached to them with the shape (natom, 3)
     """
     return [Vec3(*xyz) for xyz in self.coordinates[0]] * u.angstroms