if statement

Dear all,

I’m trying to use ‘if’ statement but I don’t get any error neither ‘if’ command executed, it’s as if skipped:

Here is the simple example, also attached.

I’d appreciate any help.

in.test2 (469 Bytes)

Dear all,

I'm trying to use 'if' statement but I don't get any error neither 'if' command executed, it's as if skipped:

Here is the simple example, also attached.

The if statement works as it should.
Commands in lammps are executed immediately. Please re-read the documentation.

Axel

Hello Axel,

I guess what you mean: commands are executed in the same order as given in input. That is S in my case stores the initial value of step which is zero.

Then is there a simple way to couple ‘if’ and process (‘minimize’ in this case). I mean to execute the command from ‘if’ statement at exactly step 3, say.
What I don’t get here is that S is evaluated anyway at each time step (as thermo output prints them out), then it must be possible to ‘detect’ this third step and to do certain LAMMPS command?

Hello Axel,

I guess what you mean: commands are executed in the same order as given in
input. That is S in my case stores the initial value of step which is zero.

Then is there a simple way to couple 'if' and process ('minimize' in this

no.

case). I mean to execute the command from 'if' statement at exactly step 3,
say.
What I don't get here is that S is evaluated anyway at each time step (as

S is updated as part of the thermo processing.
it is not updated otherwise unless explicitly
requested elsewhere.

thermo output prints them out), then it must be possible to 'detect' this
third step and to do certain LAMMPS command?

technically possible is a lot, but whether it is implemented
is a different story. periodic evaluation of lammps script
code is only implemented as part of the 'run' command
and not minimize (because the 'run' command is "predictable"
and one can break down on run into many equally sized
chunks, but 'minimize' is not).

axel.

if $S==3 ...

This is not the correct syntax - see the if doc page
It should be "$S == 3" with the quotes included.

Steve

Thank you for all your replies.

Steve, I had concluded from ‘if’ doc page that quotes are needed only if spaces are included in the statement. From your correction I guess both spaces and quotes must be used with boolean expressions. However, It doesn’t make any difference in my problem.

Axel, I need exactly for run. I was only testing with this simple input. I’m aware about run options but I’m afraid my case is a bit complicated. What I’m trying to do in fact is to check the number of atoms in certain region at every time step and if it’s less than some N, insert an atom in this region.

Thanks again,
Manana Koberidze

you're right, the spaces are not needed - I misread the doc
page. Axel is correct, the if statement is false when it
is encountered, so it just prints nothing. Step = 0 before
a run or minimize. The if statement is not evaluated during
the minimize.

Steve

Thank you for all your replies.

Axel, I need exactly for run. I was only testing with this simple input.
I'm aware about run options but I'm afraid my case is a bit complicated.
What I'm trying to do in fact is to check the number of atoms in certain
region at every time step and if it's less than some N, insert an atom in
this region.

i would not be doing this via external scripting
seems but rather create a variant of fix deposit
for this purpose.

axel.