Vector Variable Issue

All,

I’m having a problem defining a variable which involves a vector. The error I’m getting is below.

ERROR: Invalid syntax in variable formula (…/variable.cpp:2262)
Last command: variable dumpfreq equal (round({runtime}/10))

Below is the relevant excerpt of the script. I’ve tested this in the August 31, 2018 version of LAMMPS and the error is still present. What am I doing wrong?

variable rho equal 1.497 # density of polymer in g/cc
variable rhoa equal {rho}/(10^8)^3 # density of polymer in g/A^3 variable lxf equal 100 # final length of simulation box in x-direction variable lyf equal 50 # final length of simulation box in y-direction variable masssys equal (density/(10^8)^3lxlylz) # Calculate mass of system in g
variable lzf equal {masssys}/({rhoa}
{lxf}*{lyf}) # Calculate final length of sim box in z-direction in A
variable rate equal (10/10^6) # Calculate rate of deformation in A/fs variable deltatx equal ((v_lxf-lx)/v_rate) # Calculate time in fs to deform x at the specified rate
variable deltaty equal ((v_lyf-ly)/v_rate) # Calculate time in fs to deform y at the specified rate variable deltatz equal ((v_lzf-lz)/v_rate) # Calculate time in fs to deform z at the specified rate

Define vector of deltas

variable deltatvec vector [abs({deltatx}),abs({deltaty}),abs(${deltatz})]
variable runtime equal max(v_deltatvec)

Calculate dump frequency from runtime

variable dumpfreq equal (round({runtime}/10))

Calculate thermo frequency from runtime

variable thermofreq equal (round({runtime}/200))

I’m not sure why I’m getting an error. How should it be written to avoid the error?

Thanks,
Will

All,

I’m having a problem defining a variable which involves a vector. The error I’m getting is below.

ERROR: Invalid syntax in variable formula (…/variable.cpp:2262)
Last command: variable dumpfreq equal (round({runtime}/10))

have you tried referring to the runtime variable using v_runtime?

axel.

Yes, I have. I get the same error.

ERROR: Variable deltatvec: Invalid syntax in variable formula (…/variable.cpp:2262)
Last command: variable dumpfreq equal $(round(v_runtime/10))

Thanks,
Will

Yes, I have. I get the same error.

ERROR: Variable deltatvec: Invalid syntax in variable formula (…/variable.cpp:2262)
Last command: variable dumpfreq equal $(round(v_runtime/10))

ok. i’ve been systematically debugging your input and the cause root seems to be the expression:

variable deltatvec vector [abs({deltatx}),abs({deltaty}),abs(${deltatz})]

please let me know, where you found, that this is valid input and that you can define a vector variable like this.

thanks,
axel.

Axel,

I’m not sure if that’s the correct way to define a vector variable in LAMMPS. There isn’t an example in the variable documentation. How should it be written?

Thanks,
Will

If it is not documented, then you cannot do it.
Axel