# How to use the system temperature to control the force term?

Hi, there. I’m a newcomer of LAMMPS.

For some reason, I would like to use the difference between the desired temperature and the system temperature to control the force term and use the force term to control the temperature, just like the Nose-Hoover thermostat. Even though I can use Nose-Hoover thermostat to achieve my goal, I still want to make some modification.

The final structure may looks like:

Hi, there. I’m a newcomer of LAMMPS.

For some reason, I would like to use the difference between the desired temperature and the system temperature to control the force term and use the force term to control the temperature, just like the Nose-Hoover thermostat. Even though I can use Nose-Hoover thermostat to achieve my goal, I still want to make some modification.

The final structure may looks like:

==================================================
a = 0
b = 0
c = 0
d = 0
alpha = 1
beta = 1
gamma = 1

# repeat: a = alpha * (System Temperature - 300) b = b + beta * (System Temperature - 300) * delta Time c = gamma * [d - (System Temperature - 300) ] / delta Time d = (System Temperature - 300) force for all atoms = force for all atoms * (a+b+c)

The last line can be seen as:
force(i,j) = force(i,j) * (a+b+c)
i = 1 to Number of atoms
j = x, y, z

This is what I want to achieve. I had used the following code to make a test, but it doesn’t work.

variable a equal temp * 0.0001
variable b equal temp * 0.0001
variable c equal temp * 0.0001
velocity all set \$a \$b \$c sum yes units box

The simulation finished without any error message, but the velocity term (or the temperature term of the system) doesn’t seem to be affected by the above code.

Is anyone can kindly tell me how to modify the code? I read the user manual and the example just like “variable beta equal temp/3.0”, but now, the variable “a” doesn’t seem to be changed by “temp * 0.0001”. Is it possible to use LAMMPS to achieve my goal directly or should I modify the source code of LAMMPS or insert a Python subroutine to achieve it?

​the velocity command is a one time operation. all LAMMPS commands are executed immediately. only commands that define a fix or some XXX_style will cause changes that (usually) apply to every step of a simulation or ​minimization.

if you want to implement experimental integrators, you can check out fix python/move. or need to do modifications to fix_nh.cpp and fix_nh.h.

axel.