# fix halt with condition on derivative?

Dear LAMMPS users,

I am trying to define a fix halt to stop a run when a certain condition is met. What would be useful is that the run stops when a variable (calculated with a compute eg) reaches a constant value (or derivative ~ 0).
I found in the manual that a time-averaged value can be calculated with fix ave/time but nothing about derivatives.
Is there a way to do that during a run? I did not find anything in the manual nor in the mailing list.

Many thanks in advance and best regards,
Christophe

The variable doc page (at the bottom) explains how to store

the old value of one variable in another variable, e.g.

If you want to store the initial volume of the system, you can do it this way:

``````>variable v equal vol
>variable v0 equal \$v

``````

If you put lines like that in a loop construct every 1000 steps,

then I think you could have two variables that have

values 1000 steps apart. Your fix halt could compare the

2 values (every 1000 steps) and decide to exit if they

were sufficiently close to each other (time derivate nearly 0.0).

Note that for numeric fluctuating values like volume (in a NPT

simulation), you would not get a derivative exactly zero.

Steve

The variable doc page (at the bottom) explains how to store

the old value of one variable in another variable, e.g.

If you want to store the initial volume of the system, you can do it this way:

``````>variable v equal vol
>variable v0 equal \$v

``````

If you put lines like that in a loop construct every 1000 steps,

then I think you could have two variables that have

values 1000 steps apart. Your fix halt could compare the

2 values (every 1000 steps) and decide to exit if they

were sufficiently close to each other (time derivate nearly 0.0).

Yes, that could make it. Thanks for the advice.

Note that for numeric fluctuating values like volume (in a NPT

simulation), you would not get a derivative exactly zero.

Since it is difficult to get exactly 0 for any value due to flucturations, my idea for the fix halt would be something like:

fix halt deriv < eps
where eps would be a tolerance (1e-4 eg).

Christophe