# Can I calculate per-atom quantity in fix command?

Dear all,

I want to implement 1-body external potential
like a “fix addforce” command.
Then, I want to compute the potential energy
for each atom by using “per-atom”.
However, I cannot find the program which calculate
per-atom quantity in the fix command
whereas there are many fix command which calculate
global scalar or global vector.
Then, I have a question.
Can we calculate per-atom quantity in fix command?

Any fix which sets peratom_flag is storing one or more per-atom quantities.

Steve

Thank you Dr. Steve and Dr. Ray.

Then, how can we store per-atom variables?
According to the Manual (Sec. 10.3,and Sec. 10.5),
there is compute_peratom in compute command
but there is not in fix command.
I guess the methods compute_scalar, compute_vector, and compute_array
in fix class seem to be available only for the global variables.
Can we use it as the compute_peratom?

Sincerely yours,
Takenobu Nakamura

Thank you Dr. Steve and Dr. Ray.

Then, how can we store per-atom variables?
According to the Manual (Sec. 10.3,and Sec. 10.5),
there is compute_peratom in compute command
but there is not in fix command.

if course not. a fix is not a compute.

I guess the methods compute_scalar, compute_vector, and compute_array
in fix class seem to be available only for the global variables.
Can we use it as the compute_peratom?

have a look at fix.h

a fix can provide results as a scalar, and either a vector or an array.
if you set the peratom_flag, the vector or array is dimensioned to
match the number of (local) atoms and size_peratom_cols determines
whether you provide a vector (one property per atom) or an array
(multiple properties per atom). there is no need for an additional
method, since the fix is supposed to be called at the selected
stages of the MD or minimizer loops and it is you responsibility
to make sure the corresponding arrays contain the correct information.
unlike with a compute, those will have to be provided every time
the fix is invoked, not only when requested, like with a compute.

ok?

axel.

Thank you Dr. Kohlmeyer!

I understood what I have to do to make my fix command.
Moreover, I could understand the difference between fix and compute more clearly than ever!
Thank you.

Sincerely yours,
Takenobu Nakamura

(2012/11/24 21:25), Axel Kohlmeyer wrote: