Inconsistent Thermo Output with fix-HALT and run 0 Command

Dear LAMMPS Community,

I’m seeking some help with a strange behavior of run 0 command I’m encountering while simulating frictional granular media using LAMMPS version 2 Aug 2023.

I’ve attached a sample input script for reference (“lmpgran.compress”). As you can see, I’m using the fix HALT command to stop the simulation when the value of v_maxforce falls below 1e-4. Additionally, I’m using run 0 to print thermo output at the exact step where the fix_HALT condition is met.
The problem is this is giving some strange values of v_maxforce (0.67…) along with c_cfx and c_cfy.

I have also printed the thermodynamic outputs to a separate file “thermo.dat” (attached herewith) It shows the same step is printed twice but the values of last 3 columns ( c_cfx, c_cfy and v_maxforce) are different in both cases.

Therefore, I’m reaching out to the community for guidance and assistance. If anyone has encountered similar issues before or has insights into why this might be happening, I would greatly appreciate your input. I have also attached the log-file (“log.lammps”) and “restart.suspend” file herewith.

Thank you in advance for your help and support. I’m looking forward to your responses and insights.
thermo.dat (56.7 KB)
restart.suspend (3.5 MB)
log.lammps (11.3 KB)
lmpgran.compress (2.1 KB)

You are using a granular pair style where velocities are part of the force computation.

Since LAMMPS uses velocity Verlet time integration, there has been a (half) update of the velocities (fix->final_integrate()) after the mid-timestep position update and force computation before fix halt is executed (at fix->end_of_step()). With run 0 you are executing the setup() step which will recompute the forces (before fix->initial_integrate()). This works as expected with “regular” pair styles where the forces depend only on positions (and orientations), but is slightly inconsistent for any pair style where the velocities play a role (e.g. also DPD pair styles). see: 4.7. How a timestep works — LAMMPS documentation

You would have to make significant modifications to the timestepping, similar to what is done in fix mvv/dpd command — LAMMPS documentation, to avoid this behavior.

Thank you so much for the explanation. I’ll give those a try first and see if I can achieve consistent results.