Nearest neighbours information at simulation time

Before anything else I’d encourage you to reflect on whether you really need to detect every single rupture event exactly on the moment it occurs. Or whether false positives are really as fatal to your simulations as you make them out to be. The underlying issue is that you are trying to automate something which may be very difficult to automate, and you should be wary about spending a lot of “programming time” at the risk of not saving much “operating time”.

In any case, I wonder if (following @mkanski 's idea) something like this may work for you:

compute grid carbons chunk/atom bin/2d x lower ${nx} y lower ${ny} ids once
compute gc carbons gyration/chunk grid
compute gca carbons chunk/spread/atom gc
compute gcmax carbons reduce max c_gca

The initial chunk/atom will build chunks of initially-nearby carbon atoms (ids once keeps the chunk labelling constant – if parts of the membrane drift relative to each other this could be occasionally updated). compute gyration/chunk calculates the spread of these atoms, and presumably if any one chunk has a “tear” this compute will increase beyond some threshold. If you’re worried about ruptures occurring between chunks, you could use a duplicate staggered grid.