thermostating atoms in a region

Dear Lammps users:

In a box of liquids, I wish to maintain the temperature of fluids in region x1 < x <x2 to a fixed value. How can we accomplish this?

My idea is to use “fix temp/rescale”, which requires a group-ID. Since atoms in region x1 < x <x2 moves in/out of this region during simulation, we have to define a dynamic group. Maybe we can use “compute temp/region” to solve this? Specifically, since “compute temp/region” does have a group-ID as argument, maybe this command will generate a dynamic group, which can be put as input to the “fix temp/rescale” command? Specifically, will the following script work?

region middle_region block x1 x2 INF INF INF INF units box
compute 1 midFluids temp/region middle_region

fix 2 midFluids temp/rescale 20 300 300 0.01 1.0

Thank you very much for your time.

With best regards,


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> (