Getting vector length or array size of a compute output

Hi all,

I have recently run into a snag while using LAMMPS. My simulation creates bonds between particles (fix bond/react) and breaks some of these bonds when they are stretched (quartic bond style). I use “compute <compute_id> <group_name> property/local btype batom1 batom2” to keep track of which particles are bonded at a given time. I then use the “dump local” command to output this information in a data file. My question is simple: how do I get the number of bonds at any given time? Note Because the quartic bond style allows for bonds to be broken if the particles are far enough apart, the number of bonds in the system is not the same as the number of reactions output by “fix bond/react”. Since the output of the “compute” is an array, with the number of rows being the number of bonds, i.e., how do I get the number of rows of this “compute” output and use it in the same input script?

Here is my workflow:

For all timesteps:

  1. Make some bonds using bond/react, and maybe break some bonds due to quartic bond style
  2. Compute the number of bonds in the current time step
  3. Calculate how many more bonds to make based on the current number of bonds.

I hope this all makes sense, and I hope there is an easy solution to my issue. Thank you all for your time!

Cheers,

I can see a possible solution for point 2 (assuming that you are not trying to create bonds every step).
You can use the “every” option to the “run” command to run the “delete_bonds” command during a run (removing all bonds with type 0) to consolidate the number of bonds and right after that, you can access the “bonds” thermodynamic property (e.g. from a variable) and it should contain the accurate number of bonds (since no broken quartic bonds should exist at this point).

However, I am at a loss with point 3.