Respuesta :

Using the knowledge in computational language in C++ it is possible to write a code that Out of range atoms:

Writting the code in C++:

#include <cmath>

#include "pppm_tip4p.h"

#include "atom.h"

#include "domain.h"

#include "force.h"

#include "memory.h"

#include "error.h"

#include "math_const.h"

using namespace LAMMPS_NS;

using namespace MathConst;

#define OFFSET 16384

#ifdef FFT_SINGLE

#define ZEROF 0.0f

#define ONEF  1.0f

#else

#define ZEROF 0.0

#define ONEF  1.0

#endif

void PPPMTIP4P::init()

{

 // TIP4P PPPM requires newton on, b/c it computes forces on ghost atoms

 if (force->newton == 0)

   error->all(FLERR,"Kspace style pppm/tip4p requires newton on");

 PPPM::init();

}

void PPPMTIP4P::particle_map()

{

 int nx,ny,nz,iH1,iH2;

 double *xi,xM[3];

 int *type = atom->type;

 double **x = atom->x;

 int nlocal = atom->nlocal;

 if (!std::isfinite(boxlo[0]) || !std::isfinite(boxlo[1]) || !std::isfinite(boxlo[2]))

   error->one(FLERR,"Non-numeric box dimensions - simulation unstable");

 int flag = 0;

 for (int i = 0; i < nlocal; i++) {

   if (type[i] == typeO) {

     find_M(i,iH1,iH2,xM);

     xi = xM;

   } else xi = x[i];

   nx = static_cast<int> ((xi[0]-boxlo[0])*delxinv+shift) - OFFSET;

   ny = static_cast<int> ((xi[1]-boxlo[1])*delyinv+shift) - OFFSET;

   nz = static_cast<int> ((xi[2]-boxlo[2])*delzinv+shift) - OFFSET;

   part2grid[i][0] = nx;

   part2grid[i][1] = ny;

   part2grid[i][2] = nz;

   if (nx+nlower < nxlo_out || nx+nupper > nxhi_out ||

       ny+nlower < nylo_out || ny+nupper > nyhi_out ||

       nz+nlower < nzlo_out || nz+nupper > nzhi_out) flag++;

 }

 int flag_all;

 MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world);

 if (flag_all) error->all(FLERR,"Out of range atoms - cannot compute PPPM");

}

void PPPMTIP4P::make_rho()

{

 int i,l,m,n,nx,ny,nz,mx,my,mz,iH1,iH2;

 FFT_SCALAR dx,dy,dz,x0,y0,z0;

 double *xi,xM[3];

 FFT_SCALAR *vec = &density_brick[nzlo_out][nylo_out][nxlo_out];

 for (i = 0; i < ngrid; i++) vec[i] = ZEROF;

 int *type = atom->type;

 double *q = atom->q;

 double **x = atom->x;

 int nlocal = atom->nlocal;

 for (int i = 0; i < nlocal; i++) {

   if (type[i] == typeO) {

     find_M(i,iH1,iH2,xM);

     xi = xM;

   } else xi = x[i];

   nx = part2grid[i][0];

   ny = part2grid[i][1];

   nz = part2grid[i][2];

   dx = nx+shiftone - (xi[0]-boxlo[0])*delxinv;

   dy = ny+shiftone - (xi[1]-boxlo[1])*delyinv;

   dz = nz+shiftone - (xi[2]-boxlo[2])*delzinv;

   compute_rho1d(dx,dy,dz);

   z0 = delvolinv * q[i];

   for (n = nlower; n <= nupper; n++) {

     mz = n+nz;

     y0 = z0*rho1d[2][n];

     for (m = nlower; m <= nupper; m++) {

       my = m+ny;

       x0 = y0*rho1d[1][m];

       for (l = nlower; l <= nupper; l++) {

         mx = l+nx;

         density_brick[mz][my][mx] += x0*rho1d[0][l];

       }

     }

   }

 }

}

See more about C++ at brainly.com/question/19705654

#SPJ1

Ver imagen lhmarianateixeira
Ver imagen lhmarianateixeira