Getting out of range variable error when using centroid/stress/atom

Dear All,

I have some problem with centroid/stress/atom command. I used it as:

compute vis solvent centroid/stress/atom NULL

but it leads to this error:

Error: Variable formula compute vector is accessed out-of-range

My pair_style is lj/cut/tip4p/cut.

My procedure:
First of all, I established a simple case, i.e simple water box and used stress/atom command and then defined variable for six component of my isotropic stress tensor. It works.

Then, I change it to the centroid/stress/atom command and try to define components of the stress tensor as variables. Unfortunately, I get out of range error for tthe variable of yx component.

compute vis solvent centroid/stress/atom NULL 
compute visco solvent reduce sum c_vis[4] c_vis[5] c_vis[6] &
                                  c_vis[7] c_vis[8] c_vis[9]
variable vol equal 32768

variable pxycyl equal -(c_visco[4])/vol
variable pxzcyl equal -(c_visco[5])/vol
variable pyzcyl equal -(c_visco[6])/vol
variable pyxcyl equal -(c_visco[7])/vol
variable pzxcyl equal -(c_visco[8])/vol
variable pzycyl equal -(c_visco[9])/vol

variable p equal 20  
variable s equal 1    
variable d equal $p*$s 

# 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 solvent ave/correlate $s $p $d &
v_pxycyl v_pxzcyl v_pyzcyl v_pyxcyl v_pzxcyl v_pzycyl type auto file S0St.dat ave running

variable T equal 298 
variable dt equal 1
variable  scale equal ${convert}/(${kB}*$T)*${vol}*$s*${dt}

variable  vxy equal trap(f_SS[3])*${scale}
variable  vxz equal trap(f_SS[4])*${scale}
variable  vyz equal trap(f_SS[5])*${scale}
variable  vyx equal trap(f_SS[6])*${scale}
variable  vzx equal trap(f_SS[7])*${scale}
variable  vzy equal trap(f_SS[8])*${scale}

variable v equal (v_vxy+v_vxz+v_vyz+v_vyx+v_vzx+v_vzy)/6.00

Any comments would be appreciated,
Thanks in advance

You are reducing only 6 items here. They will be indexed 1 to 6 and thus your error is well deserved since the sum of c_vis[4] becomes c_visco[1], c_vis[5] becomes c_visco[2] and so on.

1 Like