LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
[lammps-users] Accessing periodic image of atoms in my own fix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lammps-users] Accessing periodic image of atoms in my own fix


From: Frank Zack <frankzack123@...664...>
Date: Thu, 14 Sep 2017 12:25:33 +0000 (UTC)

I've written a fix for  pressure-absorbing boundary conditions for fcc-lattices which I'm using for my shockwave simulations.
It uses a monochromatic wave-solution approach for integrating the equations of motion for the atoms which represent the boundary group.
One input parameter is the distance between the current atomic positions of the boundary atoms and the equilibrium position of these atoms at the very first timestep.

Actually it works surprisingly well.
However, if the simulations runs for a while, it might happen that some of my the atoms travel across the periodic boundaries and a simple distance-calculation according to "pos_new- pos_old" is obiously wrong. I have to take into account the periodic images.

so this is what I'm doing (pseudocode):

loop "i" over all atoms:
  if atom is part of the boundary-group:
    imageint *imgflag = atom->image;
   
    flag_x=static_cast<int>(((imgflag[i] & IMGMASK)-IMGMAX);
    flag_y=static_cast<int>((imgflag[i] >> IMGBITS & IMGMASK) - IMGMAX);
    flag_z=static_cast<int>((imgflag[i] >> IMG2BITS) - IMGMAX);
   
    //get the "true" positions
    x_pos=x[i][0]+flag_x*Ly;
    y_pos=x[i][1]+flag_y*Ly;
    z_pos=x[i][2]+flag_y*Ly;
    ...
this seems to work for most of my atoms. However, its no working for those atoms at the edges and corners of the simulation box.
Reason: From the very beginning the imgflag[i] - values seem to be uncorrect. They should all be "0". Instead, for the atoms at the edges and corners these are "-512"

Why is that? 
I've taken a look into the pack_scale_image function of dump_atom.cpp and the image flags are determined the very same way.
Where's my mistake?


Best regards,
frank.