Hi all
The dump command has an option to use first yes to ensure that you can output at time-step 0 even if you are using an equal-style variable to specify the time-steps in dump_modify. E.g. if I want to output data on time-steps specified in some file timesteps.dat, I can use the following code-snippet to include also step 0 (as including 0 in the list of time-steps in the file is not allowed):
variable step_file file timesteps.dat
variable step equal next(step_file)
dump 1 all custom 1 file.dump x y
dump_modify 1 every v_step first yes
I was hoping there would be similar functionality in fix print but unfortunately there isn’t currently. Would it be useful to have a similar first yes for fix print? So e.g. the following code could work:
# store the x and y components of a single atom as variables to output
variable x equal x[1] # need to ensure atom_modify map yes is called prior to this
variable y equal y[1]
# get time steps (aside from 0) from file
variable step_file file timesteps.dat
variable step equal next(step_file)
# call the fix print which allows a (currently non-existent) 'first yes' keyword value pair to ensure output is printed at zero as well.
fix output all print v_step "${x} ${y}" file out.file screen no first yes
I can probably do this myself as it seems straightforward, but any reason why it wouldn’t be a good idea? The only thing I could think of is maybe LAMMPS doesn’t compute things on step 0 (so replacing “x[1]” above with “c_id[1]” may not give the expected output), but I’ve checked and that doesn’t seem to be the case. Thanks for any input.
If it just about outputting the coordinates of that atom, why not create a group and use a custom dump? That would also be more efficient since the variable evaluation will require an additional collective communication for each variable.
Hi Axel
Thanks for the reply.
If it just about outputting the coordinates of that atom,
The example I showed was overly simplified, my actual use case is not just outputting the coordinates of a single atom. Sorry for the confusion. I am actually interested in outputting values from a custom compute (which computes a vector type quantity) I’ve made. A better representation might be something like:
compute 1 all vacf
variable x equal c_1[1]
variable y equal c_1[2]
# get time steps (aside from 0) from file
variable step_file file timesteps.dat
variable step equal next(step_file)
# call the fix print which allows a (currently non-existent) 'first yes' keyword value pair to ensure output is printed at zero as well.
fix output all print v_step "${x} ${y}" file out.file screen no first yes
why not create a group and use a custom dump?
Could I still do this for the new example I just posted? I assume no but just making sure.
That would also be more efficient since the variable evaluation will require an additional collective communication for each variable.
Do you mean that the variable is communicated to all processors before it is output?
Thanks for your help.
All LAMMPS input script operations are global and executed concurrently on all MPI ranks, thus local data needs to be broadcast and computed properties may require reductions.
Hi Axel
Thank you for the reply. So are you suggesting that it is not a useful thing in general to add a “first” option to fix print?
For context, I am using fix print to output quantities like \sum_{i=1}^N cos(q.r_i(t)) on a logarithmic time scale which I can then use to compute the intermediate scattering function. So I need to have this quantity output at t=0.
FYI I have modified my local lammps source code to do this and it seems to work without any unintended consequences.