thermostating atoms in a region

Dear Niall:

Thank you very much for kindly answering my question. To make sure that I get your idea right and also help other users with similar questions, could you check if the following script is correct implementation of your idea?

region middle_region block x1 x2 INF INF INF INF units box

compute comp_mid midFluids temp/region middle_region

fix 1 all nve

fix controlT all temp/rescale 20 300 300 0.01 1.0
fix_modify controlT temp comp_mid

Thank you very much and happy holidays!

With best regards,


Re: [lammps-users] thermostating atoms in a region

Attachments: Message as HTML
You’re thinking along the right lines, but you need to use a fix_modify as well:

  1. Define a region which covers the bit of the box that you want to thermostat
  2. Use a fix command to set up the thermostatting you want (don’t worry about limiting it to a region just yet)
  3. Set up a compute temp/region to calculate the temperature in your region of interested
  4. Use fix_modify temp to associate that compute with the thermostatting fix.

So in your case, you need to use a fix_modify temp to associate your temp/region compute with your temp/rescale fix: fix_modify temp <temp/region compute ID> (


If LAMMPS was a house it should have a sign on the fence reading:
Explanations on why using temp/rescale is a bad idea have been
repeatedly posted on this list. See for example Axel's response on:
Use a Langevin thermostat instead. It is simple and will do the work
of controlling the temperature just fine.

That script looks to me like it should work. You can set up a model system pretty quickly and use something like ave/spatial to generate a temperature profile and check.