Why does the viscosity increase in a carbon nanotube?

Hi everybody,

I have decided to calculate viscosity in a carbon nanotube containing water. To my knowledge, the viscosity should be more or less a constant quantity. However, I don’t know why do I get constantly increased viscosity versus time? Is it normal for viscosity to be increased in a CNT?
I attached data and input files for more details here.

solvate.in (2.8 KB)
solvate.data (815.6 KB)


The viscosity of water next to a solid surface is known to differ from the bulk viscosity. In general water properties next to solid surface or next to an interface are different from bulk.

In the particular case of graphene solid surface, there is usually a strong structuring of the water within the two first layers of water (thus leading to large oscillations in the density profile), as well as an increase in the viscosity.

In your case however there may still be an error since you are using a fix nvt applied to a group of atom without using fix_modify, therefore you may end-up with the wrong temperature for your system, which obviously affects the viscosity.


I just noticed that you said that the viscosity is increasing “versus time”. So definitely no, this is not a normal behavior. I think that’s linked to the bad control of the temperature in your system.

There is a lot going on in this script. It looks like it might work in theory, but there are many possible points of failure, including the issue with the thermostat mentioned by Simon… Also, the viscosity calculation itself is not included in the script. Presumably you are doing that in a post-processing step.

So it is likely that you made at least one major error. Finding it will require you to do some careful testing.

I suggest you put your full script aside for now, it is far too complicated. Instead construct another one that uses only lj/cut and a slit pore. There are lots of published results for this case that you can use as a test of the correctness of your script.

Also, if you run in to problems, it will be easier to define your question narrowly and you will be more likely to get useful suggestions on this forum.

I will also mention that extracting viscosity from stress requires careful attention to time sampling protocol, analogous to obtaining diffusivity from velocity sampling. See this script for how to do it right: lammps/in.einstein.2d at ceb9466172398e9a20cb510528b4b17f719c7cf2 · lammps/lammps · GitHub

Thanks all for your valuable comments. For the first step, I am going to fix the temperature in the CNT. To do this, is it right to add the following command?

compute mytemp solvent  temp 
fix 3 solvent nvt temp 298.0 298.0 100
fix 4 solvent temp/rescale 1 298.0 298.0 0.01 0.01
fix_modify 3 temp mytemp

Moreover, is it also useful to add fix langevin?

This is enough :

compute mytemp solvent temp 
fix 3 solvent nvt temp 298.0 298.0 100
fix_modify 3 temp mytemp

The “fix nvt” already thermostats the group “solvent” (and perform the time integration), so you don’t need the “temp/rescale”. Using both nvt and temp/rescale may work (i.e. the simulation may run), but this is not a standard way of doing it.

Nope, it produces bogus results.

Thank you very much for your fruitful comments.

In this way, I used fix_modify commands (as suggested) to fix the temperature fluctuations in my structure. But again, I get the same temp in my output thermo_style command as before (without using fix_modify). Pressure coefficients also did not change.

So, I checked the fix_modify documentation and it has been written:

Thus this option allows the user to override the default method for computing T.

Maybe, LAMMPS uses its default temp to calculate pressure coefficients.and I do not exactly know how to change the default computing temp. Would you mind writing any comments and suggestion?


Try :

thermo_modify temp mytemp

Thanks for useful comments.

By this way, temp was successfully fixed during the simulation. However, the problem is still remained for calculating pressure coefficients (Pxx, Pyy , …) which are computed based on the wrong temperature.
I modified below command and added mytemp as temp-ID in my input file:

compute vis solvent stress/atom mytemp

But unfortunately, the problem is still remained! Would you mind write any suggestion on calculating press/atom with modified temp?

Thanks in advance

Probably, you need to explicitly invoke mytemp in your pressure compute: compute vis solvent stress/atom mytemp

NOTE: If you proceed in this manner without testing against known correct results, it is highly unlikely that you will succeed in producing a correct viscosity calculation. I strongly advise you to first test your methodology by reproducing previously published viscosity calculations.

Thanks for your comments.
But the specious thing in my case: The pressure coefficients are determined based on the default compute temp. Meaning, fix_modify 3 temp mytemp and thermo_modify temp mytemp do not change press coefficients.
I attached input and data file for more details here.

Thanks the time and energy you put in yours to develop my understanding

solvate.in (2.9 KB)
solvate.data (815.6 KB)

Please take my previous advice: switch to a simpler case for which correct result is known (e.g. examples in examples/VISCOSITY), then add extra factors (e.g. frozen substrate) and confirm that you can still get correct results. Only then should you attempt calculation of your original problem.

Thanks for your comments.

Yes, I tested for water molecules without any frozen carbon atoms and got good results (viscosity fluctuated over a constant value reported for SPC/E in literature).

However, when I add two frozen graphene sheets into previous structure, it starts constantly increasing over the time.Then, I changed the structure and put water molecules into CNT and saw again constantly increasing viscosity over the time.

I have been testing my groups, regions, fixes and etc for several days and put plenty of times but unfortunately I got no points.

I appreciate any comments and suggestions

It is not at all clear how you managed to compare to the published viscosity of SPC/E water. Your script solvate.in contains no information about viscosity, only stress. A possible explanation for constantly increasing stress would be inclusion of a kinetic energy contribution to the stress that itself is constantly increasing in time, which often happens due to some version of the “flying ice cube” problem.