I want to add a force field that depends on the atom possition. I have tried to compute the atom position, the use that as a variable and then, set the force field but I get the messege:
ERROR: Variable name for fix addforce does not exist
the code I have tried is:
variable a equal c_X
variable extforce equal ${maxforce}*step/${eqrun}*a
fix externforce A addforce v_extforce 0 0
You need use an atom-style variable if you want it to vary depending on atomic position. I don't know what any of your other variables are, but as an example, this adds a y-component of force as a function of the x-position:
The error you're getting means you need to "use" the variable first, i.e. output it using the thermo_style command.