# Is zero result because of bad recalling of my Lammps array?

Hi,

I am a beginner in using LAMMPS. So, I followed bellow documents
https://docs.lammps.org/Howto_viscosity.html
to fined the viscosity of water. Although, I exactly used the same command, I do not know why I get zero for the viscosity?

Maybe the reason is because of recalling `v_pxy` for bellow commands. Is it `f_SS[3]` or `f_SS[2]`?

``````fix SS all ave/correlate \$s \$p \$d &
v_pxy v_pxz v_pyz type auto file S0St.dat ave running
``````

Here is my input LAMMPS file (The structure is a simple water box 505060 Angestrom:

``````
echo            both
units           real
boundary        p p p
neigh_modify    delay 2 every 1
timestep        1
atom_style      full

bond_style      harmonic
angle_style     harmonic

pair_style      lj/charmm/coul/long 8 10

pair_coeff 1 1 0.0 0.0
pair_coeff 1 2 0.0 0.0
pair_coeff 2 2 0.1553    3.166     #O-O

kspace_style    pppm 1e-4

fix NVT all nvt temp 300.0 300.0 100

fix rigid all shake 1.0e-6 500 0 m 1.0 a 1

velocity all create 300.0 12345678 dist uniform

thermo 1000
thermo_style custom step temp pe ke  etotal
log logequi1.txt

dump 1 all custom 1000 dump1.lammpstrj id type x y z
run 50000
reset_timestep 0
########################################

variable p equal 40  #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}

variable pxy equal pxy
variable pxz equal pxz
variable pyz equal pyz
variable pxx equal pxx  #pxx
variable pyy equal pyy  #pyy
variable pzz equal pzz  #pzz

fix SS all ave/correlate \$s \$p \$d &
v_pxy v_pxz v_pyz type auto file S0St.dat ave running

variable T equal 300
variable vol equal 150000
variable dt equal 1
variable  scale equal \${convert}/(\${kB}*\$T)*\${vol}*\$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}

variable v equal (v_v11+v_v22+v_v33)/3.0
variable ndens equal count(all)/\${vol}
print "average viscosity : \$v [Pa.s] @ \$T K, \${ndens}/A^3}"

thermo 100
thermo_style custom step temp press v_pxy v_pxz v_pyz

log logequi2.txt

dump 2 all custom 1000 dump2.lammpstrj id type x y z
run 10000
``````

The reason is that you copied/adapted the script incorrectly. By the time you have the print statement, you have not collected any data at all.

Please note that this is an advanced computation and should not be done by a beginner without proper supervision by a competent tutor (posting questions in an online forum is no adequate), since you must adjust the simulation settings to get well converged data. That is a non-trivial process requiring some experience.