Is it easy to add particles after several time steps?

Asked by Feng Chen

Hi, All:

If my simulation needs to add several particles after the simulation has started, e.g. initially I have 10 particles running, after 100 steps, I will need to add another 5 particles into the simulation and then interact with the previous 10, is it easy to do it in the current esys-particle or a lot of coding is required?

Thanks in advance!

Feng

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
Dion Weatherley
Solved:
Last query:
Last reply:
Revision history for this message
Will (will-hancock) said :
#1

Hi Feng,

This is relatively easy using a Runnable, but just be aware of a couple of things.
1.Care must be taken so that inserted particles do no significantly overlap existing particles as this may lead to numerical instability (ideally no overlap would be best).
2.New particles must be assinged an ID, this ID should be a unique number and should not already exist in the system.

With that in mind, we can use the createParticles() function under LsmMpi to insert particles into the model during a runnable in the same way we can use it before a simulation starts. LsmMpi.createParticles() takes an array of particles, however you can also use LsmMpi.createParticle() if you wish to insert individual particles one by one. The following example uses createParticles() to generate two particles in predefined locations.

rotSphereArray = []
 //create an array of particles
rotSphereArray.append (RotSphere(
id = UniqueID,
 radius = 1.0,
 posn = Vec3(X,Y,Z),
 mass =1.0)))
 //Particle 1
UniqueID +=1
rotSphereArray.append (RotSphere(
id = UniqueID,
 radius = 1.0,
 posn = Vec3(X1,Y1,Z1),
 mass =1.0)))
 //Particle 2
UniqueID +=1

self.sim.createParticles(rotSphereArray)

This is wrapped within the runnable which stores the UniqueID so that we don't reuse it. After the particle has been created you can then use the usual LsmMpi functions to change its tag, density, velocity etc..

Deleting particles can also be achieved within a runnable, but in a slightly more constructive manner... We are able to move particles outside the simulation domain using LsmMpi.moveParticleTo(id,Vec3(X,Y,Z)), thus sending them into oblivion.

Hope this answers your question. Cheers,
Will

Revision history for this message
Feng Chen (fchen3-gmail) said :
#2

Hi, Will:

Thanks a lot for the answer, I will try using your code and actually what I am planning to do is like this:

sim.readGeometry("input1.geo")
...
sim.run()
...
sim.readGeometry("input2.geo")
...
sim.run()

because I have two pre-defined particle files that I want them to interact with each other. I will try these and then let you know the results!

Feng

Revision history for this message
Best Dion Weatherley (d-weatherley) said :
#3

Hi all,

Thanks Will for your guidelines on creation and deletion of particles. This is exactly how it should be done if a simulation has a single sim.run() loop. Unfortunately, ESyS-Particle does not allow sim.run() to be called more than once. This loop terminates with an MPIFinalize() command that kills the workers (and (possibly) the master process). Will's suggested method using Runnables is preferable although, as he said, one must be careful about duplicate particle IDs.

An alternative method might be to augment the existing RunOneTimeStep() subroutine of LsmMpi (or LatticeMaster) to a RunNTimeSteps() subroutine. This is pretty easy to implement but one must ensure the simulation script ends with sim.exit() to call the necessary MPIFinalise() subroutine.

This won't however, solve the problem of ensuring new particle ID's don't overlap with existing ones...that's the crux of this particular problem unfortunately. Feng, you may find that GenGeo's MNTable3D.renumberParticlesContinuous() subroutine that might be of some benefit in working around this problem. See the API docs:
http://esys.esscc.uq.edu.au/lsmgengeo_python_doc/current/pythonapi/html/gengeo.MNTable3D-class.html

Cheers,

Dion

Revision history for this message
Feng Chen (fchen3-gmail) said :
#4

Thanks Dion Weatherley, that solved my question.