Esempio n. 1
0
    def assign_atypes(self, s):
        """pysimm.forcefield.Gaff2.assign_atypes

        Gaff2 specific boanglend typing rules.
        Requires System object Particle objects have Particle.bonds, Particle.type
        and Particle.type.name defined.
        *** use after assign_ptypes ***

        Args:
            s: pysimm.system.System

        Returns:
            None
        """
        all_types = set()
        s.angle_style = self.angle_style
        for p in s.particles:
            p.bonded_to = [x.a if p is x.b else x.b for x in p.bonds]
            for p1 in p.bonded_to:
                for p2 in p.bonded_to:
                    if p1 is not p2:
                        unique = True
                        for a in s.angles:
                            if ((a.a is p1 and a.b is p and a.c is p2)
                                    or (a.a is p2 and a.b is p and a.c is p1)):
                                unique = False
                        if unique:
                            at = self.angle_types.get(
                                '%s,%s,%s' %
                                (p1.type.name, p.type.name, p2.type.name))
                            if at:
                                s.angles.add(
                                    Angle(type_name=at[0].name,
                                          a=p1,
                                          b=p,
                                          c=p2))
                                all_types.add(at[0])
                            else:
                                print(
                                    'I cant type this angle %s,%s,%s' %
                                    (p1.type.name, p.type.name, p2.type.name))

        for at in all_types:
            at = at.copy()
            s.angle_types.add(at)

        for a in s.angles:
            at = s.angle_types.get(a.type_name)
            if at:
                a.type = at[0]
Esempio n. 2
0
    def assign_atypes(self, s):
        """pysimm.forcefield.Dreiding.assign_atypes

        Dreiding specific angle typing rules.
        Requires :class:`~pysimm.system.System` object :class:`~pysimm.system.Particle` objects have bonds, type and type.name defined.
        *** use after assign_ptypes ***

        Args:
            s: :class:`~pysimm.system.System`

        Returns:
            None
        """
        all_types = set()
        s.angle_style = self.angle_style
        s.add_particle_bonding()
        for p in s.particles:
            for p1 in p.bonded_to:
                for p2 in p.bonded_to:
                    if p1 is not p2:
                        unique = True
                        for a in s.angles:
                            if ((a.a is p1 and a.b is p and a.c is p2)
                                    or (a.a is p2 and a.b is p and a.c is p1)):
                                unique = False
                        if unique:
                            at = self.angle_types.get(
                                '%s,%s,%s' %
                                (p1.type.name, p.type.name, p2.type.name))
                            if at:
                                s.angles.add(
                                    Angle(type_name=at[0].name,
                                          a=p1,
                                          b=p,
                                          c=p2))
                                all_types.add(at[0])
                            else:
                                print(
                                    'I cant type this angle %s,%s,%s' %
                                    (p1.type.name, p.type.name, p2.type.name))

        for at in all_types:
            at = at.copy()
            s.angle_types.add(at)

        for a in s.angles:
            at = s.angle_types.get(a.type_name)
            if at:
                a.type = at[0]