How to write total potential energy to dump file?

I use

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

To get a dump file that looks like

ITEM: TIMESTEP
0
ITEM: NUMBER OF ATOMS
1150
ITEM: BOX BOUNDS pp pp pp
-2.0000000000000000e+01 2.0000000000000000e+01
-2.0000000000000000e+01 2.0000000000000000e+01
-2.0000000000000000e+01 2.0000000000000000e+01
ITEM: ATOMS id type x y z fx fy fz
970 1 4.46152 -19.8825 -19.4972 75.0494 -51.9012 106.525
798 1 1.07741 -17.5784 -19.3535 -18.5085 -58.8937 -37.7941
...

I would like to include the total energy of the system (i.e. pe as can printed to the terminal by thermo) in the dump file, to get something like

ITEM: TIMESTEP
0
ITEM: POTENTIAL ENERGY <-------------------- new
1234.5678
ITEM: NUMBER OF ATOMS
1150
ITEM: BOX BOUNDS pp pp pp
-2.0000000000000000e+01 2.0000000000000000e+01
-2.0000000000000000e+01 2.0000000000000000e+01
-2.0000000000000000e+01 2.0000000000000000e+01
ITEM: ATOMS id type x y z fx fy fz
970 1 4.46152 -19.8825 -19.4972 75.0494 -51.9012 106.525
798 1 1.07741 -17.5784 -19.3535 -18.5085 -58.8937 -37.7941
...

I feel like this is a very basic use case, but from the documentation I only understand how to write per-atom properties with dump and system properties with other commands to different files…

The native dump file format in LAMMPS does not allow such global output. This is intended to be output in the log file via thermo_style custom or with fix print.

There are, however, two exceptions: the netcdf dump style and the yaml dump style.

2 Likes