# [gmx-users] viscosity using green-kubo

Gmx QA gmxquestions at gmail.com
Wed Dec 16 15:42:56 CET 2015

```Dear gmx-users

I sent mail a couple days ago about viscosity calculations, but no-one
answered so maybe it was too lengthy, so better luck this time I hope.

I want to calculate viscosity using Green-Kubo formalism, and have run a
box with tip3p waters for 100 ps in NVE, saving data every 1 fs.

For green-kubo, I then first use gmx energy to get (one of) the
off-diagonal elements in the pressure tensor (Pxy in this case)

\$ gmx energy -f nve_prod.edr -o nve_prod_pressure_tensor_pxy.xvg

Then, I use gmx analyze to calculate the auto-correlation function of the
Pxy pressure component

\$ gmx analyze -f nve_prod_pressure_tensor_pxy.xvg -ac
nve_prod_pressure_tensor_pxy_acf.xvg -nonormalize

And then again gmx analyze to integrate it.
\$ gmx analyze -f nve_prod_pressure_tensor_pxy_acf.xvg -integrate

That gives me :
Calculating the integral using the trapezium rule
Integral 1  1940.24341  +/-    0.00000

Which I then plug into the green-kubo formula
eta = V/(kB*T)* int(…) = …=

For my V=1.59e-26 m^3, T=303 K and with kB=1.38e-23 I get eta = 0.0074

Now, I am not sure about units, or about the validity of this answer. I
tried changing the unit of the pressure from bar to pascal by multiplying
with 100000, but the results makes equally less sense.

I have also read about averaging over several of the off-diagonal pressure
tensor components, which I could try, but is there anything fundamental
that I am missing above?

Hope for better luck with some answers this time!
/PK
```