rx ry and rz are being parsed from the command line switch, e.g " … -v rx 124". I tried pretty much every formatting I know to parse this variables into the command. Why do I keep getting a “ERROR: Invalid syntax in variable formula (…/variable.cpp:2604)”
Obviously, because your variable expressions are incorrect. The variable command documentation is very clear about referencing other variables inside variable formulas using v_name. Anything with ${name} is usually expanded during pre-processing, but text in quotes or in $( ) is exempted. Please check the parsing rules page in the manual if you want to better understand the process.
I understand that I did something wrong. And I understand now that I shouldn’t be using double $ sign for parsing my variable from the command line. But this is only one of the things that I tried. This error is too odd. I still need help figuring out the correct syntax to parse the variable from the command line directly into the formula.
Then there are likely multiple errors. For example, what are the “\” characters supposed to do?
The line continuation character of LAMMPS is “&” (like in free format Fortran). This also is well documented. And there are plenty of examples. You need to improve your knowledge of the LAMMPS documentation.
This aspect is irrelevant. Using the -var command line flag is exactly like defining an index style variable. So you can simplify your input for testing by just defining an index style variable first. In fact, this is the recommended way since index style variables cannot be redefined without first deleting them. See for example the bench/in.lj input, which you can override the x, y, and z variables from the command line.
Thank you.
Actually the problem came from an empty space in the lammps bash command. The “-v rx …” part was not visible to the parser. I am now able to parse the variable from the command line.
However this is being used to define a region used in turn by fix deposit. The fact of using the variable makes the region “dynamic”. Should I open a separate issue to fix that?
This statement makes no sense to me and it is impossible to validate since you don’t provide any information on how to reproduce it.
No, it doesn’t. At least not the way it would be done properly. I cannot reproduce this claim by changing the region and fix deposit command as follows in the in.deposit.atom example.
variable delta index 1.0
region slab block 0 $(xhi) 0 $(yhi) $(zhi-2*v_delta) $(zhi-v_delta) units box
fix 4 addatoms deposit 100 2 100 12345 region slab near 1.0 &
vz -1.0 -1.0
One more thing: throughout this discussion, you have been vague or incomplete or incorrect about both assessment of the cause of problems and description of what you have been doing.
If you keep doing that, you will likely not get much help in the future. Please see the guidelines post (again). Communicating in an online forum requires extra effort since you are communicating with people that cannot read your mind or look at your computer, so you need to be explicit about “everything”. Do not assume that people will know about the stuff you leave out or do it the same way you do.