Problems in using fix addforce together with minimize

Dear LAMMPS uses and developers,

I met some problems in using fix addforce with minimize. The problem is though I have specified
fix_modify fix_ID energy yes
, I still have the error message,

ERROR: Must use variable energy with fix addforce (…/fix_addforce.cpp:192)

The system is very easy, one particle sitting on a sinusoidal surface. The contents of the two files are copied in the end and also attached.
So does anybody have suggestions about what is the problem?

Thanks!

Best wishes
Ming

in.minimize (636 Bytes)

sys.dat (312 Bytes)

From the fix addforce doc page:

The energy keyword is required if the added force is defined with one or more variables, and you are performing energy minimization via the “minimize” command. The keyword specifies the name of an atom-style variable which is used to compute the energy of each atom as function of its position.

That means the “energy” keyword for the fix addforce command. B/c
you are using a variable for the added force, you also have to provide
a 2nd variable when doing minimization that gives the energy, such
that -Grad(E) = Force. All this is explained on the doc page.

Steve

Hi Steve,

Thanks for your explanation. I’m sorry for having not read the doc carefully.

Best
Ming

Hi Steve,

Sorry to bother you again. Follow you suggestion, now I’m able to do the minimization. However, the results seems to be not right.
Apparently, though LAMMPS run successfully, the force output in the log file on the atom is not zero (~ 1), which means that the energy corresponding to the force applied via fix addforce seems not being added to the potential energy during minimization. Am I doing something wrong?
The contents of the two files are copied in the end and also attached.

Best
Ming

in.minimize (774 Bytes)

sys.dat (312 Bytes)

Hi Steve,

I found that I made a mistake in the input, which is I forgot the minus sign for the energy. After correct it, it works now. Sorry for having bothered you.

Best
Ming

in.minimize (774 Bytes)

sys.dat (312 Bytes)