Guide to Lammps - Thermostatting

There are various ways of thermostatting a model in LAMMPS. This example presents a Berendsen thermostat keeping a constant temperature of 300 K in most of the model, except a sphere with a temperature of 400 K.

# --------------------- Regions Defs -------------------
region heatedRegion7 sphere 24.99 24.99 24.99 23.205 units box

# --------------------- Dynamics --------------------------------------
fix dynamics all nve

fix reservoir all temp/berendsen 300.0 300.0 0.0001

fix 7 all temp/berendsen 400.0 400.0 0.0001
compute heatedTemp7 all temp/region heatedRegion7
fix_modify 7 temp heatedTemp7

Like previously, The command region defines a region in space. This region will later be heated differently. As one can deduce, it creates a sphere centred at (24.99, 24.99, 24.99) with a radius of 23.205 Å. Default choice specifies the parameters in lattice units. using the keywords 'units box' specifies the parameters in metric distance units.

The thermostat we are using does not perform time integration. This means it adjusts the velocities of the atoms based on specified temperature, but does not adjusts locations. To do that, we need to use a fix command which performs time integration, adjusting both locations and velocities in a manner constistant with the microcanonical ensemble. 'dynamics' is the name assigned to this fix.

The command fix temp/berendsen is our thermostat. The fix is named 'reservoir' and it is applicable on all atoms. The algorithm used is Berendsen's algorithm. The two following values specify the starting temperature and ending temperature during the following run. The last value specifies the damping parameter. This determines the rate at which temperatures are being adjusted. In this example, 0.0001 means it is adjusted every 0.0001 nsec, which is also the timestep chosen. Thus, temperatures are adjusted every step in the simulation. Choosing higher values result in slower adjustments. Choosing too high a value, with a short run, might result in a non functioning thermostat.

The command compute defines a computation done on a group of atoms. The computation is named 'heatedTemp7', it is done on all atoms and consists of a temperature computation done in the region 'heatedRegion7'.

The command fix_modify changes a previous fix. In this example, it changes the temperature of fix '7' to be computed using the previously defined computation, 'heatedTemp7', meaning temperature adjustment is done only in the region 'heatedRegion'.

To summarize, the three commands fix-compute-fix_modify are used to define a thermostat in a specific region in space.

Make note that Berendsen's thermostatting algorithm is an efficient algorithm to rescale velocities of atoms, thus controlling the temperature. However, it does not produce results consistent with the canonical ensemble for small systems. For systems of the orders of hundreds or thousands of atoms, most attributes are approximated rather well.

There are other ways to control the temperature of a model. For example, it is possible to use Lengavin's thermostat for dissipation instead, or use a simple temp/rescale algorithm. The temp/rescale algorithm simply multiplies the velocities, increasing or decreasing the temperature. This means static atoms remain static in this method, which is why it is important to assign initial velocities to the atoms. Make note that the temp/rescale is considered unstable and is not recommended for use, and also not considered a coupling with a heat reservoit. It is more similiar to a momentary "kick" given to the system. For accurate results consistent with ensembles, one may consider 'fix nvt' or 'fix npt'. It is worth noting that the different thermostats should not produce significantly different results. If this is the case, it is likely that the simulation is ill-defined.

To continue in the LAMMPS guide, press here.
To return backwards in the LAMMPS guide, press here.