Commit 29e60fa5 authored by Sebastian Hütter's avatar Sebastian Hütter
Browse files

Move rho/gamma arrays to fields of MEAM, remove arguments and arrdim macros

parent 078f2a0a
Loading
Loading
Loading
Loading
+35 −31
Original line number Diff line number Diff line
@@ -12,12 +12,8 @@ typedef enum { FCC, BCC, HCP, DIM, DIA, B1, C11, L12, B2 } lattice_t;

class MEAM {
 public:
  MEAM(Memory *mem) :
    memory(mem) {};

  ~MEAM() {
    meam_cleanup();
  }
  MEAM(Memory *mem);
  ~MEAM();
 private:
  Memory *&memory;

@@ -102,14 +98,29 @@ class MEAM {

  int nr, nrar;
  double dr, rdrar;

public:
  int nmax;
  double *rho,*rho0,*rho1,*rho2,*rho3,*frhop;
  double *gamma,*dgamma1,*dgamma2,*dgamma3,*arho2b;
  double **arho1,**arho2,**arho3,**arho3b,**t_ave,**tsq_ave;

  int maxneigh;
  double *scrfcn,*dscrfcn,*fcpair;
 protected:
  void meam_checkindex(int, int, int, int*, int*);
  void G_gam(double, int, double, double*, int*);
  void dG_gam(double, int, double, double*, double*);
  void getscreen(int, int, double*, double*, double*, double*, int, int*, int, int*, int, int*, int*);
  void screen(int, int, int, double*, double, double*, int, int*, int, int*, int*);
  void calc_rho1(int, int, int, int*, int*, double*, int, int*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*);
  void dsij(int, int, int, int, int, int, double, double*, double*, int, int*, int*, double*, double*, double*);
  void getscreen(int i, double* scrfcn, double* dscrfcn, double* fcpair,
          double** x, int numneigh, int* firstneigh, int numneigh_full,
          int* firstneigh_full, int ntype, int* type, int* fmap);
  void screen(int i, int j, double** x, double rijsq, double* sij,
       int numneigh_full, int* firstneigh_full, int ntype, int* type, int* fmap);
  void calc_rho1(int i, int ntype, int* type, int* fmap, double** x,
          int numneigh, int* firstneigh, double* scrfcn, double* fcpair);
  void dsij(int i, int j, int k, int jn, int numneigh, double rij2,
     double* dsij1, double* dsij2, int ntype, int* type, int* fmap, double** x,
     double* scrfcn, double* fcpair);
  void fcut(double, double*);
  void dfcut(double, double*, double*);
  void dCfunc(double, double, double, double*);
@@ -133,9 +144,19 @@ class MEAM {
  void meam_setup_global(int*, int*, double*, int*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, int*);
  void meam_setup_param(int*, double*, int*, int*, int*);
  void meam_setup_done(double*);
  void meam_dens_init(int*, int*, int*, int*, int*, double*, int*, int*, int*, int*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, int*);
  void meam_dens_final(int*, int*, int*, int*, int*, double*, double*, int*, int*, int*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, int*);
  void meam_force(int*, int*, int*, int*, int*, int*, double*, double*, int*, int*, int*, double*, int*, int*, int*, int*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, double*, int*);
  void meam_dens_setup(int, int, int);
  void meam_dens_init(int* i, int* ntype, int* type, int* fmap, double** x,
                int* numneigh, int* firstneigh, int* numneigh_full,
                int* firstneigh_full, int fnoffset, int* errorflag);
  void meam_dens_final(int* nlocal, int* eflag_either, int* eflag_global,
                 int* eflag_atom, double* eng_vdwl, double* eatom, int* ntype,
                 int* type, int* fmap, int* errorflag);
  void meam_force(int* iptr, int* eflag_either, int* eflag_global,
            int* eflag_atom, int* vflag_atom, double* eng_vdwl, double* eatom,
            int* ntype, int* type, int* fmap, double** x, int* numneigh,
            int* firstneigh, int* numneigh_full, int* firstneigh_full,
            int fnoffset, double** f, double** vatom,
            int* errorflag);
  void meam_cleanup();
};

@@ -165,25 +186,8 @@ Fortran Array Semantics in C.
   (or be used with 0-based indexing)
*/

// we receive a pointer to the first element, and F dimensions is ptr(a,b,c)
// we know c data structure is ptr[c][b][a]
#define arrdim2v(ptr, a, b)                                                    \
  const int DIM1__##ptr = a;                                                   \
  const int DIM2__##ptr = b;                                                   \
  (void)(DIM1__##ptr);                                                         \
  (void)(DIM2__##ptr);
#define arrdim3v(ptr, a, b, c)                                                 \
  const int DIM1__##ptr = a;                                                   \
  const int DIM2__##ptr = b;                                                   \
  const int DIM3__##ptr = c;                                                   \
  (void)(DIM1__##ptr); (void)(DIM2__##ptr; (void)(DIM3__##ptr);

// access data with same index as used in fortran (1-based)
#define arr1v(ptr, i) ptr[i - 1]
#define arr2v(ptr, i, j) ptr[(DIM1__##ptr) * (j - 1) + (i - 1)]
#define arr3v(ptr, i, j, k)                                                    \
  ptr[(i - 1) + (j - 1) * (DIM1__##ptr) +                                      \
      (k - 1) * (DIM1__##ptr) * (DIM2__##ptr)]
};
#define arr2v(ptr, i, j) ptr[j - 1][i - 1]

#endif
+54 −67
Original line number Diff line number Diff line
@@ -21,23 +21,10 @@ using namespace LAMMPS_NS;
//

void
MEAM::meam_dens_final(int* nlocal, int* nmax, int* eflag_either, int* eflag_global,
MEAM::meam_dens_final(int* nlocal, int* eflag_either, int* eflag_global,
                 int* eflag_atom, double* eng_vdwl, double* eatom, int* ntype,
                 int* type, int* fmap, double* Arho1, double* Arho2,
                 double* Arho2b, double* Arho3, double* Arho3b, double* t_ave,
                 double* tsq_ave, double* Gamma, double* dGamma1,
                 double* dGamma2, double* dGamma3, double* rho, double* rho0,
                 double* rho1, double* rho2, double* rho3, double* fp,
                 int* errorflag)
                 int* type, int* fmap, int* errorflag)
{

  arrdim2v(Arho1, 3, *nmax);
  arrdim2v(Arho2, 6, *nmax);
  arrdim2v(Arho3, 10, *nmax);
  arrdim2v(Arho3b, 3, *nmax);
  arrdim2v(t_ave, 3, *nmax);
  arrdim2v(tsq_ave, 3, *nmax);

  int i, elti;
  int m;
  double rhob, G, dG, Gbar, dGbar, gam, shp[3 + 1], Z;
@@ -49,23 +36,23 @@ MEAM::meam_dens_final(int* nlocal, int* nmax, int* eflag_either, int* eflag_glob
    elti = arr1v(fmap, arr1v(type, i));
    if (elti > 0) {
      arr1v(rho1, i) = 0.0;
      arr1v(rho2, i) = -1.0 / 3.0 * arr1v(Arho2b, i) * arr1v(Arho2b, i);
      arr1v(rho2, i) = -1.0 / 3.0 * arr1v(arho2b, i) * arr1v(arho2b, i);
      arr1v(rho3, i) = 0.0;
      for (m = 1; m <= 3; m++) {
        arr1v(rho1, i) =
          arr1v(rho1, i) + arr2v(Arho1, m, i) * arr2v(Arho1, m, i);
          arr1v(rho1, i) + arr2v(arho1, m, i) * arr2v(arho1, m, i);
        arr1v(rho3, i) = arr1v(rho3, i) -
                         3.0 / 5.0 * arr2v(Arho3b, m, i) * arr2v(Arho3b, m, i);
                         3.0 / 5.0 * arr2v(arho3b, m, i) * arr2v(arho3b, m, i);
      }
      for (m = 1; m <= 6; m++) {
        arr1v(rho2, i) =
          arr1v(rho2, i) +
          this->v2D[m] * arr2v(Arho2, m, i) * arr2v(Arho2, m, i);
          this->v2D[m] * arr2v(arho2, m, i) * arr2v(arho2, m, i);
      }
      for (m = 1; m <= 10; m++) {
        arr1v(rho3, i) =
          arr1v(rho3, i) +
          this->v3D[m] * arr2v(Arho3, m, i) * arr2v(Arho3, m, i);
          this->v3D[m] * arr2v(arho3, m, i) * arr2v(arho3, m, i);
      }

      if (arr1v(rho0, i) > 0.0) {
@@ -84,17 +71,17 @@ MEAM::meam_dens_final(int* nlocal, int* nmax, int* eflag_either, int* eflag_glob
        }
      }

      arr1v(Gamma, i) = arr2v(t_ave, 1, i) * arr1v(rho1, i) +
      arr1v(gamma, i) = arr2v(t_ave, 1, i) * arr1v(rho1, i) +
                        arr2v(t_ave, 2, i) * arr1v(rho2, i) +
                        arr2v(t_ave, 3, i) * arr1v(rho3, i);

      if (arr1v(rho0, i) > 0.0) {
        arr1v(Gamma, i) = arr1v(Gamma, i) / (arr1v(rho0, i) * arr1v(rho0, i));
        arr1v(gamma, i) = arr1v(gamma, i) / (arr1v(rho0, i) * arr1v(rho0, i));
      }

      Z = this->Z_meam[elti];

      G_gam(arr1v(Gamma, i), this->ibar_meam[elti],
      G_gam(arr1v(gamma, i), this->ibar_meam[elti],
            this->gsmooth_factor, &G, errorflag);
      if (*errorflag != 0)
        return;
@@ -140,33 +127,33 @@ MEAM::meam_dens_final(int* nlocal, int* nmax, int* eflag_either, int* eflag_glob
      rhob = arr1v(rho, i) / rho_bkgd;
      denom = 1.0 / rho_bkgd;

      dG_gam(arr1v(Gamma, i), this->ibar_meam[elti],
      dG_gam(arr1v(gamma, i), this->ibar_meam[elti],
             this->gsmooth_factor, &G, &dG);

      arr1v(dGamma1, i) = (G - 2 * dG * arr1v(Gamma, i)) * denom;
      arr1v(dgamma1, i) = (G - 2 * dG * arr1v(gamma, i)) * denom;

      if (!iszero(arr1v(rho0, i))) {
        arr1v(dGamma2, i) = (dG / arr1v(rho0, i)) * denom;
        arr1v(dgamma2, i) = (dG / arr1v(rho0, i)) * denom;
      } else {
        arr1v(dGamma2, i) = 0.0;
        arr1v(dgamma2, i) = 0.0;
      }

      //     dGamma3 is nonzero only if we are using the "mixed" rule for
      //     dgamma3 is nonzero only if we are using the "mixed" rule for
      //     computing t in the reference system (which is not correct, but
      //     included for backward compatibility
      if (this->mix_ref_t == 1) {
        arr1v(dGamma3, i) = arr1v(rho0, i) * G * dGbar / (Gbar * Z * Z) * denom;
        arr1v(dgamma3, i) = arr1v(rho0, i) * G * dGbar / (Gbar * Z * Z) * denom;
      } else {
        arr1v(dGamma3, i) = 0.0;
        arr1v(dgamma3, i) = 0.0;
      }

      B = this->A_meam[elti] * this->Ec_meam[elti][elti];

      if (!iszero(rhob)) {
        if (this->emb_lin_neg == 1 && rhob <= 0) {
          arr1v(fp, i) = -B;
          arr1v(frhop, i) = -B;
        } else {
          arr1v(fp, i) = B * (log(rhob) + 1.0);
          arr1v(frhop, i) = B * (log(rhob) + 1.0);
        }
        if (*eflag_either != 0) {
          if (*eflag_global != 0) {
@@ -186,9 +173,9 @@ MEAM::meam_dens_final(int* nlocal, int* nmax, int* eflag_either, int* eflag_glob
        }
      } else {
        if (this->emb_lin_neg == 1) {
          arr1v(fp, i) = -B;
          arr1v(frhop, i) = -B;
        } else {
          arr1v(fp, i) = B;
          arr1v(frhop, i) = B;
        }
      }
    }
@@ -198,38 +185,38 @@ MEAM::meam_dens_final(int* nlocal, int* nmax, int* eflag_either, int* eflag_glob
// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

void
MEAM::G_gam(double Gamma, int ibar, double gsmooth_factor, double* G, int* errorflag)
MEAM::G_gam(double gamma, int ibar, double gsmooth_factor, double* G, int* errorflag)
{
  //     Compute G(Gamma) based on selection flag ibar:
  //   0 => G = sqrt(1+Gamma)
  //   1 => G = exp(Gamma/2)
  //     Compute G(gamma) based on selection flag ibar:
  //   0 => G = sqrt(1+gamma)
  //   1 => G = exp(gamma/2)
  //   2 => not implemented
  //   3 => G = 2/(1+exp(-Gamma))
  //   4 => G = sqrt(1+Gamma)
  //  -5 => G = +-sqrt(abs(1+Gamma))
  //   3 => G = 2/(1+exp(-gamma))
  //   4 => G = sqrt(1+gamma)
  //  -5 => G = +-sqrt(abs(1+gamma))

  double gsmooth_switchpoint;
  if (ibar == 0 || ibar == 4) {
    gsmooth_switchpoint = -gsmooth_factor / (gsmooth_factor + 1);
    if (Gamma < gsmooth_switchpoint) {
    if (gamma < gsmooth_switchpoint) {
      //         e.g. gsmooth_factor is 99, {:
      //         gsmooth_switchpoint = -0.99
      //         G = 0.01*(-0.99/Gamma)**99
      //         G = 0.01*(-0.99/gamma)**99
      *G = 1 / (gsmooth_factor + 1) *
           pow((gsmooth_switchpoint / Gamma), gsmooth_factor);
           pow((gsmooth_switchpoint / gamma), gsmooth_factor);
      *G = sqrt(*G);
    } else {
      *G = sqrt(1.0 + Gamma);
      *G = sqrt(1.0 + gamma);
    }
  } else if (ibar == 1) {
    *G = MathSpecial::fm_exp(Gamma / 2.0);
    *G = MathSpecial::fm_exp(gamma / 2.0);
  } else if (ibar == 3) {
    *G = 2.0 / (1.0 + exp(-Gamma));
    *G = 2.0 / (1.0 + exp(-gamma));
  } else if (ibar == -5) {
    if ((1.0 + Gamma) >= 0) {
      *G = sqrt(1.0 + Gamma);
    if ((1.0 + gamma) >= 0) {
      *G = sqrt(1.0 + gamma);
    } else {
      *G = -sqrt(-1.0 - Gamma);
      *G = -sqrt(-1.0 - gamma);
    }
  } else {
    *errorflag = 1;
@@ -239,43 +226,43 @@ MEAM::G_gam(double Gamma, int ibar, double gsmooth_factor, double* G, int* error
// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

void
MEAM::dG_gam(double Gamma, int ibar, double gsmooth_factor, double* G, double* dG)
MEAM::dG_gam(double gamma, int ibar, double gsmooth_factor, double* G, double* dG)
{
  // Compute G(Gamma) and dG(gamma) based on selection flag ibar:
  //   0 => G = sqrt(1+Gamma)
  //   1 => G = MathSpecial::fm_exp(Gamma/2)
  // Compute G(gamma) and dG(gamma) based on selection flag ibar:
  //   0 => G = sqrt(1+gamma)
  //   1 => G = MathSpecial::fm_exp(gamma/2)
  //   2 => not implemented
  //   3 => G = 2/(1+MathSpecial::fm_exp(-Gamma))
  //   4 => G = sqrt(1+Gamma)
  //  -5 => G = +-sqrt(abs(1+Gamma))
  //   3 => G = 2/(1+MathSpecial::fm_exp(-gamma))
  //   4 => G = sqrt(1+gamma)
  //  -5 => G = +-sqrt(abs(1+gamma))
  double gsmooth_switchpoint;

  if (ibar == 0 || ibar == 4) {
    gsmooth_switchpoint = -gsmooth_factor / (gsmooth_factor + 1);
    if (Gamma < gsmooth_switchpoint) {
    if (gamma < gsmooth_switchpoint) {
      //         e.g. gsmooth_factor is 99, {:
      //         gsmooth_switchpoint = -0.99
      //         G = 0.01*(-0.99/Gamma)**99
      //         G = 0.01*(-0.99/gamma)**99
      *G = 1 / (gsmooth_factor + 1) *
           pow((gsmooth_switchpoint / Gamma), gsmooth_factor);
           pow((gsmooth_switchpoint / gamma), gsmooth_factor);
      *G = sqrt(*G);
      *dG = -gsmooth_factor * *G / (2.0 * Gamma);
      *dG = -gsmooth_factor * *G / (2.0 * gamma);
    } else {
      *G = sqrt(1.0 + Gamma);
      *G = sqrt(1.0 + gamma);
      *dG = 1.0 / (2.0 * *G);
    }
  } else if (ibar == 1) {
    *G = MathSpecial::fm_exp(Gamma / 2.0);
    *G = MathSpecial::fm_exp(gamma / 2.0);
    *dG = *G / 2.0;
  } else if (ibar == 3) {
    *G = 2.0 / (1.0 + MathSpecial::fm_exp(-Gamma));
    *G = 2.0 / (1.0 + MathSpecial::fm_exp(-gamma));
    *dG = *G * (2.0 - *G) / 2;
  } else if (ibar == -5) {
    if ((1.0 + Gamma) >= 0) {
      *G = sqrt(1.0 + Gamma);
    if ((1.0 + gamma) >= 0) {
      *G = sqrt(1.0 + gamma);
      *dG = 1.0 / (2.0 * *G);
    } else {
      *G = -sqrt(-1.0 - Gamma);
      *G = -sqrt(-1.0 - gamma);
      *dG = -1.0 / (2.0 * *G);
    }
  }
+93 −36
Original line number Diff line number Diff line
@@ -3,6 +3,85 @@
#include "math_special.h"

using namespace LAMMPS_NS;


void
MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh)
{
  int i, j;
  
  // grow local arrays if necessary

  if (atom_nmax > nmax) {
    memory->destroy(rho);
    memory->destroy(rho0);
    memory->destroy(rho1);
    memory->destroy(rho2);
    memory->destroy(rho3);
    memory->destroy(frhop);
    memory->destroy(gamma);
    memory->destroy(dgamma1);
    memory->destroy(dgamma2);
    memory->destroy(dgamma3);
    memory->destroy(arho2b);
    memory->destroy(arho1);
    memory->destroy(arho2);
    memory->destroy(arho3);
    memory->destroy(arho3b);
    memory->destroy(t_ave);
    memory->destroy(tsq_ave);

    nmax = atom_nmax;

    memory->create(rho,nmax,"pair:rho");
    memory->create(rho0,nmax,"pair:rho0");
    memory->create(rho1,nmax,"pair:rho1");
    memory->create(rho2,nmax,"pair:rho2");
    memory->create(rho3,nmax,"pair:rho3");
    memory->create(frhop,nmax,"pair:frhop");
    memory->create(gamma,nmax,"pair:gamma");
    memory->create(dgamma1,nmax,"pair:dgamma1");
    memory->create(dgamma2,nmax,"pair:dgamma2");
    memory->create(dgamma3,nmax,"pair:dgamma3");
    memory->create(arho2b,nmax,"pair:arho2b");
    memory->create(arho1,nmax,3,"pair:arho1");
    memory->create(arho2,nmax,6,"pair:arho2");
    memory->create(arho3,nmax,10,"pair:arho3");
    memory->create(arho3b,nmax,3,"pair:arho3b");
    memory->create(t_ave,nmax,3,"pair:t_ave");
    memory->create(tsq_ave,nmax,3,"pair:tsq_ave");
  }

  if (n_neigh > maxneigh) {
    memory->destroy(scrfcn);
    memory->destroy(dscrfcn);
    memory->destroy(fcpair);
    maxneigh = n_neigh;
    memory->create(scrfcn,maxneigh,"pair:scrfcn");
    memory->create(dscrfcn,maxneigh,"pair:dscrfcn");
    memory->create(fcpair,maxneigh,"pair:fcpair");
  }

  // zero out local arrays

  for (i = 0; i < nall; i++) {
    rho0[i] = 0.0;
    arho2b[i] = 0.0;
    arho1[i][0] = arho1[i][1] = arho1[i][2] = 0.0;
    for (j = 0; j < 6; j++) arho2[i][j] = 0.0;
    for (j = 0; j < 10; j++) arho3[i][j] = 0.0;
    arho3b[i][0] = arho3b[i][1] = arho3b[i][2] = 0.0;
    t_ave[i][0] = t_ave[i][1] = t_ave[i][2] = 0.0;
    tsq_ave[i][0] = tsq_ave[i][1] = tsq_ave[i][2] = 0.0;
  }
}







//     Extern "C" declaration has the form:
//
//  void meam_dens_init_(int *, int *, int *, double *, int *, int *, int *,
@@ -22,34 +101,27 @@ using namespace LAMMPS_NS;
//

void
MEAM::meam_dens_init(int* i, int* nmax, int* ntype, int* type, int* fmap, double* x,
MEAM::meam_dens_init(int* i, int* ntype, int* type, int* fmap, double** x,
                int* numneigh, int* firstneigh, int* numneigh_full,
                int* firstneigh_full, double* scrfcn, double* dscrfcn,
                double* fcpair, double* rho0, double* arho1, double* arho2,
                double* arho2b, double* arho3, double* arho3b, double* t_ave,
                double* tsq_ave, int* errorflag)
                int* firstneigh_full, int fnoffset, int* errorflag)
{
  *errorflag = 0;

  //     Compute screening function and derivatives
  getscreen(*i, *nmax, scrfcn, dscrfcn, fcpair, x, *numneigh, firstneigh,
  getscreen(*i, &scrfcn[fnoffset], &dscrfcn[fnoffset], &fcpair[fnoffset], x, *numneigh, firstneigh,
            *numneigh_full, firstneigh_full, *ntype, type, fmap);

  //     Calculate intermediate density terms to be communicated
  calc_rho1(*i, *nmax, *ntype, type, fmap, x, *numneigh, firstneigh, scrfcn,
            fcpair, rho0, arho1, arho2, arho2b, arho3, arho3b, t_ave, tsq_ave);
  calc_rho1(*i, *ntype, type, fmap, x, *numneigh, firstneigh, &scrfcn[fnoffset], &fcpair[fnoffset]);
}

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

void
MEAM::getscreen(int i, int nmax, double* scrfcn, double* dscrfcn, double* fcpair,
          double* x, int numneigh, int* firstneigh, int numneigh_full,
MEAM::getscreen(int i, double* scrfcn, double* dscrfcn, double* fcpair,
          double** x, int numneigh, int* firstneigh, int numneigh_full,
          int* firstneigh_full, int ntype, int* type, int* fmap)
{

  arrdim2v(x, 3, nmax);

  int jn, j, kn, k;
  int elti, eltj, eltk;
  double xitmp, yitmp, zitmp, delxij, delyij, delzij, rij2, rij;
@@ -92,8 +164,7 @@ MEAM::getscreen(int i, int nmax, double* scrfcn, double* dscrfcn, double* fcpair
          sij = 0.0;
        } else {
          rnorm = (this->rc_meam - rij) * drinv;
          screen(i, j, nmax, x, rij2, &sij, numneigh_full, firstneigh_full,
                 ntype, type, fmap);
          screen(i, j, x, rij2, &sij, numneigh_full, firstneigh_full, ntype, type, fmap);
          dfcut(rnorm, &fc, &dfc);
          fcij = fc;
          dfcij = dfc * drinv;
@@ -170,19 +241,9 @@ MEAM::getscreen(int i, int nmax, double* scrfcn, double* dscrfcn, double* fcpair
// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

void
MEAM::calc_rho1(int i, int nmax, int ntype, int* type, int* fmap, double* x,
          int numneigh, int* firstneigh, double* scrfcn, double* fcpair,
          double* rho0, double* arho1, double* arho2, double* arho2b,
          double* arho3, double* arho3b, double* t_ave, double* tsq_ave)
MEAM::calc_rho1(int i, int ntype, int* type, int* fmap, double** x,
          int numneigh, int* firstneigh, double* scrfcn, double* fcpair)
{
  arrdim2v(x, 3, nmax);
  arrdim2v(arho1, 3, nmax);
  arrdim2v(arho2, 6, nmax);
  arrdim2v(arho3, 10, nmax);
  arrdim2v(arho3b, 3, nmax);
  arrdim2v(t_ave, 3, nmax);
  arrdim2v(tsq_ave, 3, nmax);

  int jn, j, m, n, p, elti, eltj;
  int nv2, nv3;
  double xtmp, ytmp, ztmp, delij[3 + 1], rij2, rij, sij;
@@ -302,7 +363,7 @@ MEAM::calc_rho1(int i, int nmax, int ntype, int* type, int* fmap, double* x,
// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

void
MEAM::screen(int i, int j, int nmax, double* x, double rijsq, double* sij,
MEAM::screen(int i, int j, double** x, double rijsq, double* sij,
       int numneigh_full, int* firstneigh_full, int ntype, int* type, int* fmap)
//     Screening function
//     Inputs:  i = atom 1 id (integer)
@@ -310,11 +371,7 @@ MEAM::screen(int i, int j, int nmax, double* x, double rijsq, double* sij,
//     rijsq = squared distance between i and j
//     Outputs: sij = screening function
{

  arrdim2v(x, 3, nmax)

    int k,
    nk /*,m*/;
  int k, nk /*,m*/;
  int elti, eltj, eltk;
  double delxik, delyik, delzik;
  double delxjk, delyjk, delzjk;
@@ -375,8 +432,8 @@ MEAM::screen(int i, int j, int nmax, double* x, double rijsq, double* sij,
// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

void
MEAM::dsij(int i, int j, int k, int jn, int nmax, int numneigh, double rij2,
     double* dsij1, double* dsij2, int ntype, int* type, int* fmap, double* x,
MEAM::dsij(int i, int j, int k, int jn, int numneigh, double rij2,
     double* dsij1, double* dsij2, int ntype, int* type, int* fmap, double** x,
     double* scrfcn, double* fcpair)
{
  //     Inputs: i,j,k = id's of 3 atom triplet
@@ -385,7 +442,7 @@ MEAM::dsij(int i, int j, int k, int jn, int nmax, int numneigh, double rij2,
  //     Outputs: dsij1 = deriv. of sij w.r.t. rik
  //     dsij2 = deriv. of sij w.r.t. rjk

  arrdim2v(x, 3, nmax) int elti, eltj, eltk;
  int elti, eltj, eltk;
  double rik2, rjk2;

  double dxik, dyik, dzik;
+47 −61

File changed.

Preview size limit exceeded, changes collapsed.

+64 −0
Original line number Diff line number Diff line
/* ----------------------------------------------------------------------
   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
   http://lammps.sandia.gov, Sandia National Laboratories
   Steve Plimpton, sjplimp@sandia.gov

   Copyright (2003) Sandia Corporation.  Under the terms of Contract
   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
   certain rights in this software.  This software is distributed under
   the GNU General Public License.

   See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */

/* ----------------------------------------------------------------------
   Contributing author: Sebastian Hütter (OvGU)
------------------------------------------------------------------------- */

#include "meam.h"
#include "memory.h"

using namespace LAMMPS_NS;

/* ---------------------------------------------------------------------- */

MEAM::MEAM(Memory *mem) : memory(mem)
{
  nmax = 0;
  rho = rho0 = rho1 = rho2 = rho3 = frhop = NULL;
  gamma = dgamma1 = dgamma2 = dgamma3 = arho2b = NULL;
  arho1 = arho2 = arho3 = arho3b = t_ave = tsq_ave = NULL;

  maxneigh = 0;
  scrfcn = dscrfcn = fcpair = NULL;
}

MEAM::~MEAM()
{
  meam_cleanup();

  memory->destroy(rho);
  memory->destroy(rho0);
  memory->destroy(rho1);
  memory->destroy(rho2);
  memory->destroy(rho3);
  memory->destroy(frhop);
  memory->destroy(gamma);
  memory->destroy(dgamma1);
  memory->destroy(dgamma2);
  memory->destroy(dgamma3);
  memory->destroy(arho2b);

  memory->destroy(arho1);
  memory->destroy(arho2);
  memory->destroy(arho3);
  memory->destroy(arho3b);
  memory->destroy(t_ave);
  memory->destroy(tsq_ave);

  memory->destroy(scrfcn);
  memory->destroy(dscrfcn);
  memory->destroy(fcpair);
}

Loading