[lammps-users] fix thermal/conductivity. I can't have kinetic energy and linear temperature profile at same time

Dear Steve,
Thanks for your help. I tried what you taught me.
My system conserved the energy,and temperarture when running nve.
My difficulty is
If I run fix thermal/conductivity 1 z 24 1; I can get V shape linear temperature profile but kinetic energy was not conversed.
When I increased the Nevery parameter to 3000, the KE is conserved, however I can't get linear temperature profile...
I guess I should increase the number of swapping pairs. Am I correct? Or shall I change any other parameters in the script (see below)?

Best regards

When you say it isn't linear, you mean it's noisy or do you mean its curvilinear? When you swap velocities you will not strictly conserve energy. The more frequent the swaps, the worse the energy conservation will be. Think about how the swap is performed. The particle is happily moving in a local potential in one direction (probably very rapidly), then you switch that direction in a single timestep. The integrator isn't going to deal with the change well. The solution to your problem is to use the larger swap frequency and average for a much longer trajectory.

Quoting "Lu, Haiming" <[email protected]...>:

Dear Matt,
Thanks for your quick reply. I really appreciate your help.

When I say the temperature profile is not linear, I believe it is noise when setting fix thermal/conductivity 3000 z 24 1. I understand the KE can't be strictly conserved, however the KE increased linear with time when setting fix thermal/conductivity 1 z 24 1. This can't be right.
Now I am setting fix thermal/conductivity 3000 z 24 300. I increased swap frequency to get a relatively constant total KE. Will I get rid of noise by swapping more atom pairs and obtain linear temperature profile?
This is my question. I am very sorry if I didn't make myself clear initially.

Look forward to hearing your reply
Your sincerely


First off, I haven't used this fix. I've used the related viscosity fix, which I believe does the same operations but swaps a single component of the velocity. So take my advice with that in mind. I don't think swapping more pairs less often will completely fix the problem. The related viscosity fix allows for swapping between pairs that are less than the extremal pairs. I think if you implemented the same thing in the conductivity fix that might fix your problem. That way you could swap frequently between pairs that aren't so hot/cold. The idea is that this would give the integrator a better chance of keeping up.

Quoting "Lu, Haiming" <[email protected]...>:

Does this mean that for reasonable swap rates you will conserve energy?
I thought that was what the MP method was supposed to do for
both viscosity and thermal/cond swaps.


Hi Haiming and Steve,

I also used the same script to simulate the thermal conductivity for graphene sheet. When I set

fix thermal/conductivity 1 z 24

I can observe the temperature after 100ps and the temperature of the hottest region can reach 600K after 3ns running. But when I use the setting:

fix thermal/conductivity 20 z 24

The system temperature can conserve at 300K. At the same time, the temperature is distributed symmetrically along the z direction in a line except there is a sharp peak at the middle region.

It’s easy to understand the system temperature also will conserve if using higher Nevery. But the higher Nevery will increase the simulation time to realize the linear distribution of temperature.


The nice thing about MP is that no energy is put in and out, like through a thermostat. SLLOD uses a thermostat to deal with the energy put in by the deformation at the boundary. The energy conservation problems for MP come in when the velocities are swapped. I think the integrator has a hard time dealing with the abrupt change. Especially when those changes are dramatic. The MP viscosity method doesn't conserve energy well when the velocity swaps were between the most opposed velocities. It did much better when the swaps were between particles with velocities much less than the most opposed. That is, energy "not conserved" per "total amount of momentum exchange" was better when swapping between particles that had more similar velocities. For a given amount of imposed momentum flux it's better to do a lot of swap between particles with similar velocities, than a few swaps between particles with very opposed velocities.


Quoting Steve Plimpton <[email protected]>:

Dear Steve and Matt,
My simulation is finally working. It is my mistake that I should swap velocity of different atom species separately, i.e. Li-Li, O-O ions rather than swapping them together.
I yield some reasonable thermal conductivity results.
I am very grateful and thankful for your valuable help.
Best regards