Here is a brief test in.file about variable chunkID atom c_Nchunk and the test results of the lammps-2022Jun23 compiled by Intel on a single processor on MobaXterm.
Obviously, the variable only assigns the total number of chunks to each atom instead of chunkID. c_Nchunk is considered as a global scalar(total number of chunks) instead of per-atom vector(chunkID).
Your analysis is incorrect. The problem is that you are connecting the atom style variable to the compute, but the compute is “non-current” in between runs and thus cannot be accessed and will produce inconsistent or random data.
You need a “cache” that makes the data properly permanent. Fix store/state can be used for that.
compute cluster Ncell cluster/atom 2.5
compute Nchunk Ncell chunk/atom c_cluster compress yes nchunk once ids once
fix storechunk all store/state 0 c_Nchunk
variable chunkID atom f_storechunk
run 0 post no
fix R Ncell rigid/nve custom v_chunkID
run 2 post no
write_dump all custom dump.chunk id v_chunkID
It does. You are creating thermo output which is during a run, if you would add “c_cluster” to the write_dump command in my example, you will get:
ERROR: Compute used in dump between runs is not current (src/dump_custom.cpp:567)
And if you use the compute in a variable and add the variable to the write_dump line you get:
ERROR: Variable clusterID: Compute used in variable between runs is not current (src/variable.cpp:1571)
Using fix store/state can give you access to both with the example input changed as follows:
compute cluster Ncell cluster/atom 2.5
compute Nchunk Ncell chunk/atom c_cluster compress yes nchunk once ids once
fix storechunk all store/state 0 c_Nchunk c_cluster
variable chunkID atom f_storechunk[1]
variable clusterID atom f_storechunk[2]
run 0 post no
fix R Ncell rigid/nve custom v_chunkID
run 2 post no
write_dump all custom dump.chunk id v_chunkID f_storechunk[1] f_storechunk[2]
You mean that compute Nchunk only performs calculation at the 0 timestep and cannot be invoked at other timesteps, right? But even in timestep 0, the value of v_chunkID is also incorrect in preNchunk.txt.