Save position and velocities

Hi,

I’m performing a simulation in which I use LAMMPS to calculate the mean square displacement of some particles at certain times calculated through the logfreq3 function. This is the relevant part of the code I’m using.

group A type 1
group B type 2 # B is smaller
compute msdA A msd # default com=no and average=no so rvec(t=0) used
compute msdB B msd # default com=no and average=no so rvec(t=0) used

variable tmsd equal logfreq3(1,200,100000)
variable tLJ equal step*dt
thermo_style custom v_tLJ c_msdA[4] c_msdB[4]
thermo v_tmsd

Is there a way to make LAMMPS print the system configuration (position and velocities) only at (some of the) tmsd times?

With the dump command I can only dump periodically (the dump function expects an integer parameter) but not at the computed tmsd times which are, for example: 18.485 19.59 20.755 21.99 23.3…

Thank you

How about using the ceil() function to round the value of the tmsd variable up to the next integer value?

Please also see the discussion of using a variable dump frequency in the documentation of the dump_modify command — LAMMPS documentation (check out the section and the examples for the every keyword).

Thank you, I think I will mention you in the acknowledgements section of my thesis. :slight_smile:

Hello, again.

I have solved the problem of saving position and velocities at certain times.

Now I want to put the code in the first post in a loop inside the LAMMPS file.
Without the loop LAMMPS would send the output with the mean square displacement to a file (e.g. mpirun file.lammps > msd_data ), I have no problem doing that and it works.

I am running the simulation for 100000 steps with

fix nve1 all nve
run 100000

Is there a way to make LAMMPS save the mean square displacement at every tmsd time (defined in the code in the first post) in a separate file and not the general output file?

I tried to use the fix command with something like

fix msdA A ave/atom 1 1 v_tmsd c_msdA[4] file msdA_data

but it complains because it needs integer values.

Should I somehow specify the times at which I want the msd saved like in the dump command? I cannot find an “every” option which takes a variable as input for the fix command.

Thank you.

Two things:

  • you must not use variable references (like v_name) unless the manual explicitly says it is allowed. the individual command must have been programmed to support it and hence each instance is documented.
  • you cannot have output of any of the averaging fixes at variable timesteps because of the way how the averaging is done and how data is stored (or rather excessive data storage avoided).

Thanks, I think I will put the lammps script file in for cycle within a bash script, then. If I put the loop variable in the output filename (msd_01, msd_02 etc) it should work, I hope.