[lammps-users] information on minium y coordinates of all atoms

Hi Luke,

I have done pretty much exactly what you want. I define this compute:

compute ymax all reduce max y

Then you can output the value to a log file if you want, by refering to v_ymax.

Of course, if you would like to use the value for further calculations you should probably use the method Steve is suggesting.

Sincerely,
Christer H. Ersland.

Many thanks for your answers, Steve and Christer.
It helps a lot for my understanding the commands really.

Best rgards,

Luke

Dear Steve and Christer:

Thanks for your answers really.
I’d like to obtain ymax at the starting of the job (before run).
Based on your advices, I used the following commands.

compute myy all property/atom y
variable ymax equal max(c_myy)
print ${ymax}

But it still showed following eror message.

Mismatched compute in variable formula

I’ve tried many other modifications such as c_myy[1] in max() but it is really hard to know what’s the problem with it.
Would you let me know what I should do for it, please?

I’ve also tried the following commands.

compute ymax all reduce max y
variable ymax equal c_ymax
print ${ymax}

But it showed following error message.

Compute used in variable between runs is not current

I used restart file for the input data but one single run command was used in input file.
Would you let me know What’s wrong with it?

Best regards,

Luke

Dear Luke,

My experience with computes is that they will not be calculated before they are used during a run (when they are used for outputting data to either a dump or a log file). Therefore, you can not use this type of expression to find the max y-coordinate before your first run.

If this is before anything is run, I would guess that the top of your system box would correspond exactly to the maximum y-coordinate. Then you should be able to get that value from the "yhi" keyword (see the thermo_style command for a full list of keywords).
By just writing these commands, I was able to print out the yhi value before a run:

variable ymax equal yhi
print ${ymax}

Of course, this value will be the same that is also output on your screen when the system box is made.
During a run, however, the value of yhi will _not_ be equal to the max y-coordinate, since the system box is only rescaled every once in a while. But before a run they should be equal.

Steve, please correct me if I'm wrong.

Sincerely,
Christer H. Ersland.

What Christer says is correct, you have to sometimes
trick LAMMPS into evaluating some variables before
or between runs, since it can't tell if into the variable accesses
is current. The variable doc page describes a couple
ways to do this, at the bottom.

Steve

Dear Steve and Christer:

Thanks for your answers really.
I will try it again based on your advices.

Best regards,

Luke