Storing variables within lammps script

Hello,

I have a specific problem. I was wondering if there is a simple way of solving it (without changing the source code).

I am running an MD simulation, and after every 200 steps, I am printing out a variable (named, say d) value using “fix print” command. However, I would like my lammps script to find out the minimum value of the variable d during the run - and if the minimum value is less than a certain value then do another MD simulation.

I do not want to do many short runs, such as with the command “run 42000 every 200” because the temperature and pressure variables get re-set and my MD trajectory changes.

I am using the C++ Sept 2010 version of Lammps.

Thanks for the help

Sumit

The simplest way to do this is write the values
out to a file, every 200 steps, e.g. with the fix ave/time
command. Then write a script to find the min value
in the file (e.g. from your shell), and decide whether
to launch a 2nd LAMMPS run via a 2nd input script.

Doing this all within a single LAMMPS input script
might be possible, but I'd have to experiment a bit
and won't be back in the office until next week.

Steve

Here is some logic that may do what you want.
If you replace the line "run 100" in the bench/in.lj
script with these lines:

variable t equal temp
variable tmin equal 10000
run 100 pre no post no every 10 &
    "if 't < {tmin}' then 'variable tmin equal t'" print "Tmin = {tmin}"

then when the run is done the variable tmin will store the
minimum temperature
encountered during the run (sampled every 10 steps
in this case).

Steve

Dear Steve,

Thank you for the suggestion.

In the below script, the line : "run 100 pre no post no every 10 & “if ‘t < {tmin}’ then 'variable tmin equal $t” ", will essential do 10 runs of 10 steps, but when a run finishes and the other starts, the temperature and pressure variables get reset, and hence the trajectory differs from the one I will get for “run 100”. What do you think?

Thanks
Sumit

I don't know what you mean. The T and P are not "reset",
(don't know what that means either),
and the thermo stats at the end of the 10 10-step runs
are identical to the stats at the end of a single 100 step run.

Also, your original Q (I thought) was how to store the
minimum value of a variable during a run (like the Temp)
so that you could do something with it after the run.

That's what the example I posted illustrates.
You could use the same logic in a loop of short
runs if you wanted, and not use the "run every" syntax.

Steve