class NonEquilibriumMomentumExchange(configuration, exchange_interval, heat_source, heat_sink, update_profile_interval=0, profile_resolution=None)

A class that implements a heat flow by non-equilibrium momentum exchange (reverse non-equilibrium MD (RNEMD)) technique via a hook function.

  • configuration (BulkConfiguration) – The initial configuration on which the heat flow simulation will be performed.
  • exchange_interval (int) – After each exchange_interval iterations, a velocity swapping is performed between the hot and the cold region.
  • heat_source (str | list of ints) – The tag or list of indices defining the group of atoms in the hot region.
  • heat_sink (str | list of ints) – The tag or list of indices defining the group of atoms in the cold region.
  • update_profile_interval (int) – The interval at which a measurement of the temperature profile is performed and added to the average profile. Set to zero to disable on-the-fly measurement.
    Default: 0
  • profile_resolution (PhysicalQuantity of type length) – The spatial resolution for the on-the-fly calculation of the temperature profile.
    Default: 2.0 * Angstrom
Returns:The average heat current.
Return type:PhysicalQuantity of type energy/time
Returns:The call interval of this hook function.
Return type:int
nlprint(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)

Print a formatted string with the average temperature profile, as well as the average heat current.

Parameters:stream (A stream that supports strings being written to using 'write'.) – The stream the temperature profile is written to.
Returns:The temperature profile as a tuple containing bin-centers and corresponding temperature values.
Return type:(PhysicalQuantity of type length, PhysicalQuantity of type temperature)

Usage Example

Perform a molecular dynamics run of 5000 steps on a carbon nanotube. Momenta of two particles in the hot, respectively cold region are exchanged every 100 steps.

# Set up configuration
bulk_configuration = NanoTube(3,1)

# Add tags
nano_tube.addTags('cold', [0, 1, 2, 3, 5, 6, 7, 10, 11, 16, 17])
nano_tube.addTags('hot',  [24, 30, 31, 35, 36, 37, 41, 42, 45, 46, 47, 48, 49, 50, 51])

# Set calculator
calculator = TremoloXCalculator(parameters=Tersoff_C_2010())

method = NVEVelocityVerlet(

momentum_exchange_hook = NonEquilibriumMomentumExchange(

md_trajectory = MolecularDynamics(


  • The reverse non-equilibrium momentum-exchange (RNEMD) method is implemented as a class, which can be used as a post_step_hook in MolecularDynamics.
  • The momenta of the coldest particle in the heat_source group of atoms and the hottest particle in the heat_sink group are exchanged at a given interval. This exchange produces a temperature gradient, and an interal flow of energy between the two groups of atoms. Both quantities can be measured and the thermal conductance can be calculated using Fourier’s law. For more details regarding the RNEMD technique, please consult Refs. [MP97] and [NDA03].
  • If a non-zero update_profile_interval is specified, a temperature profile is stored on-the-fly during the simulation. After the MD run, the profiles may be accessed using the method temperatureProfile.

[MP97]F. Mueller-Plathe. A simple nonequilibrium molecular dynamics method for calculating the thermal conductivity. J. Chem. Phys., 106(14):6082–6085, 1997. doi:10.1063/1.473271.
[NDA03]C. Nieto-Draghi and J. B. Avalos. Non-equilibrium momentum exchange algorithm for molecular dynamics simulation of heat flow in multicomponent systems. Mol. Phys., 101(14):2303–2307, 2003. doi:10.1080/0026897031000154338.