Access atom Coordinates every timestep and update fix command

I was trying to access coordinates of an atom every timestep in the simulation and also update the fix addforce command simultaneously as given below by looping
variable actforce equal 10
compute typei type1 property/atom xu yu zu
compute typej type2 property/atom xu yu zu
variable dx atom (c_typei[1]-c_typej[1])
variable dy atom (c_typei[2]-c_typej[2])
variable dz atom (c_typei[3]-c_typej[3])
variable d atom ((v_dxv_dx+v_dyv_dy+v_dz*v_dz)^(1/2))
variable delx atom ((c_typei[1]-c_typej[1])/v_d)
variable dely atom ((c_typei[2]-c_typej[2])/v_d)
variable delz atom ((c_typei[3]-c_typej[3])/v_d)
fix af type1 addforce ({actforce}*v_delx) ({actforce}*v_dely) (${actforce}v_delz)
uncompute typei
uncompute typej
unfix af
there was an error saying "Expected floating point parameter instead of '(10
v_delx)’ in input script or data file"
is there any better way of doing this,or to solve the error
thanks in advance for your input

Please see the forum guidelines for instructions on how to correctly quote LAMMPS input in messages.

The error you are reporting is a syntax error and thus have nothing to do with the chosen method.

When using equal style variables properly no loop and redefinition of fix addforce is needed. The value of the variable will be recomputed for every use.

1 Like

Hello Sir,
As per your suggestion i have made the corrections in the input script. I have been trying to verify whether force is being updated every timestep by fix addforce command, to confirm the accuracy of my simulation. I have attached the input script below for clarity.
in.lmp (1.3 KB)

Sorry, I am not your tutor or adviser and thus have no time to review and correct your inputs. What LAMMPS is doing is documented in the manual. If you have doubts about the correctness of the implementation, you need to create minimal input decks that demonstrate the difference to the documentation. If you want to validate the functionality for yourself, that will do as well. This is a standard procedure in doing computational research and thus not something specific to LAMMPS or to the commands in question. If you have problems with that, I would suggest you ask your adviser or colleagues for assistance.

Thank you