Run every command

Hello, I want to simulate charing and discharging cycles with LAMMPS, so I want a cyclic voltage like +6 V, then -6V, +6,-6+6,-6 and so on.
Here are some commands I used, could this allow me to change voltage every 125000 steps or will this change voltage every single step?
thank you.

variable volt equal 6.0

fix 5 all echemdid 1 k 6.0 rc 4.0 norm 0.6 nelec 10 regionlia regionlic volt $ {volt}

run 500000 every 125000 “variable volt equal ${volt}*(-1)”

You have to check the documentation of that fix or ask its author. This fix is not part of the LAMMPS distribution, so we don’t know anything about it.

As @akohlmey said we generally do not debug non-LAMMPS packages. However, unless ECHEMDID severely modifies LAMMPS, any command of the form

fix myfix mygroup STYLE ${var1} ${var2} ...

uses the values of var1 and var2 by value – that is, the value of var1 at the point of parsing is used and does not change throughout the fix lifetime. It is as if you’d simply typed the values in as plain numbers to the command. See 5.2. Parsing rules for input scripts — LAMMPS documentation .

Fixes that take variables “by reference” (that is, use the dynamic value of an equal- or atom-style variable over time) will usually (not necessarily!) take those references in the form v_variable-name, as you will see if you search the documentation for the string v_. Now, as someone who likes looking at ELECTRODEs, I did look at the source code of ECHEMDID and it can be modified to take such a reference. (I have discovered a truly marvelous proof of this, which the margins of my spare time are too narrow to contain.)

Whether or not it makes sense for ECHEMDID to do this is a question for the authors. Furthermore, you would be simulating a voltage change of 12 V total over sub-nanosecond duty cycles, which seems rather dubious to me. But it’s certainly doable, although you’d have to further modify source code to do it.

3 Likes