'variable' and 'fix print' problems

Hi,

I am simulating a lennard Jones fluid at T*=1, P*=1 and I want to calculate the stress tensor. But when I want to use diagonal components and the box volume to calculate pressure, I get weird errors. Here is my input file:

units lj
atom_style atomic
boundary p p p
pair_style lj/cut 2.5
read_restart lj4000.out
velocity all create 1.0 87287
pair_coeff 1 1 1.0 1.0 2.5
neighbor 0.3 bin
neigh_modify every 20 delay 0 check no
fix ensembleFixStr all nvt temp 1.0 1.0 5.0
thermo 0
compute per_atom_stress all stress/atom
compute total_stress_xx all reduce sum c_per_atom_stress[1]
compute total_stress_yy all reduce sum c_per_atom_stress[2]
compute total_stress_zz all reduce sum c_per_atom_stress[3]
compute total_stress_xy all reduce sum c_per_atom_stress[4]
compute total_stress_xz all reduce sum c_per_atom_stress[5]
compute total_stress_yz all reduce sum c_per_atom_stress[6]
thermo_style custom step temp c_total_stress_xx c_total_stress_yy c_total_stress_zz c_total_stress_xy c_total_stress_xz c_total_stress_yz
variable stXX equal c_total_stress_xx
variable stYY equal c_total_stress_yy
variable stZZ equal c_total_stress_zz
variable stXY equal c_total_stress_xy
variable stXZ equal c_total_stress_xz
variable stYZ equal c_total_stress_yz
variable mdStep equal step
variable volInv equal 1.0/vol
variable stTrace equal (stXX+stYY+stZZ)/3.0
variable instPress equal -stTrace/(vol)
fix stress_print all print 100 “{mdStep} {instPress} {stXX} {stYY} {stZZ} {stXY} {stXZ} {stYZ}” append lj4000-stress.txt
run 1000000

and here is the error that I get

ERROR: Invalid thermo keyword in variable formula (variable.cpp:1252)

by commenting out different lines of the script, I narrowed down the problem to be occurring in the following line:

variable instPress equal -stTrace/(vol)

which is not inherently different from my other computations. Would someone help me realize what is wrong with that statement?

Regards

Amir

A line like this:
variable instPress equal -stTrace/(vol)
needs to be
variable instPress equal -v_stTrace/(vol)

else LAMMPS can't tell a variable name from
a thermo keyword.

See the variable doc page.

Steve

Hi,

That did not solve the problem. I still get the same error. And I am doing similar calculations in the following line without invoking an error:

variable stTrace equal (stXX+stYY+stZZ)/3.0

while I am not using any v_ for distinguishing user-defined variables.

Regards

Amir

again, your variable statement is incorrect - see the doc page -
every time you use a variable in another variable, it needs to be v_stXX, etc.

Steve