How to get the instant number of particles?

Submitted by zhou_yu on Tue, 01/10/2017 - 12:36

I am doing a simulation of sandpile formation. I am wodering how can I get the instant number of particles in the sandpile since I use "lost ignore" to delete the paticles that gose to far from the pile.

Actually, I want to use this number in a judgement condition of a loop to control the max number I should pour on the sandpile.

I noticed that thermo_style has an argument of atoms that can output this number on screen, and this number should equals to the number of entries in the ouput of a compute atom command. but this two cant be used as a variable in the input script. So if there is any simple method to get this number as a usable variable?

Besides if I am using a polydisperse multisphere insertion template, thermostyle can only output the number of atoms not the number of clump particles. In this condition, how can I achieve the goal of controlling the total number of particles in a sandpile?

Any suggestion is appreciated.

msandli | Wed, 01/11/2017 - 23:08

might be able to assign a variable name to it. something like:
variable num equal count("group")

then you can use the variable name ${num} in other statements in your simulation

zhou_yu | Thu, 01/12/2017 - 14:20

Thanks for your hint and that really works! But not for multisphere clump systems, the error message says count(group) dose not work with multisphere.
So I still need to find another way.

msandli | Sat, 01/14/2017 - 03:16

I see I didn't read to the end of your comment. If all of your multisphere atoms look the same, you might be able to do it based on mass. calculate the mass of all your particles, and then define a variable that divides that by the mass of one particle. i've never run a multisphere simulation, so I don't know what commands do and don't work on multispheres.

zhou_yu | Sat, 01/14/2017 - 04:13

Thank you all the same. I am using polydisperse multispheres system, I dont really know which multisphere clump was inserted, so the mass is unassured. The number of entries of the output file of compute multisphere command equals the number of remained nultisphere clumps, so there must be a way.
According to this point, I have written a python script to get the number of particles from the outputfile. I am wodering whether inscript can use a extraneous variable during the running process.

richti83's picture

richti83 | Mon, 01/16/2017 - 09:41

There is an undocumented flag for fix multisphere "allow_group_and_set yes" which allows you to use count function on clumps.
The total number of particles is stored in system variable atoms so variable N equal atoms will give you the same as variable N equal count(all)
To get the number of clumps I think the thermo.cpp needs to be extended to count number of molecules (bodies) or fix_multisphere needs a compute_vector method which returns the number of bodies.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

sbateman | Tue, 01/17/2017 - 18:33

You might be able to use the "compute multisphere" with the "id_multisphere" option, and the "compute reduce" with the "max" option. Or maybe the "compute multisphere" with "atomtype" or "clumptype" options, and the "compute reduce" with "sum", and do some math if all your clumps have the same type.