Is it possible to dump conservative forces only?

Running the following input script with the thermostat commented out

units lj
dimension 3
atom_style atomic
pair_style lj/cut 2.5
boundary p p p

region box block -5 5 -5 5 -5 5
create_box 1 box
create_atoms 1 single 0 0 0
create_atoms 1 single 1 0 0
create_atoms 1 single 0 1 0

mass 1 1
pair_coeff 1 1 1.0 1.0

dump my_dump all custom 1000 "md.lammpstrj" id type x y z fx fy fz

velocity all create 1.0 4928459 mom yes rot yes dist gaussian
fix mynve all nve
# fix mylgv all langevin 1.0 1.0 0.1 1530917 zero yes
timestep 0.005
run 300000

yields a dump file that starts like this

ITEM: TIMESTEP
0
ITEM: NUMBER OF ATOMS
3
ITEM: BOX BOUNDS pp pp pp
-5.0000000000000000e+00 5.0000000000000000e+00
-5.0000000000000000e+00 5.0000000000000000e+00
-5.0000000000000000e+00 5.0000000000000000e+00
ITEM: ATOMS id type x y z fx fy fz
1 1 0 0 0 -24 -24 0
2 1 1 0 0 22.875 1.125 0
3 1 0 1 0 1.125 22.875 0

I verified by hand that the fx fy fz forces are the conservative forces as calculated by the lj/cut pair style. If I uncomment the thermostat line, the output changes to

ITEM: TIMESTEP
0
ITEM: NUMBER OF ATOMS
3
ITEM: BOX BOUNDS pp pp pp
-5.0000000000000000e+00 5.0000000000000000e+00
-5.0000000000000000e+00 5.0000000000000000e+00
-5.0000000000000000e+00 5.0000000000000000e+00
ITEM: ATOMS id type x y z fx fy fz
1 1 0 0 0 14.1429 -30.0936 60.4325
2 1 1 0 0 -14.5625 23.4622 -90.0978
3 1 0 1 0 0.419578 6.63142 29.6653

Clearly fx fy fz now reflect the effect of the thermostat.

For a force field machine learning project, I am explicitly interested in the conservative forces at every dumped timestep of an NVT simulation. Is there a way to dump the conservative forces only?

I already figured out that there are thermostats that do not seem to affect the forces, such as nvt, but naively replacing nve and langevin with fix 1 all nvt temp 300.0 300.0 $(100.0*dt) leads to lost atoms in this example.

No.

That means your starting configured is far from equilibrium.

You should be able to first bring the system to equilibrium with fix nve+langevin and then switch to fix nve later. If not, you have a more general problem with your simulation setup altogether.

1 Like