lab-cosmo / i-pi-dev_archive

Development version of i-PI
21 stars 12 forks source link

Units again, this time in the LAMMPS interface #164

Closed ollehellman closed 7 years ago

ollehellman commented 7 years ago

I apologize if you are not the people maintaining the LAMMPS interface, if you are the wrong people, ignore this.

I think that something similar to the double-applied units I mentioned in #162 is also present in the LAMMPS interface: the units are applied twice. I'm trying to run fcc Al with a FS potential, and the tabulated eam-potentials need to use the LAMMPS units metal.

The LAMMPS input looks like

clear
units metal
atom_style atomic
box tilt large

read_data outfile.supercell_lammps_ipi
pair_style eam/fs
pair_coeff * * Al1.eam.fs Al
mass           1 26.9820
timestep       1
thermo         50

fix f0 all ipi ipidriver 1234 unix
run               1000000

Which is as basic as it gets, and input.xml as

<simulation>
<output prefix="equil">
    <properties stride='1' filename='out'>[ step, conserved{electronvolt}, temperature{kelvin}, kinetic_md{electronvolt}, kinetic_cv{electronvolt}, potential{electronvolt}]</properties>
</output>
<total_steps>200</total_steps>
<prng><seed>32345</seed></prng>

<ffsocket name="ipisocket" mode="unix">
    <address>ipidriver</address>
</ffsocket>
<system>
<initialize nbeads="2">
    <file mode="xyz">dum.xyz</file>
    <velocities mode="thermal" units="kelvin"> 600 </velocities>
</initialize>
<forces><force forcefield='ipisocket'></force></forces>
<ensemble>
    <temperature units="kelvin">600</temperature>
</ensemble>
<motion mode='dynamics'>
    <fixcom>True</fixcom>
    <dynamics mode='nvt'>
        <thermostat mode="langevin">
            <tau units="femtosecond">100</tau>
        </thermostat>
        <timestep units="femtosecond">1</timestep>
    </dynamics>
</motion>
</system>
</simulation>

And I got just nonsense. Doing a normal LAMMPS run, without i-pi, works just as expected. I dug around a little, and I think the problem is in the interface: I changed (starting at line 355 in fix_ipi.cpp that I pulled from github yesterday)

  // picks local atoms from the buffer
  double **x = atom->x;
  int *mask = atom->mask;
  int nlocal = atom->nlocal;
  if (igroup == atom->firstgroup) nlocal = atom->nfirst;
  for (int i = 0; i < nlocal; i++) {
    if (mask[i] & groupbit) {
      x[i][0]=buffer[3*(atom->tag[i]-1)+0]*posconv;
      x[i][1]=buffer[3*(atom->tag[i]-1)+1]*posconv;
      x[i][2]=buffer[3*(atom->tag[i]-1)+2]*posconv;
    }
  }

to

  // picks local atoms from the buffer
  double **x = atom->x;
  int *mask = atom->mask;
  int nlocal = atom->nlocal;
  if (igroup == atom->firstgroup) nlocal = atom->nfirst;
  for (int i = 0; i < nlocal; i++) {
    if (mask[i] & groupbit) {
      x[i][0]=buffer[3*(atom->tag[i]-1)+0]; //*posconv;
      x[i][1]=buffer[3*(atom->tag[i]-1)+1]; //*posconv;
      x[i][2]=buffer[3*(atom->tag[i]-1)+2]; //*posconv;
    }
  }

and after that, everything seems to work just fine. This is probably not what you guys intended.

ceriottm commented 7 years ago

uhm... no sorry I am almost sure this is a units problem on the i-PI side, non on LAMMPS. I don't see why LAMMPS should work with some units but not others. Are you sure it's not just a problem in interpreting the content of the xyz file? what are its units, and what is the associated LAMMPS datafile.

On 31 January 2017 at 20:00, Olle Hellman notifications@github.com wrote:

I apologize if you are not the people maintaining the LAMMPS interface, if you are the wrong people, ignore this.

I think that something similar to the double-applied units I mentioned in

162 https://github.com/epfl-cosmo/i-pi-dev/issues/162 is also present

in the LAMMPS interface: the units are applied twice. I'm trying to run fcc Al with a FS potential, and the tabulated eam-potentials need to use the LAMMPS units metal.

The LAMMPS input looks like

clear units metal atom_style atomic box tilt large

read_data outfile.supercell_lammps_ipi pair_style eam/fs pair_coeff Al1.eam.fs Al mass 1 26.9820 timestep 1 thermo 50

fix f0 all ipi ipidriver 1234 unix run 1000000

Which is as basic as it gets, and input.xml as

[ step, conserved{electronvolt}, temperature{kelvin}, kinetic_md{electronvolt}, kinetic_cv{electronvolt}, potential{electronvolt}] 200 32345
ipidriver
dum.xyz 600 600 True 100 1

And I got just nonsense. Doing a normal LAMMPS run, without i-pi, works just as expected. I dug around a little, and I think the problem is in the interface: I changed (starting at line 355 in fix_ipi.cpp that I pulled from github yesterday)

