working with variables: ERROR: Index between variable brackets must be positive

Dear all lammps users,

I am new in using variables in lammps.
I want to have three outputs, each of which is the sum of two other variables coming from computes. I don’t know if this is the best method I am doing:

variable I10 equal c_I1[1]
variable I11 equal c_I1[2]
variable I12 equal c_I1[3]

variable I20 equal c_I2[1]
variable I21 equal c_I2[2]
variable I22 equal c_I2[3]

variable tot1 equal ({I10} + {I20})
variable tot2 equal ({I11} + {I21})
variable tot3 equal ({I12} + {I22})

fix L_sum all ave/time 500 1 500 {tot1} {tot2} ${tot3} file total.txt

However, I always get this error. At line working on variable tot1:

ERROR: Index between variable brackets must be positive

I checked the error section, but don’t understand what I should do.

Please help.

Best Regards
Tapraj

Dear all lammps users,

I am new in using variables in lammps.
I want to have three outputs, each of which is the sum of two other variables coming from computes. I don’t know if this is the best method I am doing:

variable I10 equal c_I1[1]
variable I11 equal c_I1[2]
variable I12 equal c_I1[3]

variable I20 equal c_I2[1]
variable I21 equal c_I2[2]
variable I22 equal c_I2[3]

variable tot1 equal ({I10} + {I20})
variable tot2 equal ({I11} + {I21})
variable tot3 equal ({I12} + {I22})

fix L_sum all ave/time 500 1 500 {tot1} {tot2} ${tot3} file total.txt

However, I always get this error. At line working on variable tot1:

ERROR: Index between variable brackets must be positive

I checked the error section, but don’t understand what I should do.

Read the documentation for the variable command again and pay special attention to the difference between immediate variable expansion and variable references.

Axel