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

code improvement, less pointer params

parent 72a1364d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -141,8 +141,8 @@ public:
  void interpolate_meam(int);
  double compute_phi(double, int, int);
 public:
  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_global(int, lattice_t*, 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_setup(int, int, int);
  void meam_dens_init(int* i, int* ntype, int* type, int* fmap, double** x,
+4 −16
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ using namespace LAMMPS_NS;
//

void
MEAM::meam_setup_global(int* nelt, int* lat, double* z, int* ielement, double* atwt,
MEAM::meam_setup_global(int nelt, lattice_t* lat, double* z, int* ielement, double* atwt,
                   double* alpha, double* b0, double* b1, double* b2,
                   double* b3, double* alat, double* esub, double* asub,
                   double* t0, double* t1, double* t2, double* t3,
@@ -28,22 +28,10 @@ MEAM::meam_setup_global(int* nelt, int* lat, double* z, int* ielement, double* a
  int i;
  double tmplat[maxelt];

  this->neltypes = *nelt;
  this->neltypes = nelt;

  for (i = 1; i <= *nelt; i++) {
    if (arr1v(lat, i) == 0)
      this->lattce_meam[i][i] = FCC;
    else if (arr1v(lat, i) == 1)
      this->lattce_meam[i][i] = BCC;
    else if (arr1v(lat, i) == 2)
      this->lattce_meam[i][i] = HCP;
    else if (arr1v(lat, i) == 3)
      this->lattce_meam[i][i] = DIM;
    else if (arr1v(lat, i) == 4)
      this->lattce_meam[i][i] = DIA;
    else {
      //           unknown
    }
  for (i = 1; i <= nelt; i++) {
    this->lattce_meam[i][i] = arr1v(lat, i);

    this->Z_meam[i] = arr1v(z, i);
    this->ielt_meam[i] = arr1v(ielement, i);
+18 −38
Original line number Diff line number Diff line
@@ -59,20 +59,17 @@ MEAM::meam_checkindex(int num, int lim, int nidx, int* idx /*idx(3)*/, int* ierr
//     20 = bkgd_dyn

void
MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,
                  int* index /*index(3)*/, int* errorflag)
MEAM::meam_setup_param(int which, double value, int nindex, int* index /*index(3)*/, int* errorflag)
{
  //: index[0..2]
  int i1, i2, val;
  int i1, i2;
  lattice_t vlat;
  *errorflag = 0;
  int which = *which_p;
  double value = *value_p;
  int nindex = *nindex_p;

  switch (which) {
    //     0 = Ec_meam
    case 0:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->Ec_meam[index[0]][index[1]] = value;
@@ -80,7 +77,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     1 = alpha_meam
    case 1:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->alpha_meam[index[0]][index[1]] = value;
@@ -88,7 +85,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     2 = rho0_meam
    case 2:
      meam_checkindex(1, maxelt, nindex, index, errorflag);
      meam_checkindex(1, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->rho0_meam[index[0]] = value;
@@ -96,7 +93,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     3 = delta_meam
    case 3:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->delta_meam[index[0]][index[1]] = value;
@@ -104,34 +101,17 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     4 = lattce_meam
    case 4:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      val = (int)value;

      if (val == 0)
        this->lattce_meam[index[0]][index[1]] = FCC;
      else if (val == 1)
        this->lattce_meam[index[0]][index[1]] = BCC;
      else if (val == 2)
        this->lattce_meam[index[0]][index[1]] = HCP;
      else if (val == 3)
        this->lattce_meam[index[0]][index[1]] = DIM;
      else if (val == 4)
        this->lattce_meam[index[0]][index[1]] = DIA;
      else if (val == 5)
        this->lattce_meam[index[0]][index[1]] = B1;
      else if (val == 6)
        this->lattce_meam[index[0]][index[1]] = C11;
      else if (val == 7)
        this->lattce_meam[index[0]][index[1]] = L12;
      else if (val == 8)
        this->lattce_meam[index[0]][index[1]] = B2;
      vlat = (lattice_t)value;

      this->lattce_meam[index[0]][index[1]] = vlat;
      break;

    //     5 = attrac_meam
    case 5:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->attrac_meam[index[0]][index[1]] = value;
@@ -139,7 +119,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     6 = repuls_meam
    case 6:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->repuls_meam[index[0]][index[1]] = value;
@@ -147,7 +127,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     7 = nn2_meam
    case 7:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      i1 = std::min(index[0], index[1]);
@@ -157,7 +137,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     8 = Cmin_meam
    case 8:
      meam_checkindex(3, maxelt, nindex, index, errorflag);
      meam_checkindex(3, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->Cmin_meam[index[0]][index[1]][index[2]] = value;
@@ -165,7 +145,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     9 = Cmax_meam
    case 9:
      meam_checkindex(3, maxelt, nindex, index, errorflag);
      meam_checkindex(3, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->Cmax_meam[index[0]][index[1]][index[2]] = value;
@@ -193,7 +173,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     14 = re_meam
    case 14:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      this->re_meam[index[0]][index[1]] = value;
@@ -216,7 +196,7 @@ MEAM::meam_setup_param(int* which_p, double* value_p, int* nindex_p,

    //     18 = zbl_meam
    case 18:
      meam_checkindex(2, maxelt, nindex, index, errorflag);
      meam_checkindex(2, neltypes, nindex, index, errorflag);
      if (*errorflag != 0)
        return;
      i1 = std::min(index[0], index[1]);
+4 −4
Original line number Diff line number Diff line
@@ -371,7 +371,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile)

  int params_per_line = 19;

  int *lat = new int[nelements];
  lattice_t *lat = new lattice_t[nelements];
  int *ielement = new int[nelements];
  int *ibar = new int[nelements];
  double *z = new double[nelements];
@@ -502,7 +502,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile)

  // pass element parameters to MEAM package

  meam_inst->meam_setup_global(&nelements,lat,z,ielement,atwt,alpha,b0,b1,b2,b3,
  meam_inst->meam_setup_global(nelements,lat,z,ielement,atwt,alpha,b0,b1,b2,b3,
                       alat,esub,asub,t0,t1,t2,t3,rozero,ibar);

  // set element masses
@@ -618,7 +618,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile)
    // pass single setting to MEAM package

    int errorflag = 0;
    meam_inst->meam_setup_param(&which,&value,&nindex,index,&errorflag);
    meam_inst->meam_setup_param(which,value,nindex,index,&errorflag);
    if (errorflag) {
      char str[128];
      sprintf(str,"MEAM library error %d",errorflag);