Create new fix that stores data in restart file

Dear Lammps users and developpers,

I am playing with a new fix for calculating time correlation functions efficiently in long runs. It works nicely, but I want to store info about the fix in the restart files, so the calculation of the correlation functions can continue when the simulation is restarted.

I see there are options for this in the fix.h file, like restart_global or even restart_file (which seems to allow the fix to store its own restart file). However, there is not much info available on how to use them, and there are not many examples either (fix_nh.cpp seems to be the only one, but I’ve tried to emulate its behaviour with no success).

What is your recommendation? Should I go for the restart_file option? In that case, at what point during the restart of the simulation is the restart file of the fix read?

Thank you very for your help!

Regards,

Jorge

Dear Lammps users and developpers,

I am playing with a new fix for calculating time correlation functions
efficiently in long runs. It works nicely, but I want to store info about
the fix in the restart files, so the calculation of the correlation
functions can continue when the simulation is restarted.

I see there are options for this in the fix.h file, like restart_global or
even restart_file (which seems to allow the fix to store its own restart
file). However, there is not much info available on how to use them, and
there are not many examples either (fix_nh.cpp seems to be the only one,
but I've tried to emulate its behaviour with no success).

What is your recommendation? Should I go for the restart_file option? In
that case, at what point during the restart of the simulation is the
restart file of the fix read?

​please have a look at fix store/state

what you want to look at are Fix::​pack/unpack_restart() (and also
Fix::pack/unpack_exchange(), if you haven't done so already). those are for
communicating per MPI rank data.

axel.

However, there is not much info available on how to use them, and there are not many examples either (fix_nh.cpp seems to be the only one, but I’ve tried to emulate its behaviour with no success).

Try this: grep restart_global fix*cpp /fixcpp, which yields many fixes:

fix.cpp: restart_global = restart_peratom = restart_file = 0;
fix_atom_swap.cpp: restart_global = 1;
fix_deposit.cpp: restart_global = 1;
fix_event.cpp: restart_global = 1;
fix_event_prd.cpp: restart_global = 1;
fix_event_tad.cpp: restart_global = 1;
fix_gcmc.cpp: restart_global = 1;
fix_move.cpp: restart_global = 1;
fix_msst.cpp: restart_global = 1;
fix_nh.cpp: restart_global = 1;
fix_nh.cpp: int nsize = size_restart_global();
fix_nh.cpp:int FixNH::size_restart_global()
fix_nphug.cpp:int FixNPHug::size_restart_global()
fix_nphug.cpp: nsize += FixNH::size_restart_global();
fix_peri_neigh.cpp: restart_global = 1;
fix_rigid_nph.cpp: restart_global = 1;
fix_rigid_nph_small.cpp: restart_global = 1;
fix_rigid_npt.cpp: restart_global = 1;
fix_rigid_npt_small.cpp: restart_global = 1;
fix_rigid_nvt.cpp: restart_global = 1;
fix_rigid_nvt_small.cpp: restart_global = 1;
fix_ttm.cpp: restart_global = 1;

Steve