Cascade simulation in certain time (dt/reset)

Hello all.

I trided to make cascade simulation by using Lammps.
I used dt/reset command so I want to quit simulation with certain simulation time, not certain time step.

So I used command

run 1000000 every 1000 “if ‘$(time)>30’ then quit”

And It works well.

But becuase I used loop command to make several cascade in 1 simulation, I need to jump to next loop. But that command just quit my simulation, not jump to next loop.

I also used
run 1000000 every 1000 “if ‘$(time)>30’ then ‘jump SELF break’”
But it did not jump to next loop.

Is there any idea to solve it?

You want to use fix halt and the timer command.

Oh I didn’t mean real time.
I just want cumulative simulation time

Yes, that is what I understood.

Fix halt can stop a simulation run command without quitting based on an arbitrary condition and it does that by setting the timer to expired, so you need to use the timer command to reset the timer for the next loop iteration or else that one will stop right away.

Okay, Thanks a lot!

I will try it!

Hello Axel.

I tried hard with your advice, but I can’t make it.

First I made command

fix adtdt all dt/reset 1 1.0e-6 1.0e-3 0.01 units lattic

thermo 1000
thermo_style custom step dt time pe ke etotal temp c_interT c_outerT

dump dumpPKA all custom 1000 dumpPKA${i}_*.data id type x y z

timer loop

fix 100 all halt 1000 ${time} > 30

run 1000000

But it didn’t work.

And I also tried command

fix adtdt all dt/reset 1 1.0e-6 1.0e-3 0.01 units lattice
thermo 1000
thermo_style custom step dt time pe ke etotal temp c_interT c_outerT

dump dumpPKA all custom 1000 dumpPKA${i}_*.data id type x y z

timer loop

variable a equal f_adtdt[1]

fix 100 all halt 1000 $s > 30

run 1000000

But it still didn’t work.

Could you help me please?

You have to help yourself. This will be a good learning experience for you in how to learn from the documentation.

What you need to do is explained in the documentation, just not exactly the specific use case. You need to be able to translate what is there for your needs. If you cannot do this with such a simple problem, you will be in deep trouble with complicated LAMMPS problems (with little chances of getting help here). Neither of your inputs is correctly referencing a proper computation. As I have pointed it out to you before, you have to consider how the different kinds of variable references/expansions work in LAMMPS. You have the correct idea, but your implementation is wrong.

I finally used the halt command successfully using command

timer loop

variable a equal time

fix 100 all halt 1000 v_a > 3

run 100000000

I think I could learn how to use several variable in LAMMPS.
I really appreciate for your advice.

But after jump to next loop, error occur again.

This is log content

thermo 1000
thermo_style custom c_PKA_rx c_PKA_ry c_PKA_rz
WARNING: New thermo_style command, previous thermo_modify settings will be lost (…/output.cpp:902)
run 0

variable shiftx equal -c_PKA_rx+ ( ${Lxbox}/2 )

variable shiftx equal -c_PKA_rx+(107.185762/2)

variable shifty equal -c_PKA_ry+(${Lybox}/2)

variable shifty equal -c_PKA_ry+(107.186759/2)

variable shiftz equal -c_PKA_rz+(${Lzbox}/2)

variable shiftz equal -c_PKA_rz+(107.181923/2)

displace_atoms all move {shiftx} {shifty} ${shiftz} units box

ERROR: Variable shiftx: Compute used in variable between runs is not current (…/variable.cpp:1403)
Last command: displace_atoms all move {shiftx} {shifty} ${shiftz} units box

I think this error is due to halt command because this error didn’t occur without halt command.
I guess halt command reset thermo_style and compute command and make this error.

This is input code.

Iteration

label loop
variable i loop 1000
#log log.shot${i}
reset_timestep 0
timestep ${dtPKA}

Selecting a random PKA

variable tempID equal ceil(random(0,{n_atoms}-1,{i}*23782+19772))
variable pkaID equal {tempID} group PKA id {pkaID}

Atom Displacement (PKA to the center)

compute massPKA PKA property/atom mass
compute posPKA PKA property/atom x y z
compute PKA_rx all reduce sum c_posPKA[1]
compute PKA_ry all reduce sum c_posPKA[2]
compute PKA_rz all reduce sum c_posPKA[3]
variable PKAmass equal mass(PKA)

thermo 1000
thermo_style custom c_PKA_rx c_PKA_ry c_PKA_rz
run 0

variable shiftx equal -c_PKA_rx+(${Lxbox}/2)

Could you give me a advice to solve this error?

Here is a minimal example based on the “melt” example that shows how to use fix halt in a loop scenario to terminate each run of the loop iterations early. This shows that any issues with looping have to originate from incorrect inputs by you. Either you are putting commands inside the loop that should be outside or the other way around. There are many ways to create bogus input and I don’t have the time to debug every little error that you make in your input. You have to learn how to debug input script files yourself. The best approach is to start with something minimal and add commands step by step.

units           lj
atom_style      atomic

lattice         fcc 0.8442
region          box block 0 10 0 10 0 10
create_box      1 box
create_atoms    1 box
mass            1 1.0

velocity        all create 3.0 87287 loop geom

pair_style      lj/cut 2.5
pair_coeff      1 1 1.0 1.0 2.5

neighbor        0.3 bin
neigh_modify    every 2 delay 6 check yes

fix             1 all nve

variable time equal time
variable n loop 10

thermo_style custom step time temp press etotal
thermo          50

fix            2 all halt 10 v_time > 0.5 error continue

label loop
reset_timestep 0
run             2000
next n
jump SELF loop

I solved this problem with adding ‘error continue’ in halt command.

I realize that there are so many things I should study and I have to read manual carefully.

And also I realized that I had to figure out how to solve it myself.

I really appreiciate for your help.

Have a nice day.