[lammps-users] question: fix ave/spatial

Dear lammps users,

Did anybody mentioned changes in "fix ave/spatial" command in lammps
version 7Jul09.

According to manual delta in this command supposed to be distance
units and it was in lammps version 6Dec08 I used before.

Now then I use input file

units metal
lattice sc 4.329

.....

replicate 160 4 4

....

fix 4 all ave/spatial 1 80000 100000 x lower 8.658 v_temp file tmp.profile

the tmp.profile looks like:

# Spatial-averaged data for fix 4 and group all
# TimeStep Number-of-layers
# Layer Coordinate Natoms v_temp
100000 19
  1 18.7402 1099.29 2167.46
  2 56.2207 1119.93 2201.58
  3 93.7012 1091.7 2206.99
  4 131.182 1116.36 2166.05
  5 168.662 1118.14 2190.55
  6 206.143 1090.01 2205.26
  7 243.623 1119.86 2206.52
  8 281.104 1105.94 2211.05
  9 318.584 1102.06 2192.13
  10 356.065 1120 2163.22
  11 393.545 1094.99 2142.59
  12 431.026 1113.01 2143.92
  13 468.506 1119.97 2144.27
  14 505.987 1091.24 2173.83
  15 543.467 1116.8 2173.49
  16 580.947 1118.43 2155.69
  17 618.428 1089.81 2167.3
  18 655.908 1119.76 2181.56
  19 693.389 532.713 2154.26

as you can see it's in the units of lattice parameter.
Then I restart from saved file delta is interpreted in some other units.

I would really appreciate any help.
Is it defect of my compilation or some bug in the new version of fix
ave/spatial command.

Best,
German Samolyuk

According to the doc page, the default units for this
command is "lattice", not box. So the output looks
correct to me. This default setting is the same for
all commands that have a "units" option. But I think
you are correct that fix ave/spatial was not originally
that way (box was the default, not lattice).

Possibly at the last release we changed it
to be consistent and failed to list it on the patch page.
There was a also a 18May08 bug patch that might
have affected your output.

Steve

Thank you,

If I restart my calculations with read_restart command
the command fix ave/spatial changes output even if I use it with definite units

fix 4 all ave/spatial 1 180000 200000 x lower 2 v_temp units
lattice file tmp.profile ave running

The version of lammps I use is 7Jul09. Does it mean that it has a
18May08 bug patch?

German

Restart file don't store anything about the fix ave/spatial
command or the lattice. So your new script would
have to re-define these quantities. Any LAMMPS version
dated after a patch will contain the patch.

Steve

Yes, I understand.

I input script I re-define fix ave/spatial after restart with command

fix 4 all ave/spatial 1 180000 200000 x lower 2 v_temp units
lattice file tmp.profile ave running

but it's different units.

German

I don't understand what you're asking. If you use the same
units and lattice and fix ave/spatial commands in both scripts,
what is it doing different? The only difference
could be that the lower x boundary is different when restarting,
if the box volume changed.

Steve

If I use units box

"fix 3 all ave/spatial 1 399 400 x lower 10.86 v_temp units box
file tmp.profile ave running"

It's restarting correctly.

If I use units lattice

"fix 3 all ave/spatial 1 399 400 x lower 2.0 v_temp units
lattice file tmp.profile ave running"

it does something different on restart

German

PS: It's not a big deal as soon as I can use "units box"

it does something different on restart

I still don't know what you mean by this. If you
put the exact same commands (lattice, fix ave/spatial)
in 2 different input scripts you should get the same behavior.
The fact that you started one from a data file and the
other from a restart file makes no difference (assuming
the box size is the same, and assuming the atom info
is similar). Neither of those commands know anything
about a data or restart file.

Steve

I prepared simple example:

1) input file

units metal
boundary p p p
lattice fcc 5.39
region box block 0 1 0 1 0 1
create_box 1 box
create_atoms 1 box
mass 1 39.948
timestep 0.002

replicate 2 1 1

pair_style lj/cut 13.0
pair_coeff 1 1 0.010324 3.405

thermo 1

velocity all create 90.0 87287

compute ke all ke/atom
variable temp atom c_ke[]/(1.5*8.67e-5)
fix 3 all ave/spatial 1 9 10 x lower 1.0 v_temp units
lattice file tmp.profile

fix NVE all nve

restart 10 rstrt_1 rstrt_2

run 100

2) OUTPUT tmp.profile

10 2
  1 2.695 5 69.6502
  2 8.085 3 90.3541
20 2
  1 2.695 5 65.6061
  2 8.085 3 85.5567
30 2
  1 2.695 5 58.1182
  2 8.085 3 76.9617

....

3) restart from rstrt_1 input file

lattice fcc 5.39

thermo 1

read_restart rstrt_1

compute ke all ke/atom
variable temp atom c_ke[]/(1.5*8.67e-5)
fix 3 all ave/spatial 1 9 10 x lower 1.0 v_temp units
lattice file tmp.profile

fix NVE all nve

restart 10 rstrt_1 rstrt_2

run 100

4) OUTPUT tmp.profile

100 12
  1 0.452683 2 1.69452
  2 1.35805 0 0
  3 2.26341 2 13.5428
  4 3.16878 0 0
  5 4.07414 0 0
  6 4.97951 2 18.4495
  7 5.88487 0 0
  8 6.79024 0 0
  9 7.6956 1 11.1759
  10 8.60097 1 16.0933
  11 9.50633 0 0
  12 10.4117 0 0
110 12
  1 0.452683 2 1.2671
  2 1.35805 0 0
  3 2.26341 2 18.4736
  4 3.16878 0 0
  5 4.07414 0 0
  6 4.97951 2 23.6849
  7 5.88487 0 0
  8 6.79024 0 0
  9 7.6956 1 11.7887
  10 8.60097 1 12.5643
  11 9.50633 0 0
  12 10.4117 0 0
.......

I keep the same units lattice

German Samolyuk

Thanks for sending the example. LAMMPS is actually
working correctly.

In your first script you have:

units metal
lattice fcc 5.39
create_atoms 1 box

In your second script you have:

lattice fcc 5.39
read_restart tmp.1

In the first case, the lattice is setup in metal units, where 5.39 means
the lattice spacing is 5.39 Angs.

In the second case, the lattice is setup in lj units (the default), where
5.39 is the reduced density, which generates a very small lattice
spacing. Then reading the restart file will change your units
to metal. So if you flip the order of the lattice and read_restart
commands in the 2nd script, you'll get what you want.

If you look at the output printed to the screen by the lattice
command, you'll see what it generates for spacings.

This confused me at first as well, but it's a "feature" not a "bug".

Steve

Steve, thank you very much!
German