 # Calculating viscosity during simulation

Dear Users,

I am trying to calculate the viscosity of an ionic liquid using the Green-Kubo relation. I am following the example “8.3.6. Calculate viscosity” on LAMMPS documentation. But I still don’t understand the correlation time for viscosity calculation. If I run a simulation for 1 ns, how can I calculate the viscosity at 200, 400, 600, 800, 1000 ps?

variable    p equal 50000     # correlation length
variable    s equal 20       # sample interval
variable    d equal $p*$s   # dump interval

variable     pxy equal pxy
variable     pxz equal pxz
variable     pyz equal pyz

fix          SS all ave/correlate $s$p $d v_pxy v_pxz v_pyz type auto file S0St.dat ave running variable scale equal${convert}/(${kB}*$T)*$V*$s*${dt} variable v11 equal trap(f_SS)*${scale}
variable     v22 equal trap(f_SS)*${scale} variable v33 equal trap(f_SS)*${scale}

run 1000000 # 1ns


Ziru

1 Like

That is controlled by a) the Nrepeat, Nevery, Noutput settings of fix ave correlate and b) how and when you output the variables v11, v22, v33 (e.g. via fix print at the desired interval).

Thank you very much!

if I set the fix ave/correlate as

fix  SS all ave/correlate 20 10000 200000 v_pxy v_pxz v_pyz type auto file S0St.dat ave running


does this means the viscosity output at 1000 ps will be the integral from dt=0 to dt=200 ps?

\eta(t=1000\ ps)=C\int_0^{200000}<P(t_0+t)P(t_0)> dt

Can I increase the correlation length as the simulation runs, like this?

\eta(t=200\ ps)=C\int_0^{200000}<P(t_0+t)P(t_0)> dt

\eta(t=1000\ ps)=C\int_0^{1000000}<P(t_0+t)P(t_0)> dt

The answer to your question is in the documentation of the fix and variable commands.