A couple of wishes for LAMMPS and fix ave/spatial

Here are a couple of wishes for LAMMPS and the fix ave/spatial
command. I frequently use fix ave/spatial to measure
position-dependent properties over the course of an entire simulation.

1. It would be nice to be able to stop LAMMPS in the middle of a
simulation (i.e. jump to the last timestep) and still print out the
fix ave/spatial values in a file. I know that I could print out block
averages every so often, but then I have to combine those at the end
and only have data from the previous blocks. Other codes I have used
check every so often for a file like stop.txt and if they find the
file then the simulation dumps out all the data and ends.

2. It would also be nice to be able to print out a running average
using fix ave/spatial every so often instead of just printing out
separate independent blocks. This way if a job crashes I won't lose
all the data that has accrued over the course of the simulation.

Just a few thoughts--let me know if anyone has any suggestions.

Thanks,

Stan

Fix ave/spatial has an ave running option - see the doc page.

We could implement a fix that looked for a file like stop.txt
every N steps and triggered an exit, even from the middle
of a run. But it would be awkward for fixes like the averaging
ones to do anything intelligent. That could happen anywhere
in the middle of a cycle of averaging and the stored fix quantities
would be in a variety of states. Just like a dump file, it's
easy to specify periodic output from the fix, so I'm not clear
why that isn't sufficient?

Steve

Fix ave/spatial has an ave running option - see the doc page.

We could implement a fix that looked for a file like stop.txt
every N steps and triggered an exit, even from the middle
of a run. But it would be awkward for fixes like the averaging
ones to do anything intelligent. That could happen anywhere
in the middle of a cycle of averaging and the stored fix quantities
would be in a variety of states. Just like a dump file, it's
easy to specify periodic output from the fix, so I'm not clear
why that isn't sufficient?

Steve

Steve,

The ave running option is useful for me--thanks for pointing that out.
Right now though if I output the running average too frequently it
leads to a very large file, and I just need the latest value of the
running average. When using fix ave/spatial and ave running, perhaps
it would be nice to add an option to allow LAMMPS to overwrite the
file (i.e. similar to the restart file).

Thanks,

Stan

Interesting idea, presumably
you want the file header to be re-written out
every time in rewrite mode?

Steve

Yes, I think re-writing out the header file every time would be best

Thanks,

Stan

Dear all,

I too would be very interested by such an option for fix ave/spatial,
and maybe even more for fix ave/correlate.

Best regards,
Laurent

The attached code seems to work for fix ave/spatial. It should be
easy to add this modification to other fix ave styles that include a
running average option (like fix ave/correlate).

Stan

fix_ave_spatial.h (4.47 KB)

fix_ave_spatial.cpp (41.8 KB)

Posted a patch for this yesterday, applied
to all the ave fixes.

The use of ftell/fseek was a clever way
to do this Stan.

Thanks,
Steve