ave/chunk and temp/com

Hello everyone,

According to the documentation, in the following statement:

fix T_slices1 all ave/chunk \{Nevery\} (v_Nevery_ave/v_Nevery) ${Nevery_ave} slices1 temp file slices1_equi.prof

"temp" refers to a compute defined as:

compute thermo_temp all temp

Of course that works fine. Now when I try the following:

compute myTemp all temp/com
fix T_comslices1 all ave/chunk \{Nevery\} (v_Nevery_ave/v_Nevery) ${Nevery_ave} slices1 c_myTemp file comslices1_equi.prof

I get an error message saying that "ave/chunk compute does not calculate per-atom values". Even though the output section of the documentation for temp/com is identical to that of temp (global scalar and global vector for both). What am I doing wrong?

Best,

Jonathan Severin

Hello everyone,

According to the documentation, in the following statement:

fix T_slices1 all ave/chunk \{Nevery\} (v_Nevery_ave/v_Nevery)
${Nevery_ave} slices1 temp file slices1_equi.prof

"temp" refers to a compute defined as:

​no, it doesn't. "temp" is a valid keyword and is described in the fix
ave/chunk documentation as follows:

​The temp value means the temperature is computed for each chunk, by the
formula KE = DOF/2 k T, where KE = total kinetic energy of the chunk of
atoms (sum of 1/2 m v^2), DOF = the total number of degrees of freedom for
all atoms in the chunk, k = Boltzmann constant, and T = temperature.

compute thermo_temp all temp

Of course that works fine. Now when I try the following:

compute myTemp all temp/com
fix T_comslices1 all ave/chunk \{Nevery\} (v_Nevery_ave/v_Nevery)
${Nevery_ave} slices1 c_myTemp file comslices1_equi.prof

I get an error message saying that "ave/chunk compute does not calculate
per-atom values". Even though the output section of the documentation
for temp/com is identical to that of temp (global scalar and global
vector for both). What am I doing wrong?

​you are misreading the docs. you would be using thermo_temp compute only,
if you were averaging over c_themo_temp and then you will get the same
error message (or one telling you that thermo_temp has not been defined
yet, depending on where you place the fix command in your input).

axel.​

Thank you, I misunderstood the meaning of the error message: it actually means that ave/chunk does calculate per-atom values… After some tinkering with atom-style variables I ended up with this:

variable tempWcom atom “0.5mass(all)((vx - vcm(all,x))^2 + (vy - vcm(all,y))^2 + (vz - vcm(all,z))^2)/1.5/8.61733e-5”
fix T_comslices1 all ave/chunk {Nevery} (v_Nevery_ave/v_Nevery) ${Nevery_ave} slices1 v_tempWcom file comslices1_equi.prof

Now that doesn’t look very promising (especially considering the “all” keywords I had to use for the group arguments). Supposing that the number of DOF I must consider is 3 for the 3 dimensions, will that variable definition give me the temperature of the chunks after subtracting the velocity of the chunk’s center of mass?

Best,

Jonathan Severin

Thank you, I misunderstood the meaning of the error message: it actually
means that ave/chunk *does* calculate per-atom values...

​that statement is incorrect, too. the error message was about the compute
*used* by fix ave/chunk, not about fix ave/chunk itself. fix ave/chunk
computes *per chunk* values, and not per atom data.

After some tinkering with atom-style variables I ended up with this:

    variable tempWcom atom "0.5*mass(all)*((vx - vcm(all,x))^2 + (vy -
vcm(all,y))^2 + (vz - vcm(all,z))^2)/1.5/8.61733e-5"
    fix T_comslices1 all ave/chunk \{Nevery\} (v_Nevery_ave/v_Nevery) ${Nevery_ave} slices1 v_tempWcom file
comslices1_equi.prof

Now that doesn't look very promising (especially considering the "all"
keywords I had to use for the group arguments). Supposing that the number
of DOF I must consider is 3 for the 3 dimensions, will that variable
definition give me the temperature of the chunks after subtracting the
velocity of the chunk's center of mass?​

​i don't give predictions about LAMMPS input code, and - quite frankly -
seeing something like this, makes my head hurt.
why don't you make a simple test?

...and i would also have another look at the documentation. in cannot help,
but have the nagging feeling, that you are trying to do something in the
most complex and backwards way, that is already available through the
"bias" option.

axel.​

I’ve come up with two options. First one is using an atom-style variable like:

variable tempWcom atom "0.5mass((vx - vcm(all,x))^2 + (vy - vcm(all,y))^2 + (vz - vcm(all,z))^2)/1.5/8.61733e-5/9648.53295
fix T_comslices1 all ave/chunk {Nevery} (v_Nevery_ave/v_Nevery) ${Nevery_ave} slices1 v_tempWcom file comslices1_equi.prof

