[lammps-users] variable evaluation

Hello list,

I am wondering why this is not working correctly. If I use

variable V equal vol
variable Rho equal ${totMass}/$V*1.0e24

fix 2 all ave/time 2 5 10 v_Rho ave window 10 &
                file time-avg.dat &
                title1 "# Step rho(g/cm^3)"

Then Rho is not updated; I get the same value at all time steps.

If I use

variable Rho equal ${totMass}/vol*1.0e24

I get the correct updated result at each time step. Why isn't V updated
at each time step?

Thanks,

variable V equal vol
variable Rho equal ${totMass}/$V*1.0e24
Then Rho is not updated; I get the same value at all time steps.

This is because you used $V which substitutes immediately.
You want v_V in the formula for Rho.

Steve

v_V; got it. Thanks,