writing the data from a variable command to a output file

Dear LAMMPS users,

I’m just a beginner and simulating a single polymer in a solution. I have calculated the centre of mass position and velocity of the polymer using the variable command.

variable Xcm equal xcm(polymer,x)
variable Ycm equal xcm(polymer,y)
variable Zcm equal xcm(polymer,z)

and

variable XVcm equal vcm(polymer,x)
variable YVcm equal vcm(polymer,y)
variable ZVcm equal vcm(polymer,z)

I’m trying to write this data to two files each with three columns, 1. CMposition.dat 2. CMvelocity.dat As I understand this can’t be done using any of the output commands, dump, fix ave, and compute. I can use thermo_style command in the following way - thermo_style custom v_Xcm v_Ycm v_Zcm - but it writes some unwanted information at the beginning and end of the file. Also, this command can’t be used a second time to write centre of velocities to another file. I also tried fix print command in this way - fix CM polymer print 100 “$v_Xcm $v_Ycm $v_Zcm” file CMposition.dat - but this is also not working.

I have read the manual section on output commands, if I’m missing something please point me to there. A simple fprintf like statement with out any constraints would be very helpful to write the data to files as the user would like.

Thank you very much.

Sridhar Kumar Kannam,
Research Fellow.

You can use the fix ave/time command to write variable values to
a file (and time average them if you wish).

Steve