Unfortunately that doesn’t work because vcm(all) yields the center of mass velocity of the whole system and not just that of one chunk. I’ve checked that indirectly by printing out the value of mass(all).

Second option is to use the bias keyword as advised:

compute tempWcom all temp/com
fix T_comslices1 all ave/chunk {Nevery} (v_Nevery_ave/v_Nevery) ${Nevery_ave} slices1 temp bias tempWcom file comslices1_equi.prof

Unfortunately, I currently have no way to check if this subtracts the CoM velocity of one chunk or that of the whole system. Once again I’m confused with the compute definition using the “all” keyword. Can someone with more knowledge then I have confirm that this should work as expected?

Best,

Jonathan Severin

Sorry, I re-scanned this thread and don’t see where you give

an explanation of what you are actually trying to do. It’s

just many formulas and unclear Qs (to me).

The temp option for fix ave/chunk has several paragraphs

on the doc page of exactly what it computes. It is

the “correct” temperature per chunk by standard definitions,

including how it handles the DOF of the chunk atoms.

(we got this wrong the first time, someone corrected us)

If it’s not what you want, you might have to roll your own,

e.g. by post-processing.

If you have a detailed Q about what fix ave/chunk is calculating,

you can verify it yourself. Write out a dump file with

the atom velocities (or whatever), with their chunk IDs (from

the compute chunk/atom command), and you can calculate

chunk-by-chunk whatever you want, including what fix

ave/chunk is supposed to be doing.

Steve

Thank you for the answer. What I want to do is simply to compute the chunk temperature based on atomic velocities from which the chunk’s center of mass velocity has been subtracted. I tried using an atom-style variable that I provided to ave/chunk (the formulas in the previous message) but that doesn’t work since the vcm(all) function works on the whole system and not simply on one chunk. Then as was advised I looked at the bias keyword for ave/chunk. I’m not sure I understand how it works. The documentation says that the argument of bias is the

ID of a temperature compute that removes a velocity bias

So I my questions are : Can I use compute temp/com with this bias keyword? And how should I define this compute so that it subtracts the chunk’s com velocity (and not the whole system’s)?

Best,
Jonathan Severin

"Unfortunately, I currently have no way to check if this subtracts the CoM velocity of one chunk or that of the whole system. " This is clearly not true. There are lots of way you could check this. For example, build a system with two clusters of atoms of equal size, with equal and opposite velocities.

Anyway, it seems pretty clear from the documentation of compute temp/com that this will remove the CoM motion of the entire group, not the chunk. The thing that does what you want is compute temp/chunk with ‘com yes’, which you can then time-average using fix ave/time.

Aidan

So I my questions are : Can I use compute temp/com with this bias keyword? And how should I define >this compute so that it subtracts the chunk’s com velocity (and not the whole system’s)?

This won’t work for what you want.

The bias compute temp/com provides is subtracting the COM of the entire

system from every atom. It has nothing to do with chunks.

The compute temp/chunk command does what you want, if you use its COM

keyword. Note this paragraph on its doc page:

Note that the per-chunk temperature calculated by this compute and the fix ave/chunk temp command can be different. This compute calculates the temperature for each chunk for a single snapshot. Fix ave/chunk can do that but can also time average those values over many snapshots, or it can compute a temperature as if the atoms in the chunk on different timesteps were collected together as one set of atoms to calculate their temperature. This compute allows the center-of-mass velocity of each chunk to be subtracted before calculating the temperature; fix ave/chunk does not.

If you want to time-average what compute temp/chunk produces (a global array of temp per chunk), you could use a column of it as input to fix ave/time in its vector mode. This will not do the fancy

stuff that fix ave/chunk temp does with combing atoms across timesteps to accumulate one temp,

as on its doc page:

Note that the per-chunk temperature calculated by this fix and the compute temp/chunk command can be different. The compute calculates the temperature for each chunk for a single snapshot. This fix can do that but can also time average those values over many snapshots, or it can compute a temperature as if the atoms in the chunk on different timesteps were collected together as one set of atoms to calculate their temperature. The compute allows the center-of-mass velocity of each chunk to be subtracted before calculating the temperature; this fix does not.

Steve

Thank you Steve and Aidan for your answers, this worked for me:

compute tempWcom all temp/chunk slices temp com yes
fix T_slices all ave/time 10 100 1000 c_tempWcom file slices_equi.prof mode vector

Best,

Jonathan Severin