// picks local atoms from the buffer double *x = atom->x; int mask = atom->mask; int nlocal = atom->nlocal; if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { x[i][0]=buffer[3(atom->tag[i]-1)+0]posconv; x[i][1]=buffer[3(atom->tag[i]-1)+1]posconv; x[i][2]=buffer[3(atom->tag[i]-1)+2]posconv; } }

to

// picks local atoms from the buffer double *x = atom->x; int mask = atom->mask; int nlocal = atom->nlocal; if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { x[i][0]=buffer[3(atom->tag[i]-1)+0]; //posconv; x[i][1]=buffer[3(atom->tag[i]-1)+1]; //posconv; x[i][2]=buffer[3(atom->tag[i]-1)+2]; //posconv; } }

and after that, everything seems to work just fine. This is probably not what you guys intended.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/epfl-cosmo/i-pi-dev/issues/164, or mute the thread https://github.com/notifications/unsubscribe-auth/ABESZ4InMRHUC1QOnJB5w4mks0hJZh8Yks5rX4S-gaJpZM4LzCdi .

ollehellman commented 7 years ago

So, the i-Pi cell is given as

256
 # CELL{H}: 16.2000000000 0.0000000000 0.0000000000 0.0000000000 16.2000000000 0.0000000000 0.0000000000 0.0000000000 16.2000000000 cell{angstrom}
    Al     0.810000000000E+01 0.607500000000E+01 0.101250000000E+02
    Al     0.101250000000E+02 0.810000000000E+01 0.101250000000E+02
    (+many more lines)

And the LAMMPS atom file input thing as

 # Something
 256 atoms
 1 atom types
 0   16.20000000000000      xlo xhi
 0   16.20000000000000      ylo yhi
 0   16.20000000000000      zlo zhi
   0.0000000000000000        0.0000000000000000        0.0000000000000000      xy xz yz
 Atoms

           1           1   8.10000000000000        6.07500000000000        10.12500000000000
           2           1   10.1250000000000        8.10000000000000        10.12500000000000
           3           1   12.1500000000000        10.1250000000000        10.12500000000000
           4           1   14.1750000000000        12.1500000000000        10.12500000000000
    (+many more lines)

So, both structure inputs are identical, in identical units.

Is it perhaps related to the fact that I the double definition cell{angstrom} positions{angstrom} gave me trouble in i-Pi, but perhaps it's not erroneously defined everywhere?

ceriottm commented 7 years ago

If the "double" definition is in the xyz file, everything should work fine. The problem arises when you specify units both in the xyz and xml file.

On 31 January 2017 at 22:25, Olle Hellman notifications@github.com wrote:

So, the i-Pi cell is given as

256

CELL{H}: 16.2000000000 0.0000000000 0.0000000000 0.0000000000 16.2000000000 0.0000000000 0.0000000000 0.0000000000 16.2000000000 cell{angstrom}

Al     0.810000000000E+01 0.607500000000E+01 0.101250000000E+02
Al     0.101250000000E+02 0.810000000000E+01 0.101250000000E+02
(+many more lines)

And the LAMMPS atom file input thing as

Something

256 atoms 1 atom types 0 16.20000000000000 xlo xhi 0 16.20000000000000 ylo yhi 0 16.20000000000000 zlo zhi 0.0000000000000000 0.0000000000000000 0.0000000000000000 xy xz yz Atoms

       1           1   8.10000000000000        6.07500000000000        10.12500000000000
       2           1   10.1250000000000        8.10000000000000        10.12500000000000
       3           1   12.1500000000000        10.1250000000000        10.12500000000000
       4           1   14.1750000000000        12.1500000000000        10.12500000000000
(+many more lines)

So, both structure inputs are identical, in identical units.

Is it perhaps related to the fact that I the double definition cell{angstrom} positions{angstrom} gave me trouble in i-Pi, but perhaps it's not erroneously defined everywhere?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/epfl-cosmo/i-pi-dev/issues/164#issuecomment-276497497, or mute the thread https://github.com/notifications/unsubscribe-auth/ABESZyv0Y6XL1cW63U0PwmD9OyDNSrC3ks5rX6bVgaJpZM4LzCdi .

ollehellman commented 7 years ago

Yup, all my fault. If I keep the double cell{angstrom} positions{angstrom} definition in the .xyz-file, everything works as expected, no patching required. My bad.

ceriottm commented 7 years ago

That stuff requires some documentation....

On 31 January 2017 at 23:08, Olle Hellman notifications@github.com wrote:

Yup, all my fault. If I keep the double cell{angstrom} positions{angstrom} definition in the .xyz-file, everything works as expected, no patching required. My bad.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/epfl-cosmo/i-pi-dev/issues/164#issuecomment-276508874, or mute the thread https://github.com/notifications/unsubscribe-auth/ABESZ8IU_2Mls684d2Eml_jgUYvJpyQ6ks5rX7DogaJpZM4LzCdi .

grhawk commented 7 years ago

Yes... The documentation is not so clear regarding the possible values used in and in . BTW, the first tutorial in the manual explains how to use the units in the xyz/pdb files. I will open an issue to gather all the problems regarding the documentation and I will close this one to avoid confusion.