# Question about the Green-Kubo relation for viscosity calculation and trap function in lammps

Dear lammps users,

I have question about the below input using Green-Kubo relation for viscosity calculation

``````units       real
variable    T equal 200.0       # run temperature
variable    Tinit equal 250.0   # equilibration temperature
variable    V equal vol
variable    dt equal 4.0
variable    p equal 400     # correlation length
variable    s equal 5       # sample interval
variable    d equal \$p*\$s   # dump interval

# convert from LAMMPS real units to SI

variable    kB equal 1.3806504e-23    # [J/K] Boltzmann
variable    atm2Pa equal 101325.0
variable    A2m equal 1.0e-10
variable    fs2s equal 1.0e-15
variable    convert equal \${atm2Pa}*\${atm2Pa}*\${fs2s}*\${A2m}*\${A2m}*\${A2m}

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[3])*\${scale}
variable     v22 equal trap(f_SS[4])*\${scale}
variable     v33 equal trap(f_SS[5])*\${scale}
thermo_style custom step temp press v_pxy v_pxz v_pyz v_v11 v_v22 v_v33
``````

my questions are listed below
(1) According to lammps manual, the global array that ave/correlate computes has 5 columns and the first column is time delta_t. However, the output of S0St.dat has six columns, and the first column is index and second column is delta_t. my question is if the index column is not considered when accessing the output of ave/correlate?

(2) I am not too sure how the trap function works after reading the manual. I think the The f_SS[3] represents correlation data (c1,c2,c3,c4…c400) which has 400 element. The trap(f_SS[3] ) function will return the data `K=0.5*c1+c2+c3+c4+....+0.5c400` at time step `d=400*5=2000`. Is it right?

(3) The output v_v11 at time step `d=400*5=2000` is `v_v11=K*\${scale}`. Is it right

I will be grateful if someone can clarify those questions.

Thanks

Since you need to provide the index when accessing elements of a global array also returning it would be redundant.