How to out put the average x ,y ,z positions of atoms and the related id's?

Dear All,

I have a CNT which i have fixed one end and the other end (top end) is free. I want to output the average x , y and z positions of each atom of the top end and the related atom ids.
The following command out puts the id and related positions but not the average positions:
write_dump carbon_atoms custom final.data id type xu yu zu

I am trying to use fix/ave command but I am not sure how to tell it to output the atom ids and the related average x,y,z .

I tried the following wrongly:

variable xx equal xcm(carbon_top,x)
variable yy equal xcm(carbon_top,y)
variable zz equal xcm(carbon_top,z)
fix at2 all ave/time 10 10 100 v_xx v_yy v_zz file output_cnttop_ave.dat

the above is wrong as it gives me the ave position of the center of mass. I am not sure how to define my variables and how to get the fix/ave to output each atom id and it’s average position (x ,y,z)

Could you please help me with it?

Thanks a lot

Hi Delaram,
Indeed, for what you want to do, the command is fix ave/atom. You can then output the resulting averaged position per atom, as well as the atom id and type using a dump custom.
Best,
Simon

Thank you very much Simon, could you please tell me how to write the fix/ave, should it be v_x , v_y, v_z?

fix at2 all ave/time 10 10 100 v_x v_y v_z file output_cnttop_ave.dat

but x, y and z are not variables. I am not sure how to define the atom positions as variables.

Could you please help me to write the fix/ave command to output the average x y z of each atom, I couldn’t figure out how to define the required variables. Or is there any need to define x, y,z as variables necessarily to use in this command?

the following produces an error:
fix at2 all ave/time 10 10 100 x y z file output_cnttop_ave.dat

When you have these types of doubt, you can always find some examples from the documentation. For instance, from the fix ave/atom page, a given example is:

fix 1 all ave/atom 1 100 100 vx vy vz

The possible outputs are also given:

x,y,z,vx,vy,vz,fx,fy,fz = atom attribute (position, velocity, force component)

So from that you can guess that the following command should work just find :

fix 1 all ave/atom 1 100 100 x y z

1 Like

Thank you, I saw that in the documention after I asked the question, and fixed it, but I still get the following error

No values from computes, fixes, or variables used in fix ave/time command (src/fix_ave_time.cpp:71)
Last command: fix at2 all ave/time 10 10 100 x y z file output_cnttop_ave.dat

Thanks

You can’t refer to x y z in a ave/time command, only in a ave/atom.

1 Like

uh so careless of me. Thanks .