how to create bonds between particles during the simulation

Asked by aaron

Hi there,

I am trying to create bonds between particles during the simulaiton. I understand it is possible to create bonds at the beginning of the simulaiton by using the sim.createConnections, as with the code below:

particle1 = SimpleSphere(id = 0, posn = Vec3(0,2,0), radius = 0.1, mass = 1)
sim.createParticle(particle1)
pList.append(particle1)

particle2 = SimpleSphere(id = 1, posn = Vec3(0,2.2,0), radius = 0.1, mass = 1)
sim.createParticle(particle2)
pList.append(particle2)
sim.createConnections([TaggedIdConnection(0, 1, 1)])

This works very well and I can check the bond interaction is running during the simulation.

However, I would like to create more bonds after the simulations start, such that I can simulate the process that particles move together once they come into contact. I thought it would be helpful to use a Runnable module to create bonds dynamically. The pieces of codes used is shown below:

particle1 = SimpleSphere(id = 0, posn = Vec3(0,6,0), radius = 0.1, mass = 1)
self.sim.createParticle(particle1)
self.pList.append(particle1)

particle2 = SimpleSphere(id = 1, posn = Vec3(0,6.2,0), radius = 0.1, mass = 1)
self.sim.createParticle(particle2)
self.pList.append(particle2)

self.sim.createConnections([TaggedIdConnection(0, 1, 1)])

This time, it does not work. The bond interaction is not running any more.

I cannot figure out why ESyS refused to create new bonds at the run-time. Could anybody help me solve this problem?

Thanks in advance.

Best,
Aaron

Question information

Language:
English Edit question
Status:
Expired
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RH (rh999999999) said :
#1

Hy,

I have a solution. You can create new bonds in a runable like this:

#import the appropriate ESyS-Particle modules:
from esys.lsm import *
from esys.lsm.util import *
from esys.lsm.geometry import *

class ConnectionRunnable (Runnable):
    def __init__ (self, LsmMpi=None, startTime=0, endTime=0, intervall = 100, ParticleList = [], maxDist=0):
        """
        Subroutine to initialise the Runnable and store parameter values.
        """
        Runnable.__init__(self)
        self.sim = LsmMpi
        self.dt = self.sim.getTimeStepSize()
        self.startTime = startTime
        self.endTime = endTime
        self.intervall = intervall
        self.ParticleList = ParticleList
        self.maxDist = maxDist
        self.Nt = 0
        self.n = 0
    def run (self):
        """
        Subroutine to move the specified wall. After self.startTime
        timesteps, the speed of the wall increases linearly over
        self.rampTime timesteps until the desired wall speed is achieved.
        Thereafter the wall is moved at that speed.
        """
        if (self.Nt >= self.startTime and self.Nt <= self.endTime):
            if self.n <= 0:
                self.sim.createConnections(
                    ConnectionFinder(
                        maxDist = self.maxDist,
                        bondTag = 1,
                        pList = self.ParticleList
                    )
                )
                self.n=self.intervall
            self.n -= 1
        #count the number of timesteps completed thus far:
        self.Nt += 1

In your script you have to add the runable

Conn = ConnectionRunnable(LsmMpi=sim, startTime=0, endTime=1000000, intervall = 100, ParticleList = ParticleList, maxDist = 0.01)

sim.addPreTimeStepRunnable (Connector)

The method , however, can lead to a significant extension of computation time when the interval is small. It may be, there is a better solution by the developers .

Revision history for this message
aaron (zhaotaoscu) said :
#2

Hi RH,

Thanks for sharing your answer. However, it does not really work. My idea is to generate particles and bond them together during the simulation. I noticed that the bonds can only be generated at the initiation stage of the simulation. Any connection creation functions placed in the Runnable script won't work.

Aaron

Revision history for this message
SteffenAbe (s-abe) said :
#3

Hi Aaron,

the creation of bonds during a simulation is certainly possible. I've done it for example in the simulations used in the following paper:

Abe, S., van Gent, H. and Urai, J.L., 2011, DEM simulation of normal faults in cohesive materials, Tectonophysics, 512, 12-21

I'll see that I dig out the esys-particle simulation scripts from this work and post the relevant bits tomorrow.

N.B. I'm not quite sure if this is exactly what you need. In those simulations I created new bonds _once_ during a simulation by creating a new interaction group. If you want to add bonds multiple times to an _existing_ interaction group, this might work differently (or require some functions to be added at the C++ level to work at all). If that's indeed what you want then I'd need to have a closer look at the problem.

Steffen

Revision history for this message
aaron (zhaotaoscu) said :
#4

Hi Steffen,

Yes, that's relevant to what I need. I will be very appreciative if you can give me some suggesiton in coding this piece of program.

Thanks.

Aaron

Revision history for this message
Launchpad Janitor (janitor) said :
#5

This question was expired because it remained in the 'Open' state without activity for the last 15 days.