using variables


I’m new in working with variables. I’m using some variables in the following form:

boundary p p p
units metal
atom_style atomic
lattice fcc 3.52
newton on

variable b equal 300.0
region box block 0 v_b 0 v_b 0 v_b units box
create_box 1 box
variable c equal v_b/2
region sp sphere v_c v_c v_c 10 units box
create_atoms 1 region sp

But get the error:
ERROR: Expected floating point parameter in input script or data file

I looked it up in the Error section in the document, but don’t understand what to do :frowning:

Can you please check tell me where I’m making the mistake…

In this case I think the problem is that region sphere expects an actual floating point number, not a variable. You therefore have to make sure that the variables passed to region are converted into floating points at the time of reading that line, which you can do using the $-syntax, i.e., $b and $c.

Also, the doc page for the region command does not indicate you

can do this:

region sp sphere v_c v_c v_c 10 units box

If a command doesn’t say you can use a variable like v_foo

for an argument, then you can’t.