writing per-atom vector to a file

I’m trying to calculate the average displacement of all atoms of a group during the simulation and write the value to a file every 500 steps. Two averaging: all atoms… during the time…
My problem is with dumping it into a file. I’m using these commands:

compute displ1 core displace/atom
fix displ1 core ave/atom 5 99 500 c_displ1[1] c_displ1[2] c_displ1[3] c_displ1[4]
dump displ1 core custom 500 tmp.displ1 f_displ1

Error:
ERROR: Dump custom fix does not compute per-atom vector

However, in the How to Section, I noticed dump custom command accepts per-atom vector :frowning:

I appreciate your help.

I'm trying to calculate the average displacement of all atoms of a group
during the simulation and write the value to a file every 500 steps. Two
averaging: all atoms.... during the time...
My problem is with dumping it into a file. I'm using these commands:

compute displ1 core displace/atom
fix displ1 core ave/atom 5 99 500 c_displ1[1] c_displ1[2] c_displ1[3]
c_displ1[4]
dump displ1 core custom 500 tmp.displ1 f_displ1

Error:
ERROR: Dump custom fix does not compute per-atom vector

However, in the How to Section, I noticed dump custom command accepts
per-atom vector :frowning:

that is all correct, consistent and working the way it should. you are
overlooking that fix ave/atom is outputting a per atom *array*, so you
have to output each array component (which is a per atom vector)
individually. sames as when you pass the output from the displace/atom
compute to the ave/atom fix.

axel.

Thank you so much for your help.

I came to the conclusion to use these commands:

compute displ1 core displace/atom
dump displ1 core custom 500 tmp.displ1 c_displ1[1] c_displ1[2] c_displ1[3] c_displ1[4]

Then post process averaging over atoms using python code.

Btw, I think it was perfect if there was no limitation of “per-atom vectors” for the dump input command. That is, it could accept any input to easily write into file. For example writing global scalars the same as the thermo_style custom.

Thank you so much for your help.

I came to the conclusion to use these commands:

compute displ1 core displace/atom
dump displ1 core custom 500 tmp.displ1 c_displ1[1] c_displ1[2] c_displ1[3]
c_displ1[4]

Then post process averaging over atoms using python code.

Btw, I think it was perfect if there was no limitation of "per-atom vectors"
for the dump input command. That is, it could accept any input to easily
write into file. For example writing global scalars the same as the
thermo_style custom.

it would be equally perfect, if LAMMPS could make you walk on water. :wink:

in general, limitations in LAMMPS exist for one or more of the
following reasons:
- it is technically difficult to implement or nobody has found a good
way to make it work yet
- it would result in complex, hard to read and maintain code
- nobody has cared enough to do it (remember LAMMPS' source code is to
a large degree contributed code)
- it would significantly impact performance

keep in mind that there already are fix print and fix ave/time (if you
average over a period of 1, you just get a dump) that can output
global properties to a file.

axel.

As Axel said, you can write global scalars to a file via thermo
output (log file) or to a file created by fix print of fix ave/time.

Dump files are for per-atom properties, not global
scalars. There are commands, like compute reduce
that will internally process per-atom values and
create global scalars, e.g. a sum or average, if
that’s what you want for average displacement.

Steve