nonconservation of energy with fix ehex, fix nve and fix rattle command

Dear all,

I would like to simulate the thermal diffusion phenonmenon in ethanol-water mixture at 298 K and 1 atm, the ethanol molecule used TraPPE-UA force field (4 sites) with harmonic bond and angle, water molecule used SPC/E model (3 sites) with fix rattle commend to fix its bond and angle. However, when I applied fix ehex and fix nve command to generate the temperature gradient, the total energy are decreasing and the kinetic energy are increasing, the temperature of the whole system is increasing, too. I have tried to put fix rattle command in the end but the energy is still decreasing. I also have checked the nve ensemble with fix rattle command, the result of total energy conserves well. I really need some help, would someone give me some advice? Here is the input file with fix ehex, fix nve and fix rattle command:

Possibly Peter can answer your Qs (CCd). He is the author of fix ehex and fix rattle in LAMMPS.


Hi Xiaoyu

For the energy conservation tests, I’d set the pppm precision to 1e-5 and reduce the timestep to 1fs, to be on the safe side.

I’d perform the following checks:

I) Does the problem persist for NEMD if you reduce the timestep and increase the pppm precision? A plot showing total energy vs time, comparing both NVE and NEMD, would be helpful. Also, it would be good to run NVE for the same number of steps as the NEMD run.

II) Does the energy conservation improve if you use SHAKE instead of RATTLE?

III) Does the problem disappear if you remove the ‘constrain com’ option?


Dear Peter:

Thank you for your reply. I have forgotten to check my e-mail thes days. Sorry for the late response.

I will try to reduce the timestep, while the pppm precision that I set now are 1e-4, do I need to increase the pppm precision to 1e-3 or more? Besides, I’m sorry I don’t understand “it would be good to run NVE for the same number of steps as the NEMD run”, do you mean if I need to run NEMD process in 100 ns, there should be a NVE run with (100 ns/timestep) steps before NEMD processes?

I had use fix shake command instead of rattle, while the results showed that the total energy. kinetic energy and potential energy are all increasing, which I have sent a e-mail to the lammps-users with title of “problem of increasing temperature”.

I have not try to remove the ‘constrain com’ option, because the bond and angle are fixed by the shake/rattle command. I will have a try on this option.

Thanks again for your reply, it is really helpful!


Xiaoyu Chen.

Dear Peter:

Thank you so much for your advice, it really does work when I set pppm precision to 1e-5, timestep to 1 fs and remove “constrain com” option in fix ehex command. Now I’m testing the simulation that set timestep to 2 fs. Thanks again for your advices!

best wishes for you!
Xiaoyu Chen

Hi Xiaoyu,

Glad it works now!

It would be very helpful, if you could keep isolating the problem so that we know what exactly was causing the issue.