예제 #1
0
    def test_tribend(self):
        self.system.actors.clear()
        # two triangles with bending interaction
        # move nodes, should relax back

        system = self.system
        system.virtual_sites = VirtualSitesInertialessTracers()

        system.part.clear()

        # Add four particles
        system.part.add(id=0, pos=[5, 5, 5], virtual=1)
        system.part.add(id=1, pos=[5, 5, 6], virtual=1)
        system.part.add(id=2, pos=[5, 6, 6], virtual=1)
        system.part.add(id=3, pos=[5, 6, 5], virtual=1)

        # Add first triel, weak modulus
        from espressomd.interactions import IBM_Triel
        tri1 = IBM_Triel(
            ind1=0, ind2=1, ind3=2, elasticLaw="Skalak", k1=0.1, k2=0, maxDist=2.4)
        system.bonded_inter.add(tri1)
        system.part[0].add_bond((tri1, 1, 2))

        # Add second triel
        tri2 = IBM_Triel(
            ind1=0, ind2=2, ind3=3, elasticLaw="Skalak", k1=10, k2=0, maxDist=2.4)
        system.bonded_inter.add(tri2)
        system.part[0].add_bond((tri2, 2, 3))

        # Add bending
        from espressomd.interactions import IBM_Tribend
        tribend = IBM_Tribend(
            ind1=0, ind2=1, ind3=2, ind4=3, kb=1, refShape="Initial")
        system.bonded_inter.add(tribend)
        system.part[0].add_bond((tribend, 1, 2, 3))

        # twist
        system.part[1].pos = [5.2, 5, 6]

        self.reset_lb()

        # Perform integration
        last_angle = self.compute_angle()
        for i in range(6):
            system.integrator.run(430)
            angle = self.compute_angle()
            self.assertLess(angle, last_angle)
            last_angle = angle
        self.assertLess(angle, 0.03)
예제 #2
0
def AddBending(system, kb):

    # currently only works for ONE SINGLE soft object

    # angles
    from espressomd.interactions import IBM_Tribend
    with open("tables/softAngles", "r") as fp:
        numAngles = int(fp.readline())
        print "Found " + str(numAngles) + " angles"
        # actual add
        for i in range(0, numAngles):
            line = str.split(fp.readline())
            id1 = int(line[0])
            id2 = int(line[1])
            id3 = int(line[2])
            id4 = int(line[3])
            tribend = IBM_Tribend(ind1=id1,
                                  ind2=id2,
                                  ind3=id3,
                                  ind4=id4,
                                  kb=kb,
                                  refShape="initial")
            system.bonded_inter.add(tribend)
            system.part[id1].add_bond((tribend, id2, id3, id4))
    def test_tribend(self):

        # two triangles with bending interaction
        # move nodes, should relax back

        system = self.system
        system.virtual_sites = VirtualSitesInertialessTracers()
        self.lbf.set_params(ext_force_density=(0.0, 0., 0.))
        self.stop_fluid()

        system.part.clear()

        ## Add four particles
        system.part.add(id=0, pos=[5, 5, 5], virtual=1)
        system.part.add(id=1, pos=[5, 5, 6], virtual=1)
        system.part.add(id=2, pos=[5, 6, 6], virtual=1)
        system.part.add(id=3, pos=[5, 6, 5], virtual=1)

        ## Add first triel, weak modulus
        from espressomd.interactions import IBM_Triel
        tri1 = IBM_Triel(ind1=0,
                         ind2=1,
                         ind3=2,
                         elasticLaw="Skalak",
                         k1=0.1,
                         k2=0,
                         maxDist=2.4)
        system.bonded_inter.add(tri1)
        system.part[0].add_bond((tri1, 1, 2))

        ## Add second triel
        tri2 = IBM_Triel(ind1=0,
                         ind2=2,
                         ind3=3,
                         elasticLaw="Skalak",
                         k1=10,
                         k2=0,
                         maxDist=2.4)
        system.bonded_inter.add(tri2)
        system.part[0].add_bond((tri2, 2, 3))

        ## Add bending
        from espressomd.interactions import IBM_Tribend
        tribend = IBM_Tribend(ind1=0,
                              ind2=1,
                              ind3=2,
                              ind4=3,
                              kb=1,
                              refShape="Initial")
        system.bonded_inter.add(tribend)
        system.part[0].add_bond((tribend, 1, 2, 3))

        ## output before
        print("Angle before twisting: " + str(self.compute_angle()))

        ## twist
        system.part[1].pos = [5.2, 5, 6]

        ## output after
        print("Angle after twisting: " + str(self.compute_angle()))

        ## Perform integrat[ion
        last_angle = self.compute_angle()
        for i in range(8):
            system.integrator.run(500)
            angle = self.compute_angle()
            print("Angle after relaxation: ", angle)
            self.assertLess(angle, last_angle)
            last_angle = angle

        self.assertLess(angle, 0.03)