diff --git a/src/GPU/pair_sw_gpu.cpp b/src/GPU/pair_sw_gpu.cpp index 7bfbe2810f..b819580488 100644 --- a/src/GPU/pair_sw_gpu.cpp +++ b/src/GPU/pair_sw_gpu.cpp @@ -186,7 +186,7 @@ void PairSWGPU::init_style() if (i < 0 || j < 0) continue; else { - int ijparam = elem2param[i][j][j]; + int ijparam = elem3param[i][j][j]; ncutsq[ii][jj] = params[ijparam].cutsq; ncut[ii][jj] = params[ijparam].cut; sigma[ii][jj] = params[ijparam].sigma; @@ -206,7 +206,7 @@ void PairSWGPU::init_style() if (k < 0) continue; else { - int ijkparam = elem2param[i][j][k]; + int ijkparam = elem3param[i][j][k]; costheta[ii][jj][kk] = params[ijkparam].costheta; lambda_epsilon[ii][jj][kk] = params[ijkparam].lambda_epsilon; } @@ -218,7 +218,7 @@ void PairSWGPU::init_style() int success = sw_gpu_init(tp1, atom->nlocal, atom->nlocal+atom->nghost, mnf, cell_size, gpu_mode, screen, ncutsq, ncut, sigma, powerp, powerq, sigma_gamma, c1, c2, c3, c4, c5, - c6, lambda_epsilon, costheta, map, elem2param); + c6, lambda_epsilon, costheta, map, elem3param); memory->destroy(ncutsq); memory->destroy(ncut); diff --git a/src/GPU/pair_tersoff_gpu.cpp b/src/GPU/pair_tersoff_gpu.cpp index e675ba6903..c2f3413d3d 100644 --- a/src/GPU/pair_tersoff_gpu.cpp +++ b/src/GPU/pair_tersoff_gpu.cpp @@ -41,7 +41,7 @@ using namespace LAMMPS_NS; int tersoff_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, const double cell_size, int &gpu_mode, FILE *screen, int* host_map, const int nelements, - int*** host_elem2param, const int nparams, + int*** host_elem3param, const int nparams, const double* ts_lam1, const double* ts_lam2, const double* ts_lam3, const double* ts_powermint, const double* ts_biga, const double* ts_bigb, @@ -218,7 +218,7 @@ void PairTersoffGPU::init_style() int success = tersoff_gpu_init(atom->ntypes+1, atom->nlocal, atom->nlocal+atom->nghost, mnf, cell_size, gpu_mode, screen, map, nelements, - elem2param, nparams, lam1, lam2, lam3, + elem3param, nparams, lam1, lam2, lam3, powermint, biga, bigb, bigr, bigd, c1, c2, c3, c4, c, d, h, gamma, beta, powern, _cutsq); diff --git a/src/GPU/pair_tersoff_mod_gpu.cpp b/src/GPU/pair_tersoff_mod_gpu.cpp index 98a7248c1f..6a5e9892ec 100644 --- a/src/GPU/pair_tersoff_mod_gpu.cpp +++ b/src/GPU/pair_tersoff_mod_gpu.cpp @@ -40,7 +40,7 @@ using namespace LAMMPS_NS; int tersoff_mod_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, const double cell_size, int &gpu_mode, FILE *screen, - int* host_map, const int nelements, int*** host_elem2param, const int nparams, + int* host_map, const int nelements, int*** host_elem3param, const int nparams, const double* ts_lam1, const double* ts_lam2, const double* ts_lam3, const double* ts_powermint, const double* ts_biga, const double* ts_bigb, const double* ts_bigr, const double* ts_bigd, const double* ts_c1, @@ -211,7 +211,7 @@ void PairTersoffMODGPU::init_style() int success = tersoff_mod_gpu_init(atom->ntypes+1, atom->nlocal, atom->nlocal+atom->nghost, mnf, cell_size, gpu_mode, screen, map, nelements, - elem2param, nparams, lam1, lam2, lam3, + elem3param, nparams, lam1, lam2, lam3, powermint, biga, bigb, bigr, bigd, c1, c2, c3, c4, c5, h, beta, powern, powern_del, ca1, _cutsq); diff --git a/src/GPU/pair_tersoff_zbl_gpu.cpp b/src/GPU/pair_tersoff_zbl_gpu.cpp index e17b48fec5..0c56212fef 100644 --- a/src/GPU/pair_tersoff_zbl_gpu.cpp +++ b/src/GPU/pair_tersoff_zbl_gpu.cpp @@ -41,7 +41,7 @@ using namespace LAMMPS_NS; int tersoff_zbl_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, const double cell_size, int &gpu_mode, FILE *screen, int* host_map, const int nelements, - int*** host_elem2param, const int nparams, + int*** host_elem3param, const int nparams, const double* ts_lam1, const double* ts_lam2, const double* ts_lam3, const double* ts_powermint, const double* ts_biga, const double* ts_bigb, @@ -227,7 +227,7 @@ void PairTersoffZBLGPU::init_style() int success = tersoff_zbl_gpu_init(atom->ntypes+1, atom->nlocal, atom->nlocal+atom->nghost, mnf, cell_size, gpu_mode, screen, map, nelements, - elem2param, nparams, lam1, lam2, lam3, + elem3param, nparams, lam1, lam2, lam3, powermint, biga, bigb, bigr, bigd, c1, c2, c3, c4, c, d, h, gamma, beta, powern, Z_i, Z_j, ZBLcut, ZBLexpscale, diff --git a/src/GPU/pair_vashishta_gpu.cpp b/src/GPU/pair_vashishta_gpu.cpp index c5dd722974..b3c703952f 100644 --- a/src/GPU/pair_vashishta_gpu.cpp +++ b/src/GPU/pair_vashishta_gpu.cpp @@ -41,7 +41,7 @@ using namespace LAMMPS_NS; int vashishta_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, const double cell_size, int &gpu_mode, FILE *screen, int* host_map, - const int nelements, int*** host_elem2param, + const int nelements, int*** host_elem3param, const int nparams, const double* cutsq, const double* r0, const double* gamma, const double* eta, const double* lam1inv, const double* lam4inv, @@ -217,7 +217,7 @@ void PairVashishtaGPU::init_style() int mnf = 5e-2 * neighbor->oneatom; int success = vashishta_gpu_init(atom->ntypes+1, atom->nlocal, atom->nlocal+atom->nghost, mnf, cell_size, gpu_mode, screen, map, nelements, - elem2param, nparams, cutsq, r0, gamma, eta, lam1inv, + elem3param, nparams, cutsq, r0, gamma, eta, lam1inv, lam4inv, zizj, mbigd, dvrc, big6w, heta, bigh, bigw, c0, costheta, bigb, big2b, bigc); memory->destroy(cutsq); diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 5d629dc42a..2fb90b7aec 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -289,7 +289,7 @@ void PairSWKokkos::operator()(TagPairSWComputeHalf const X_FLOAT delz = ztmp - x(j,2); const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - const int ijparam = d_elem2param(itype,jtype,jtype); + const int ijparam = d_elem3param(itype,jtype,jtype); if (rsq >= d_params[ijparam].cutsq) continue; twobody(d_params[ijparam],rsq,fpair,eflag,evdwl); @@ -313,7 +313,7 @@ void PairSWKokkos::operator()(TagPairSWComputeHalf int j = d_neighbors_short(i,jj); j &= NEIGHMASK; const int jtype = d_map[type[j]]; - const int ijparam = d_elem2param(itype,jtype,jtype); + const int ijparam = d_elem3param(itype,jtype,jtype); delr1[0] = x(j,0) - xtmp; delr1[1] = x(j,1) - ytmp; delr1[2] = x(j,2) - ztmp; @@ -328,8 +328,8 @@ void PairSWKokkos::operator()(TagPairSWComputeHalf int k = d_neighbors_short(i,kk); k &= NEIGHMASK; const int ktype = d_map[type[k]]; - const int ikparam = d_elem2param(itype,ktype,ktype); - const int ijkparam = d_elem2param(itype,jtype,ktype); + const int ikparam = d_elem3param(itype,ktype,ktype); + const int ijkparam = d_elem3param(itype,jtype,ktype); delr2[0] = x(k,0) - xtmp; delr2[1] = x(k,1) - ytmp; @@ -412,7 +412,7 @@ void PairSWKokkos::operator()(TagPairSWComputeFullA= d_params[ijparam].cutsq) continue; @@ -434,7 +434,7 @@ void PairSWKokkos::operator()(TagPairSWComputeFullA::operator()(TagPairSWComputeFullA::operator()(TagPairSWComputeFullB= nlocal) continue; const int jtype = d_map[type[j]]; - const int jiparam = d_elem2param(jtype,itype,itype); + const int jiparam = d_elem3param(jtype,itype,itype); const X_FLOAT xtmpj = x(j,0); const X_FLOAT ytmpj = x(j,1); const X_FLOAT ztmpj = x(j,2); @@ -530,8 +530,8 @@ void PairSWKokkos::operator()(TagPairSWComputeFullB::setup_params() { PairSW::setup_params(); - // sync elem2param and params + // sync elem3param and params - tdual_int_3d k_elem2param = tdual_int_3d("pair:elem2param",nelements,nelements,nelements); - t_host_int_3d h_elem2param = k_elem2param.h_view; + tdual_int_3d k_elem3param = tdual_int_3d("pair:elem3param",nelements,nelements,nelements); + t_host_int_3d h_elem3param = k_elem3param.h_view; tdual_param_1d k_params = tdual_param_1d("pair:params",nparams); t_host_param_1d h_params = k_params.h_view; @@ -646,17 +646,17 @@ void PairSWKokkos::setup_params() for (int i = 0; i < nelements; i++) for (int j = 0; j < nelements; j++) for (int k = 0; k < nelements; k++) - h_elem2param(i,j,k) = elem2param[i][j][k]; + h_elem3param(i,j,k) = elem3param[i][j][k]; for (int m = 0; m < nparams; m++) h_params[m] = params[m]; - k_elem2param.template modify(); - k_elem2param.template sync(); + k_elem3param.template modify(); + k_elem3param.template sync(); k_params.template modify(); k_params.template sync(); - d_elem2param = k_elem2param.template view(); + d_elem3param = k_elem3param.template view(); d_params = k_params.template view(); } diff --git a/src/KOKKOS/pair_sw_kokkos.h b/src/KOKKOS/pair_sw_kokkos.h index 31b7f3301d..b9f4559bc2 100644 --- a/src/KOKKOS/pair_sw_kokkos.h +++ b/src/KOKKOS/pair_sw_kokkos.h @@ -102,7 +102,7 @@ class PairSWKokkos : public PairSW { typedef typename tdual_int_3d::t_dev_const_randomread t_int_3d_randomread; typedef typename tdual_int_3d::t_host t_host_int_3d; - t_int_3d_randomread d_elem2param; + t_int_3d_randomread d_elem3param; typename AT::t_int_1d_randomread d_map; typedef Kokkos::DualView tdual_param_1d; diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index 41a32a61e3..72a79c0b49 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -125,7 +125,7 @@ void PairTersoffKokkos::setup_params() for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) for (k = 1; k <= n; k++) { - m = elem2param[map[i]][map[j]][map[k]]; + m = elem3param[map[i]][map[j]][map[k]]; k_params.h_view(i,j,k).powerm = params[m].powerm; k_params.h_view(i,j,k).gamma = params[m].gamma; k_params.h_view(i,j,k).lam3 = params[m].lam3; diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp index bd8e4d7528..c8431abc4b 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp @@ -124,7 +124,7 @@ void PairTersoffMODKokkos::setup_params() for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) for (k = 1; k <= n; k++) { - m = elem2param[map[i]][map[j]][map[k]]; + m = elem3param[map[i]][map[j]][map[k]]; k_params.h_view(i,j,k).powerm = params[m].powerm; k_params.h_view(i,j,k).lam3 = params[m].lam3; k_params.h_view(i,j,k).h = params[m].h; diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp index 5e201dbc1c..3c362ad340 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp @@ -135,7 +135,7 @@ void PairTersoffZBLKokkos::setup_params() for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) for (k = 1; k <= n; k++) { - m = elem2param[map[i]][map[j]][map[k]]; + m = elem3param[map[i]][map[j]][map[k]]; k_params.h_view(i,j,k).powerm = params[m].powerm; k_params.h_view(i,j,k).gamma = params[m].gamma; k_params.h_view(i,j,k).lam3 = params[m].lam3; diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index 4b7b50afe9..71f3215931 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -208,7 +208,7 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeShortNei int j = d_neighbors(i,jj); j &= NEIGHMASK; const int jtype = d_map[type[j]]; - const int ijparam = d_elem2param(itype,jtype,jtype); + const int ijparam = d_elem3param(itype,jtype,jtype); const X_FLOAT delx = xtmp - x(j,0); const X_FLOAT dely = ytmp - x(j,1); @@ -279,7 +279,7 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeHalf::operator()(TagPairVashishtaComputeHalf::operator()(TagPairVashishtaComputeHalf::operator()(TagPairVashishtaComputeFullA::operator()(TagPairVashishtaComputeFullA::operator()(TagPairVashishtaComputeFullA::operator()(TagPairVashishtaComputeFullB= nlocal) continue; const int jtype = d_map[type[j]]; - const int jiparam = d_elem2param(jtype,itype,itype); + const int jiparam = d_elem3param(jtype,itype,itype); const X_FLOAT xtmpj = x(j,0); const X_FLOAT ytmpj = x(j,1); const X_FLOAT ztmpj = x(j,2); @@ -508,8 +508,8 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeFullB::setup_params() { PairVashishta::setup_params(); - // sync elem2param and params + // sync elem3param and params - tdual_int_3d k_elem2param = tdual_int_3d("pair:elem2param",nelements,nelements,nelements); - t_host_int_3d h_elem2param = k_elem2param.h_view; + tdual_int_3d k_elem3param = tdual_int_3d("pair:elem3param",nelements,nelements,nelements); + t_host_int_3d h_elem3param = k_elem3param.h_view; tdual_param_1d k_params = tdual_param_1d("pair:params",nparams); t_host_param_1d h_params = k_params.h_view; @@ -622,17 +622,17 @@ void PairVashishtaKokkos::setup_params() for (int i = 0; i < nelements; i++) for (int j = 0; j < nelements; j++) for (int k = 0; k < nelements; k++) - h_elem2param(i,j,k) = elem2param[i][j][k]; + h_elem3param(i,j,k) = elem3param[i][j][k]; for (int m = 0; m < nparams; m++) h_params[m] = params[m]; - k_elem2param.template modify(); - k_elem2param.template sync(); + k_elem3param.template modify(); + k_elem3param.template sync(); k_params.template modify(); k_params.template sync(); - d_elem2param = k_elem2param.template view(); + d_elem3param = k_elem3param.template view(); d_params = k_params.template view(); } diff --git a/src/KOKKOS/pair_vashishta_kokkos.h b/src/KOKKOS/pair_vashishta_kokkos.h index 14dcf755df..aa8543e751 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.h +++ b/src/KOKKOS/pair_vashishta_kokkos.h @@ -102,7 +102,7 @@ class PairVashishtaKokkos : public PairVashishta { typedef typename tdual_int_3d::t_dev_const_randomread t_int_3d_randomread; typedef typename tdual_int_3d::t_host t_host_int_3d; - t_int_3d_randomread d_elem2param; + t_int_3d_randomread d_elem3param; typename AT::t_int_1d_randomread d_map; typedef Kokkos::DualView tdual_param_1d; diff --git a/src/MANYBODY/pair_adp.cpp b/src/MANYBODY/pair_adp.cpp index aa11e0682a..59afbc280b 100644 --- a/src/MANYBODY/pair_adp.cpp +++ b/src/MANYBODY/pair_adp.cpp @@ -45,7 +45,6 @@ PairADP::PairADP(LAMMPS *lmp) : Pair(lmp) fp = nullptr; mu = nullptr; lambda = nullptr; - map = nullptr; setfl = nullptr; @@ -86,7 +85,6 @@ PairADP::~PairADP() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; delete [] type2frho; memory->destroy(type2rhor); memory->destroy(type2z2r); diff --git a/src/MANYBODY/pair_adp.h b/src/MANYBODY/pair_adp.h index 65596113ba..6a292dda14 100644 --- a/src/MANYBODY/pair_adp.h +++ b/src/MANYBODY/pair_adp.h @@ -67,8 +67,6 @@ class PairADP : public Pair { // potentials as file data - int *map; // which element each atom type maps to - struct Setfl { char **elements; int nelements,nrho,nr; diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index be4f17b291..a8f64853bc 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -69,7 +69,6 @@ PairBOP::PairBOP(LAMMPS *lmp) : Pair(lmp) BOP_index3 = nullptr; BOP_total = nullptr; BOP_total3 = nullptr; - map = nullptr; pi_a = nullptr; pro_delta = nullptr; pi_delta = nullptr; @@ -184,7 +183,6 @@ PairBOP::~PairBOP() if (allocated) { memory_theta_destroy(); if (otfly==0) memory->destroy(cos_index); - delete [] map; memory->destroy(BOP_index); memory->destroy(BOP_total); @@ -620,11 +618,6 @@ void PairBOP::coeff(int narg, char **arg) if (narg != 3 + atom->ntypes) error->all(FLERR,"Incorrect args for pair coefficients"); - // ensure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - // read the potential file nr=2000; nBOt=2000; @@ -657,6 +650,7 @@ void PairBOP::coeff(int narg, char **arg) if (elements) { for (i = 0; i < bop_types; i++) delete [] elements[i]; delete [] elements; + elements = nullptr; } } // clear setflag since coeff() called once with I,J = * * @@ -4922,10 +4916,7 @@ void _noopt PairBOP::read_table(char *filename) ValueTokenizer values = reader.next_values(3); values.next_int(); values.next_double(); - std::string name = values.next_string(); - - elements[i] = new char[name.length()+1]; - strcpy(elements[i], name.c_str()); + elements[i] = utils::strdup(values.next_string()); } ValueTokenizer values = reader.next_values(2); diff --git a/src/MANYBODY/pair_bop.h b/src/MANYBODY/pair_bop.h index d61c969094..ba75d5c591 100644 --- a/src/MANYBODY/pair_bop.h +++ b/src/MANYBODY/pair_bop.h @@ -46,17 +46,12 @@ class PairBOP : public Pair { int update_list; // check for changing maximum size of neighbor list int maxbopn; // maximum size of bop neighbor list for allocation int maxnall; // maximum size of bop neighbor list for allocation - int *map; // mapping from atom types to elements - int nelements; // # of unique elements int nr; // increments for the BOP pair potential int ntheta; // increments for the angle function int npower; // power of the angular function int nBOt; // second BO increments int bop_types; // number of elements in potential int npairs; // number of element pairs - char **elements; // names of unique elements - int ***elem2param; - int nparams; int bop_step; int allocate_neigh; int nb_pi,nb_sg; diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 2d93c6783e..a1fc65deb7 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -62,12 +62,7 @@ PairComb::PairComb(LAMMPS *lmp) : Pair(lmp) map = nullptr; esm = nullptr; - nelements = 0; - elements = nullptr; - nparams = 0; - maxparam = 0; params = nullptr; - elem2param = nullptr; intype = nullptr; fafb = nullptr; @@ -97,12 +92,8 @@ PairComb::~PairComb() { memory->destroy(NCo); - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - - delete [] elements; memory->sfree(params); - memory->destroy(elem2param); + memory->destroy(elem3param); memory->destroy(intype); memory->destroy(fafb); @@ -120,7 +111,6 @@ PairComb::~PairComb() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; delete [] esm; } } @@ -184,7 +174,7 @@ void PairComb::compute(int eflag, int vflag) iq = q[i]; NCo[i] = 0; nj = 0; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; // self energy, only on i atom @@ -223,7 +213,7 @@ void PairComb::compute(int eflag, int vflag) dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; // long range q-dependent @@ -282,7 +272,7 @@ void PairComb::compute(int eflag, int vflag) for (jj = 0; jj < sht_jnum; jj++) { j = sht_jlist[jj]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (params[iparam_ij].hfocor > 0.0) { delr1[0] = x[j][0] - xtmp; @@ -303,7 +293,7 @@ void PairComb::compute(int eflag, int vflag) j = sht_jlist[jj]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; // this Qj for q-dependent BSi @@ -326,7 +316,7 @@ void PairComb::compute(int eflag, int vflag) k = sht_jlist[kk]; if (j == k) continue; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -370,7 +360,7 @@ void PairComb::compute(int eflag, int vflag) k = sht_jlist[kk]; if (j == k) continue; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -445,54 +435,15 @@ void PairComb::settings(int narg, char **/*arg*/) void PairComb::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - n = atom->ntypes; - // generate streitz-mintmire direct 1/r energy look-up table if (comm->me == 0 && screen) @@ -506,24 +457,6 @@ void PairComb::coeff(int narg, char **arg) else fputs(" will not apply over-coordination correction ...\n",screen); } - - // clear setflag since coeff() called once with I,J = * * - - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -741,12 +674,12 @@ void PairComb::setup_params() { int i,j,k,m,n; - // set elem2param for all element triplet combinations + // set elem3param for all element triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -760,7 +693,7 @@ void PairComb::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // compute parameter values derived from inputs @@ -1403,7 +1336,7 @@ void PairComb::sm_table() if (map[i+1] < 0) continue; r = drin; itype = params[map[i+1]].ielement; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; z = params[iparam_i].esm1; if (comm->me == 0 && screen) @@ -1425,7 +1358,7 @@ void PairComb::sm_table() if (j == i) { itype = params[map[i+1]].ielement; inty = intype[itype][itype]; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; z = params[iparam_i].esm1; zrc = z * rc; exp2ersh = exp(-2.0 * zrc); @@ -1451,10 +1384,10 @@ void PairComb::sm_table() itype = params[map[i+1]].ielement; jtype = params[map[j+1]].ielement; inty = intype[itype][jtype]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; ea = params[iparam_ij].esm1; ea3 = ea*ea*ea; - iparam_ji = elem2param[jtype][itype][itype]; + iparam_ji = elem3param[jtype][itype][itype]; eb = params[iparam_ji].esm1; eb3 = eb*eb*eb; E1 = ea*eb3*eb/((ea+eb)*(ea+eb)*(ea-eb)*(ea-eb)); @@ -1672,7 +1605,7 @@ double PairComb::yasu_char(double *qf_fix, int &igroup) ytmp = x[i][1]; ztmp = x[i][2]; iq = q[i]; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; // charge force from self energy @@ -1706,7 +1639,7 @@ double PairComb::yasu_char(double *qf_fix, int &igroup) delr1[2] = x[j][2] - ztmp; rsq1 = dot3(delr1,delr1); - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; // long range q-dependent @@ -1743,7 +1676,7 @@ double PairComb::yasu_char(double *qf_fix, int &igroup) delr1[2] = x[j][2] - ztmp; rsq1 = dot3(delr1,delr1); - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq1 > params[iparam_ij].cutsq) continue; nj ++; diff --git a/src/MANYBODY/pair_comb.h b/src/MANYBODY/pair_comb.h index c127bc0543..51b522badf 100644 --- a/src/MANYBODY/pair_comb.h +++ b/src/MANYBODY/pair_comb.h @@ -62,12 +62,6 @@ class PairComb : public Pair { }; double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets double precision; Param *params; // parameter set for an I-J-K interaction diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index d7814737ea..a0fa3b96b6 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -63,12 +63,7 @@ PairComb3::PairComb3(LAMMPS *lmp) : Pair(lmp) map = nullptr; esm = nullptr; - nelements = 0; - elements = nullptr; - nparams = 0; - maxparam = 0; params = nullptr; - elem2param = nullptr; intype = nullptr; afb = nullptr; @@ -107,12 +102,8 @@ PairComb3::~PairComb3() { memory->destroy(NCo); - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - - delete [] elements; memory->sfree(params); - memory->destroy(elem2param); + memory->destroy(elem3param); memory->destroy(afb); memory->destroy(dpl); @@ -139,7 +130,6 @@ PairComb3::~PairComb3() memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(cutghost); - delete [] map; delete [] esm; } @@ -184,78 +174,31 @@ void PairComb3::settings(int narg, char **arg) void PairComb3::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); + cflag = 0; + for (int i = 3; i < narg; i++) + if (strcmp(arg[i],"C") == 0) { + cflag = 1; + break; + } - // insure I,J args are * * - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if ((strcmp(arg[i],"C") == 0) && (cflag == 0)) { - if (comm->me == 0 && screen) - fputs(" PairComb3: Found C: reading additional library file\n",screen); + if (cflag) { + if (comm->me == 0 && screen) + fputs(" PairComb3: Found C: reading additional library file\n",screen); read_lib(); - cflag = 1; - } - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } } + map_element2type(narg-3,arg+3); + // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - n = atom->ntypes; - // generate Wolf 1/r energy and van der Waals look-up tables + tables(); - - // clear setflag since coeff() called once with I,J = * * - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - } /* ---------------------------------------------------------------------- @@ -687,12 +630,12 @@ void PairComb3::setup_params() { int i,j,k,m,n; - // set elem2param for all element triplet combinations + // set elem3param for all element triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -706,7 +649,7 @@ void PairComb3::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // compute parameter values derived from inputs @@ -804,7 +747,7 @@ void PairComb3::Short_neigh() delrj[2] = x[i][2] - x[j][2]; rsq1 = dot3(delrj,delrj); jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq1 > cutmin) continue; @@ -928,8 +871,8 @@ void PairComb3::compute(int eflag, int vflag) delrj[2] = x[j][2] - ztmp; rsq = dot3(delrj,delrj); - iparam_ij = elem2param[itype][jtype][jtype]; - iparam_ji = elem2param[jtype][itype][itype]; + iparam_ij = elem3param[itype][jtype][jtype]; + iparam_ji = elem3param[jtype][itype][itype]; if (rsq > params[iparam_ij].lcutsq) continue; @@ -950,7 +893,7 @@ void PairComb3::compute(int eflag, int vflag) ztmp = x[i][2]; iq = q[i]; nj = 0; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; // self energy, only on i atom yaself = self(¶ms[iparam_i],iq); @@ -991,8 +934,8 @@ void PairComb3::compute(int eflag, int vflag) dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - iparam_ij = elem2param[itype][jtype][jtype]; - iparam_ji = elem2param[jtype][itype][itype]; + iparam_ij = elem3param[itype][jtype][jtype]; + iparam_ji = elem3param[jtype][itype][itype]; if (rsq > params[iparam_ij].lcutsq) continue; @@ -1091,8 +1034,8 @@ void PairComb3::compute(int eflag, int vflag) ycn = NCo[j]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; - iparam_ji = elem2param[jtype][itype][itype]; + iparam_ij = elem3param[itype][jtype][jtype]; + iparam_ji = elem3param[jtype][itype][itype]; delrj[0] = x[j][0] - xtmp; delrj[1] = x[j][1] - ytmp; @@ -1114,10 +1057,10 @@ void PairComb3::compute(int eflag, int vflag) if (j == k) continue; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; - iparam_ikj = elem2param[itype][ktype][jtype]; - iparam_jik = elem2param[jtype][itype][ktype]; - iparam_ik = elem2param[itype][ktype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; + iparam_ikj = elem3param[itype][ktype][jtype]; + iparam_jik = elem3param[jtype][itype][ktype]; + iparam_ik = elem3param[itype][ktype][ktype]; delrk[0] = x[k][0] - xtmp; delrk[1] = x[k][1] - ytmp; delrk[2] = x[k][2] - ztmp; @@ -1133,7 +1076,7 @@ void PairComb3::compute(int eflag, int vflag) if (params[iparam_ij].rad_flag > 0 && params[iparam_ik].ielementgp == 1 && params[iparam_ik].jelementgp == 1) { - iparam_ki = elem2param[ktype][itype][itype]; + iparam_ki = elem3param[ktype][itype][itype]; kcn=NCo[k]; kconjug += rad_init(rsq2,¶ms[iparam_ki],i,kradtot,kcn); @@ -1157,11 +1100,11 @@ void PairComb3::compute(int eflag, int vflag) delrl[1] = x[l][1] - x[j][1]; delrl[2] = x[l][2] - x[j][2]; rsq3 = dot3(delrl,delrl); - iparam_jl = elem2param[jtype][ltype][ltype]; + iparam_jl = elem3param[jtype][ltype][ltype]; if (rsq3 > params[iparam_jl].cutsq) continue; - iparam_ikl = elem2param[itype][ktype][ltype]; + iparam_ikl = elem3param[itype][ktype][ltype]; torindx = params[iparam_ij].tor_flag; bbtor += bbtor1(torindx, ¶ms[iparam_ikl],¶ms[iparam_jl], rsq1,rsq2,rsq3,delrj,delrk,delrl,srmu); @@ -1178,10 +1121,10 @@ void PairComb3::compute(int eflag, int vflag) if (l == i) continue; ltype = map[type[l]]; - iparam_jil = elem2param[jtype][itype][ltype]; - iparam_ijl = elem2param[itype][jtype][ltype]; - iparam_jl = elem2param[jtype][ltype][ltype]; - iparam_lj = elem2param[ltype][jtype][jtype]; + iparam_jil = elem3param[jtype][itype][ltype]; + iparam_ijl = elem3param[itype][jtype][ltype]; + iparam_jl = elem3param[jtype][ltype][ltype]; + iparam_lj = elem3param[ltype][jtype][jtype]; delrk[0] = x[l][0] - x[j][0]; delrk[1] = x[l][1] - x[j][1]; @@ -1204,7 +1147,7 @@ void PairComb3::compute(int eflag, int vflag) if (params[iparam_ji].rad_flag > 0 && params[iparam_jl].ielementgp == 1 && params[iparam_jl].jelementgp == 1) { - iparam_lj = elem2param[ltype][jtype][jtype]; + iparam_lj = elem3param[ltype][jtype][jtype]; lcn=NCo[l]; lconjug += rad_init(rsq2,¶ms[iparam_lj],j,lradtot,lcn); } @@ -1240,10 +1183,10 @@ void PairComb3::compute(int eflag, int vflag) sht_mnum = sht_num[k]; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; - iparam_ikj = elem2param[itype][ktype][jtype]; - iparam_jik = elem2param[jtype][itype][ktype]; - iparam_ik = elem2param[itype][ktype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; + iparam_ikj = elem3param[itype][ktype][jtype]; + iparam_jik = elem3param[jtype][itype][ktype]; + iparam_ik = elem3param[itype][ktype][ktype]; delrk[0] = x[k][0] - xtmp; delrk[1] = x[k][1] - ytmp; delrk[2] = x[k][2] - ztmp; @@ -1289,9 +1232,9 @@ void PairComb3::compute(int eflag, int vflag) delrl[2] = x[l][2] - x[j][2]; rsq3 = dot3(delrl,delrl); - iparam_jl = elem2param[jtype][ltype][ltype]; + iparam_jl = elem3param[jtype][ltype][ltype]; if (rsq3 > params[iparam_jl].cutsq) continue; - iparam_ikl = elem2param[itype][ktype][ltype]; + iparam_ikl = elem3param[itype][ktype][ltype]; torindx = params[iparam_ij].tor_flag; tor_force(torindx, ¶ms[iparam_ikl], ¶ms[iparam_jl],srmu, rsq1,rsq2,rsq3,delrj,delrk,delrl); @@ -1309,7 +1252,7 @@ void PairComb3::compute(int eflag, int vflag) if ( params[iparam_ijk].rad_flag>=1 && params[iparam_ijk].ielementgp==1 && params[iparam_ijk].kelementgp==1) { - iparam_ki = elem2param[ktype][itype][itype]; + iparam_ki = elem3param[ktype][itype][itype]; kcn=NCo[k]; double rik=sqrt(rsq2); kradtot = -comb_fc(rik,¶ms[iparam_ki])*params[iparam_ki].pcross+kcn; @@ -1333,8 +1276,8 @@ void PairComb3::compute(int eflag, int vflag) delrm[2] = x[m][2] - x[k][2]; rsq3 = dot3(delrm,delrm); - iparam_km = elem2param[ktype][mtype][mtype]; - iparam_ki = elem2param[ktype][itype][itype]; + iparam_km = elem3param[ktype][mtype][mtype]; + iparam_ki = elem3param[ktype][itype][itype]; if (rsq3 > params[iparam_km].cutsq) continue; @@ -1364,10 +1307,10 @@ void PairComb3::compute(int eflag, int vflag) sht_pnum = sht_num[l]; ltype = map[type[l]]; - iparam_jil = elem2param[jtype][itype][ltype]; - iparam_jli = elem2param[jtype][ltype][itype]; - iparam_ijl = elem2param[itype][jtype][ltype]; - iparam_jl = elem2param[jtype][ltype][ltype]; + iparam_jil = elem3param[jtype][itype][ltype]; + iparam_jli = elem3param[jtype][ltype][itype]; + iparam_ijl = elem3param[itype][jtype][ltype]; + iparam_jl = elem3param[jtype][ltype][ltype]; delrk[0] = x[l][0] - x[j][0]; delrk[1] = x[l][1] - x[j][1]; delrk[2] = x[l][2] - x[j][2]; @@ -1405,7 +1348,7 @@ void PairComb3::compute(int eflag, int vflag) if ( params[iparam_jil].rad_flag >= 1 && params[iparam_jil].ielementgp == 1 && params[iparam_jil].kelementgp == 1) { - iparam_lj = elem2param[ltype][jtype][jtype]; + iparam_lj = elem3param[ltype][jtype][jtype]; lcn=NCo[l]; double rjl=sqrt(rsq2); lradtot=-comb_fc(rjl,¶ms[iparam_lj])*params[iparam_lj].pcross +lcn; @@ -1428,7 +1371,7 @@ void PairComb3::compute(int eflag, int vflag) delrp[2] = x[p][2] - x[l][2]; rsq3 = dot3(delrp,delrp); - iparam_lp = elem2param[ltype][ptype][ptype]; + iparam_lp = elem3param[ltype][ptype][ptype]; if (rsq3 > params[iparam_lp].cutsq) continue; @@ -2354,7 +2297,7 @@ void PairComb3::tables() if (map[i+1] < 0) continue; r = drin - dra; itype = map[i+1]; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; z = params[iparam_i].esm; exp2ershift = exp(-2.0*z*rc); afbshift = -exp2ershift*(z+1.0/rc); @@ -2381,7 +2324,7 @@ void PairComb3::tables() if (j == i) { itype = map[i+1]; inty = intype[itype][itype]; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; z = params[iparam_i].esm; zrc = z * rc; exp2ersh = exp(-2.0 * zrc); @@ -2407,10 +2350,10 @@ void PairComb3::tables() itype = map[i+1]; jtype = map[j+1]; inty = intype[itype][jtype]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; ea = params[iparam_ij].esm; ea3 = ea*ea*ea; - iparam_ji = elem2param[jtype][itype][itype]; + iparam_ji = elem3param[jtype][itype][itype]; eb = params[iparam_ji].esm; eb3 = eb*eb*eb; E1 = ea*eb3*eb/((ea+eb)*(ea+eb)*(ea-eb)*(ea-eb)); @@ -2474,7 +2417,7 @@ void PairComb3::tables() itype = ii; jtype = jj; inty = intype[itype][jtype]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; // parameter check: eps > 0 if (params[iparam_ij].vdwflag > 0) { @@ -2521,7 +2464,7 @@ void PairComb3::tables() itype = ii; jtype = jj; inty = intype[itype][jtype]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; r = drin; for (k = 0; k < ncoul; k ++) { r6 = r*r*r*r*r*r; @@ -3229,7 +3172,7 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) ytmp = x[i][1]; ztmp = x[i][2]; iq = q[i]; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; // charge force from self energy fqi = qfo_self(¶ms[iparam_i],iq); @@ -3257,8 +3200,8 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) delrj[2] = ztmp - x[j][2]; rsq1 = dot3(delrj,delrj); - iparam_ij = elem2param[itype][jtype][jtype]; - iparam_ji = elem2param[jtype][itype][itype]; + iparam_ij = elem3param[itype][jtype][jtype]; + iparam_ji = elem3param[jtype][itype][itype]; // long range q-dependent @@ -3304,8 +3247,8 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) delrj[2] = ztmp - x[j][2]; rsq1 = dot3(delrj,delrj); - iparam_ij = elem2param[itype][jtype][jtype]; - iparam_ji = elem2param[jtype][itype][itype]; + iparam_ij = elem3param[itype][jtype][jtype]; + iparam_ji = elem3param[jtype][itype][itype]; if (rsq1 >= params[iparam_ij].cutsq) continue; nj ++; diff --git a/src/MANYBODY/pair_comb3.h b/src/MANYBODY/pair_comb3.h index b999d2cece..d03ee0e474 100644 --- a/src/MANYBODY/pair_comb3.h +++ b/src/MANYBODY/pair_comb3.h @@ -61,16 +61,10 @@ class PairComb3 : public Pair { }; // general setups - int nelements; // # of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets double PI,PI2,PI4,PIsq; // PIs double cutmin; // min cutoff for all elements double cutmax; // max cutoff for all elements double precision; // tolerance for QEq convergence - char **elements; // names of unique elements Param *params; // parameter set for an I-J-K interaction int debug_eng1, debug_eng2, debug_fq; // logic controlling debugging outputs int pack_flag; diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index 03098904c8..b5fd507687 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -49,7 +49,6 @@ PairEAM::PairEAM(LAMMPS *lmp) : Pair(lmp) rho = nullptr; fp = nullptr; numforce = nullptr; - map = nullptr; type2frho = nullptr; nfuncfl = 0; @@ -90,9 +89,7 @@ PairEAM::~PairEAM() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; delete [] type2frho; - map = nullptr; type2frho = nullptr; memory->destroy(type2rhor); memory->destroy(type2z2r); @@ -348,6 +345,7 @@ void PairEAM::allocate() memory->create(cutsq,n+1,n+1,"pair:cutsq"); + delete[] map; map = new int[n+1]; for (int i = 1; i <= n; i++) map[i] = -1; diff --git a/src/MANYBODY/pair_eam.h b/src/MANYBODY/pair_eam.h index 7e47c0f4e9..e9cbd15f34 100644 --- a/src/MANYBODY/pair_eam.h +++ b/src/MANYBODY/pair_eam.h @@ -75,8 +75,6 @@ class PairEAM : public Pair { // potentials as file data - int *map; // which element each atom type maps to - struct Funcfl { char *file; int nrho,nr; diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index b82a410791..eda1838a5a 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -46,10 +46,6 @@ PairEIM::PairEIM(LAMMPS *lmp) : Pair(lmp) nmax = 0; rho = nullptr; fp = nullptr; - map = nullptr; - - nelements = 0; - elements = nullptr; negativity = nullptr; q0 = nullptr; @@ -80,15 +76,11 @@ PairEIM::~PairEIM() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; memory->destroy(type2Fij); memory->destroy(type2Gij); memory->destroy(type2phiij); } - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - deallocate_setfl(); delete [] negativity; @@ -353,8 +345,6 @@ void PairEIM::settings(int narg, char **/*arg*/) void PairEIM::coeff(int narg, char **arg) { - int i,j,m,n; - if (!allocated) allocate(); if (narg < 5) error->all(FLERR,"Incorrect args for pair coefficients"); @@ -364,23 +354,8 @@ void PairEIM::coeff(int narg, char **arg) if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) error->all(FLERR,"Incorrect args for pair coefficients"); - // read EIM element names before filename - // nelements = # of EIM elements to read from file - // elements = list of unique element names - - if (nelements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - nelements = narg - 3 - atom->ntypes; - if (nelements < 1) error->all(FLERR,"Incorrect args for pair coefficients"); - elements = new char*[nelements]; - - for (i = 0; i < nelements; i++) { - n = strlen(arg[i+2]) + 1; - elements[i] = new char[n]; - strcpy(elements[i],arg[i+2]); - } + const int ntypes = atom->ntypes; + map_element2type(ntypes,arg+(narg-ntypes)); // read EIM file @@ -388,38 +363,12 @@ void PairEIM::coeff(int narg, char **arg) setfl = new Setfl(); read_file(arg[2+nelements]); - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" + // set per-type atomic masses - for (i = 3 + nelements; i < narg; i++) { - m = i - (3+nelements) + 1; - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - if (j < nelements) map[m] = j; - else if (strcmp(arg[i],"NULL") == 0) map[m] = -1; - else error->all(FLERR,"Incorrect args for pair coefficients"); - } - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - // set mass of atom type if i = j - - int count = 0; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; + for (int i = 1; i <= ntypes; i++) + for (int j = i; j <= ntypes; j++) + if ((map[i] >= 0) && (map[j] >= 0)) if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- diff --git a/src/MANYBODY/pair_eim.h b/src/MANYBODY/pair_eim.h index 75f8ea6bea..7611898c45 100644 --- a/src/MANYBODY/pair_eim.h +++ b/src/MANYBODY/pair_eim.h @@ -60,10 +60,6 @@ class PairEIM : public Pair { int nmax; double *rho,*fp; int rhofp; - int *map; // which element each atom type maps to - - int nelements; // # of elements to read from potential file - char **elements; // element names Setfl *setfl; diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 6039e00c0a..7e0cb3a3a2 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -51,12 +51,7 @@ PairGW::PairGW(LAMMPS *lmp) : Pair(lmp) centroidstressflag = CENTROID_NOTAVAIL; unit_convert_flag = utils::get_supported_conversions(utils::ENERGY); - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; - map = nullptr; } /* ---------------------------------------------------------------------- @@ -65,16 +60,12 @@ PairGW::PairGW(LAMMPS *lmp) : Pair(lmp) PairGW::~PairGW() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; } } @@ -142,7 +133,7 @@ void PairGW::compute(int eflag, int vflag) delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq > params[iparam_ij].cutsq) continue; repulsive(¶ms[iparam_ij],rsq,fpair,eflag,evdwl); @@ -165,7 +156,7 @@ void PairGW::compute(int eflag, int vflag) j = jlist[jj]; j &= NEIGHMASK; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; @@ -182,7 +173,7 @@ void PairGW::compute(int eflag, int vflag) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -214,7 +205,7 @@ void PairGW::compute(int eflag, int vflag) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -271,70 +262,14 @@ void PairGW::settings(int narg, char **/*arg*/) void PairGW::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -480,12 +415,12 @@ void PairGW::setup_params() { int i,j,k,m,n; - // set elem2param for all element triplet combinations + // set elem3param for all element triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -500,7 +435,7 @@ void PairGW::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_gw.h b/src/MANYBODY/pair_gw.h index 620f0b1af0..a1cbdb5c86 100644 --- a/src/MANYBODY/pair_gw.h +++ b/src/MANYBODY/pair_gw.h @@ -52,13 +52,7 @@ class PairGW : public Pair { }; Param *params; // parameter set for an I-J-K interaction - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to paramegw - int *map; // mapping from atom types to elements double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets int **pages; // neighbor list pages int maxlocal; // size of numneigh, firstneigh arrays diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index a2a8c3d1fa..727556dd50 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -74,8 +74,6 @@ PairLCBOP::~PairLCBOP() memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(cutghost); - - delete [] map; } } @@ -128,48 +126,17 @@ void PairLCBOP::coeff(int narg, char **arg) { if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); + map_element2type(narg-3,arg+3); - // insure I,J args are * * + // only element "C" is allowed - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to C and "NULL" - // map[i] = which element (0 for C) the Ith atom type is, -1 if "NULL" - - for (int i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - } else if (strcmp(arg[i],"C") == 0) { - map[i-2] = 0; - } else error->all(FLERR,"Incorrect args for pair coefficients"); - } + if ((nelements != 1) || (strcmp(elements[0],"C") != 0)) + error->all(FLERR,"Incorrect args for pair coefficients"); // read potential file and initialize fitting splines read_file(arg[2]); spline_init(); - - // clear setflag since coeff() called once with I,J = * * - - int n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -965,11 +932,9 @@ void PairLCBOP::read_file(char *filename) int i,k,l; char s[MAXLINE]; - MPI_Comm_rank(world,&me); - // read file on proc 0 - if (me == 0) { + if (comm->me == 0) { FILE *fp = utils::open_potential(filename,lmp,nullptr); if (fp == nullptr) { char str[128]; diff --git a/src/MANYBODY/pair_lcbop.h b/src/MANYBODY/pair_lcbop.h index dacbe74158..4ee89b4148 100644 --- a/src/MANYBODY/pair_lcbop.h +++ b/src/MANYBODY/pair_lcbop.h @@ -39,9 +39,6 @@ class PairLCBOP : public Pair { protected: int **pages; // neighbor list pages - int *map; // 0 (C) or -1 ("NULL") for each type - - int me; double cutLR; // LR cutoff diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index a1dc903a43..dfc4046eda 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -50,12 +50,7 @@ PairNb3bHarmonic::PairNb3bHarmonic(LAMMPS *lmp) : Pair(lmp) centroidstressflag = CENTROID_NOTAVAIL; unit_convert_flag = utils::get_supported_conversions(utils::ENERGY); - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; - map = nullptr; } /* ---------------------------------------------------------------------- @@ -64,16 +59,12 @@ PairNb3bHarmonic::PairNb3bHarmonic(LAMMPS *lmp) : Pair(lmp) PairNb3bHarmonic::~PairNb3bHarmonic() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; } } @@ -117,7 +108,7 @@ void PairNb3bHarmonic::compute(int eflag, int vflag) j = jlist[jj]; j &= NEIGHMASK; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -128,8 +119,8 @@ void PairNb3bHarmonic::compute(int eflag, int vflag) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -186,70 +177,14 @@ void PairNb3bHarmonic::settings(int narg, char **/*arg*/) void PairNb3bHarmonic::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } @@ -374,12 +309,12 @@ void PairNb3bHarmonic::setup_params() int i,j,k,m,n; double rtmp; - // set elem2param for all triplet combinations + // set elem3param for all triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -393,7 +328,7 @@ void PairNb3bHarmonic::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // compute parameter values derived from inputs diff --git a/src/MANYBODY/pair_nb3b_harmonic.h b/src/MANYBODY/pair_nb3b_harmonic.h index b68974e15f..38ec07c78b 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.h +++ b/src/MANYBODY/pair_nb3b_harmonic.h @@ -44,12 +44,6 @@ class PairNb3bHarmonic : public Pair { }; double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction void allocate(); diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index a353ad1c47..e267031901 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -49,14 +49,11 @@ PairPolymorphic::PairPolymorphic(LAMMPS *lmp) : Pair(lmp) manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; - nelements = 0; - elements = nullptr; match = nullptr; pairParameters = nullptr; tripletParameters = nullptr; elem2param = nullptr; elem3param = nullptr; - map = nullptr; epsilon = 0.0; neighsize = 0; firstneighV = nullptr; @@ -78,9 +75,6 @@ PairPolymorphic::PairPolymorphic(LAMMPS *lmp) : Pair(lmp) PairPolymorphic::~PairPolymorphic() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; delete [] match; delete [] pairParameters; @@ -91,7 +85,6 @@ PairPolymorphic::~PairPolymorphic() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; delete [] firstneighV; delete [] firstneighW; delete [] firstneighW1; @@ -466,74 +459,19 @@ void PairPolymorphic::settings(int narg, char **/*arg*/) void PairPolymorphic::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg == 4 + atom->ntypes) { - narg--; - epsilon = atof(arg[narg]); - } else if (narg != 3 + atom->ntypes) { - error->all(FLERR,"Incorrect args for pair coefficients"); - } + // parse and remove optional last parameter - // insure I,J args are * * + if (narg == 4 + atom->ntypes) + epsilon = utils::numeric(FLERR,arg[--narg],false,lmp); - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- diff --git a/src/MANYBODY/pair_polymorphic.h b/src/MANYBODY/pair_polymorphic.h index c94acd6230..a8a74267cd 100644 --- a/src/MANYBODY/pair_polymorphic.h +++ b/src/MANYBODY/pair_polymorphic.h @@ -302,13 +302,8 @@ class PairPolymorphic : public Pair { double *delxV,*delyV,*delzV,*drV; double *delxW,*delyW,*delzW,*drW; - char **elements; // names of unique elements - int **elem2param; // map: element pairs to parameters - int ***elem3param; // map: element triplets to parameters - int *map; // mapping from atom types to elements double cutmax; // max cutoff for all elements double cutmaxsq; - int nelements; // # of unique elements int npair,ntriple; int *match; diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index e7a334d9a9..fe7e56456e 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -46,12 +46,7 @@ PairSW::PairSW(LAMMPS *lmp) : Pair(lmp) centroidstressflag = CENTROID_NOTAVAIL; unit_convert_flag = utils::get_supported_conversions(utils::ENERGY); - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; - map = nullptr; maxshort = 10; neighshort = nullptr; @@ -65,17 +60,13 @@ PairSW::~PairSW() { if (copymode) return; - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(neighshort); - delete [] map; } } @@ -135,7 +126,7 @@ void PairSW::compute(int eflag, int vflag) rsq = delx*delx + dely*dely + delz*delz; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (rsq >= params[ijparam].cutsq) { continue; } else { @@ -175,7 +166,7 @@ void PairSW::compute(int eflag, int vflag) for (jj = 0; jj < jnumm1; jj++) { j = neighshort[jj]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -187,8 +178,8 @@ void PairSW::compute(int eflag, int vflag) for (kk = jj+1; kk < numshort; kk++) { k = neighshort[kk]; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -250,70 +241,14 @@ void PairSW::settings(int narg, char **/*arg*/) void PairSW::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -451,12 +386,12 @@ void PairSW::setup_params() int i,j,k,m,n; double rtmp; - // set elem2param for all triplet combinations + // set elem3param for all triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -470,7 +405,7 @@ void PairSW::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_sw.h b/src/MANYBODY/pair_sw.h index 4fdc538430..4e13caee85 100644 --- a/src/MANYBODY/pair_sw.h +++ b/src/MANYBODY/pair_sw.h @@ -50,12 +50,6 @@ class PairSW : public Pair { protected: double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction int maxshort; // size of short neighbor list array int *neighshort; // short neighbor list array diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index dea01589a6..2a642e6244 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -54,12 +54,7 @@ PairTersoff::PairTersoff(LAMMPS *lmp) : Pair(lmp) centroidstressflag = CENTROID_NOTAVAIL; unit_convert_flag = utils::get_supported_conversions(utils::ENERGY); - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; - map = nullptr; maxshort = 10; neighshort = nullptr; @@ -73,17 +68,13 @@ PairTersoff::~PairTersoff() { if (copymode) return; - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(neighshort); - delete [] map; } } @@ -204,7 +195,7 @@ void PairTersoff::eval() } jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq >= params[iparam_ij].cutsq) continue; repulsive(¶ms[iparam_ij],rsq,fpair,EFLAG,evdwl); @@ -231,7 +222,7 @@ void PairTersoff::eval() for (jj = 0; jj < numshort; jj++) { j = neighshort[jj]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; @@ -255,7 +246,7 @@ void PairTersoff::eval() if (jj == kk) continue; k = neighshort[kk]; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -295,7 +286,7 @@ void PairTersoff::eval() if (jj == kk) continue; k = neighshort[kk]; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -383,70 +374,14 @@ void PairTersoff::settings(int narg, char **arg) void PairTersoff::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -598,12 +533,12 @@ void PairTersoff::setup_params() { int i,j,k,m,n; - // set elem2param for all element triplet combinations + // set elem3param for all element triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -617,7 +552,7 @@ void PairTersoff::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_tersoff.h b/src/MANYBODY/pair_tersoff.h index 18c6ebc5f9..a4612d03be 100644 --- a/src/MANYBODY/pair_tersoff.h +++ b/src/MANYBODY/pair_tersoff.h @@ -59,13 +59,7 @@ class PairTersoff : public Pair { }; Param *params; // parameter set for an I-J-K interaction - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets int maxshort; // size of short neighbor list array int *neighshort; // short neighbor list array diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index 86994ccc0e..465bc0ebd0 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -163,12 +163,12 @@ void PairTersoffMOD::setup_params() { int i,j,k,m,n; - // set elem2param for all element triplet combinations + // set elem3param for all element triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -182,7 +182,7 @@ void PairTersoffMOD::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 94f211dd95..cacfa7078e 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -48,12 +48,7 @@ PairVashishta::PairVashishta(LAMMPS *lmp) : Pair(lmp) centroidstressflag = CENTROID_NOTAVAIL; unit_convert_flag = utils::get_supported_conversions(utils::ENERGY); - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; - map = nullptr; r0max = 0.0; maxshort = 10; @@ -68,17 +63,13 @@ PairVashishta::~PairVashishta() { if (copymode) return; - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(neighshort); - delete [] map; } } @@ -158,7 +149,7 @@ void PairVashishta::compute(int eflag, int vflag) } jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (rsq >= params[ijparam].cutsq) continue; twobody(¶ms[ijparam],rsq,fpair,eflag,evdwl); @@ -179,7 +170,7 @@ void PairVashishta::compute(int eflag, int vflag) for (jj = 0; jj < jnumm1; jj++) { j = neighshort[jj]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -192,8 +183,8 @@ void PairVashishta::compute(int eflag, int vflag) for (kk = jj+1; kk < numshort; kk++) { k = neighshort[kk]; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -257,70 +248,14 @@ void PairVashishta::settings(int narg, char **/*arg*/) void PairVashishta::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -465,12 +400,12 @@ void PairVashishta::setup_params() { int i,j,k,m,n; - // set elem2param for all triplet combinations + // set elem3param for all triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -484,7 +419,7 @@ void PairVashishta::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // compute parameter values derived from inputs diff --git a/src/MANYBODY/pair_vashishta.h b/src/MANYBODY/pair_vashishta.h index 19a8e01cd9..06c23b2384 100644 --- a/src/MANYBODY/pair_vashishta.h +++ b/src/MANYBODY/pair_vashishta.h @@ -48,12 +48,6 @@ class PairVashishta : public Pair { }; protected: double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction double r0max; // largest value of r0 int maxshort; // size of short neighbor list array diff --git a/src/MANYBODY/pair_vashishta_table.cpp b/src/MANYBODY/pair_vashishta_table.cpp index 76b44d8664..14dacdae3f 100644 --- a/src/MANYBODY/pair_vashishta_table.cpp +++ b/src/MANYBODY/pair_vashishta_table.cpp @@ -120,7 +120,7 @@ void PairVashishtaTable::compute(int eflag, int vflag) } jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (rsq >= params[ijparam].cutsq) continue; twobody_table(params[ijparam],rsq,fpair,eflag,evdwl); @@ -141,7 +141,7 @@ void PairVashishtaTable::compute(int eflag, int vflag) for (jj = 0; jj < jnumm1; jj++) { j = neighshort[jj]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; delr1[2] = x[j][2] - ztmp; @@ -154,8 +154,8 @@ void PairVashishtaTable::compute(int eflag, int vflag) for (kk = jj+1; kk < numshort; kk++) { k = neighshort[kk]; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -272,7 +272,7 @@ void PairVashishtaTable::create_tables() for (i = 0; i < nelements; i++) { for (j = 0; j < nelements; j++) { - int ijparam = elem2param[i][j][j]; + int ijparam = elem3param[i][j][j]; for (idx = 0; idx <= ntable; idx++) { rsq = tabinnersq + idx*deltaR2; PairVashishta::twobody(¶ms[ijparam],rsq,fpair,1,eng); diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 7d57ca3673..ae0023ddec 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -42,8 +42,6 @@ PairSNAP::PairSNAP(LAMMPS *lmp) : Pair(lmp) manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; - nelements = 0; - elements = nullptr; radelem = nullptr; wjelem = nullptr; coeffelem = nullptr; @@ -60,14 +58,9 @@ PairSNAP::~PairSNAP() { if (copymode) return; - if (nelements) { - for (int i = 0; i < nelements; i++) - delete[] elements[i]; - delete[] elements; - memory->destroy(radelem); - memory->destroy(wjelem); - memory->destroy(coeffelem); - } + memory->destroy(radelem); + memory->destroy(wjelem); + memory->destroy(coeffelem); memory->destroy(beta); memory->destroy(bispectrum); @@ -77,7 +70,6 @@ PairSNAP::~PairSNAP() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - memory->destroy(map); } } @@ -362,7 +354,7 @@ void PairSNAP::allocate() memory->create(setflag,n+1,n+1,"pair:setflag"); memory->create(cutsq,n+1,n+1,"pair:cutsq"); - memory->create(map,n+1,"pair:map"); + map = new int[n+1]; } /* ---------------------------------------------------------------------- @@ -384,61 +376,11 @@ void PairSNAP::coeff(int narg, char **arg) if (!allocated) allocate(); if (narg != 4 + atom->ntypes) error->all(FLERR,"Incorrect args for pair coefficients"); - char* type1 = arg[0]; - char* type2 = arg[1]; - char* coefffilename = arg[2]; - char* paramfilename = arg[3]; - char** elemtypes = &arg[4]; - - // insure I,J args are * * - - if (strcmp(type1,"*") != 0 || strcmp(type2,"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // clean out old arrays - - if (elements) { - for (int i = 0; i < nelements; i++) - delete[] elements[i]; - delete[] elements; - memory->destroy(radelem); - memory->destroy(wjelem); - memory->destroy(coeffelem); - } - - // nelements = # of unique elements declared - // elements = list of unique element names - // allocate as ntypes >= nelements - - elements = new char*[atom->ntypes]; - for (int i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - // read args that map atom types to SNAP elements - // map[i] = which element the Ith atom type is, -1 if not mapped - // map[0] is not used - - nelements = 0; - for (int i = 1; i <= atom->ntypes; i++) { - char* elemstring = elemtypes[i-1]; - if (strcmp(elemstring,"NULL") == 0) { - map[i] = -1; - continue; - } - int j; - for (j = 0; j < nelements; j++) - if (strcmp(elemstring,elements[j]) == 0) break; - map[i] = j; - if (j == nelements) { - int n = strlen(elemstring) + 1; - elements[j] = new char[n]; - strcpy(elements[j],elemstring); - nelements++; - } - } + map_element2type(narg-4,arg+4); // read snapcoeff and snapparam files - read_files(coefffilename,paramfilename); + read_files(arg[2],arg[3]); if (!quadraticflag) ncoeff = ncoeffall - 1; @@ -455,25 +397,6 @@ void PairSNAP::coeff(int narg, char **arg) } } - // clear setflag since coeff() called once with I,J = * * - - int n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - snaptr = new SNA(lmp, rfac0, twojmax, rmin0, switchflag, bzeroflag, chemflag, bnormflag, wselfallflag, nelements); @@ -571,8 +494,11 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) "file: {}", e.what())); } - // set up element lists + // clean out old arrays and set up element lists + memory->destroy(radelem); + memory->destroy(wjelem); + memory->destroy(coeffelem); memory->create(radelem,nelements,"pair:radelem"); memory->create(wjelem,nelements,"pair:wjelem"); memory->create(coeffelem,nelements,ncoeffall,"pair:coeffelem"); diff --git a/src/SNAP/pair_snap.h b/src/SNAP/pair_snap.h index d60000da3a..ee596d2ba7 100644 --- a/src/SNAP/pair_snap.h +++ b/src/SNAP/pair_snap.h @@ -50,14 +50,11 @@ protected: void compute_bispectrum(); double rcutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements double *radelem; // element radii double *wjelem; // elements weights double **coeffelem; // element bispectrum coefficients double** beta; // betas for all atoms in list double** bispectrum; // bispectrum components for all atoms in list - int *map; // mapping from atom types to elements int twojmax, switchflag, bzeroflag, bnormflag; int chemflag, wselfallflag; int chunksize; diff --git a/src/USER-INTEL/pair_sw_intel.cpp b/src/USER-INTEL/pair_sw_intel.cpp index 984b2100a3..bc5c40a258 100644 --- a/src/USER-INTEL/pair_sw_intel.cpp +++ b/src/USER-INTEL/pair_sw_intel.cpp @@ -1204,7 +1204,7 @@ void PairSWIntel::pack_force_const(ForceConst &fc, fc.p2e[ii][jj].c5 = 0; fc.p2e[ii][jj].c6 = 0; } else { - int ijparam = elem2param[i][j][j]; + int ijparam = elem3param[i][j][j]; fc.p2[ii][jj].cutsq = params[ijparam].cutsq; fc.p2[ii][jj].cut = params[ijparam].cut; fc.p2[ii][jj].sigma_gamma = params[ijparam].sigma_gamma; @@ -1237,7 +1237,7 @@ void PairSWIntel::pack_force_const(ForceConst &fc, mytypes++; _onetype = ii * tp1 + jj; _onetype3 = ii * tp1 * tp1 + jj * tp1 + kk; - int ijkparam = elem2param[i][j][k]; + int ijkparam = elem3param[i][j][k]; fc.p3[ii][jj][kk].costheta = params[ijkparam].costheta; fc.p3[ii][jj][kk].lambda_epsilon = params[ijkparam].lambda_epsilon; fc.p3[ii][jj][kk].lambda_epsilon2 = params[ijkparam].lambda_epsilon2; diff --git a/src/USER-INTEL/pair_tersoff_intel.cpp b/src/USER-INTEL/pair_tersoff_intel.cpp index 4284309b74..eb3ce562fa 100644 --- a/src/USER-INTEL/pair_tersoff_intel.cpp +++ b/src/USER-INTEL/pair_tersoff_intel.cpp @@ -482,7 +482,7 @@ void PairTersoffIntel::pack_force_const(ForceConst &fc, fc.c_inner_loop[i][0][j].d2 = 1.0; fc.c_inner_loop[0][i][j].d2 = 1.0; for (int k = 1; k < tp1; k++) { - Param * param = ¶ms[elem2param[map[i]][map[j]][map[k]]]; + Param * param = ¶ms[elem3param[map[i]][map[j]][map[k]]]; fc.c_cutoff_inner[i][k][j].cutsq = static_cast(param->cutsq); fc.c_inner_loop[i][j][k].lam3 = static_cast(param->lam3); fc.c_inner_loop[i][j][k].bigr = static_cast(param->bigr); @@ -504,7 +504,7 @@ void PairTersoffIntel::pack_force_const(ForceConst &fc, fc.c_inner[i][j][k].powermint = static_cast(param->powermint); } - Param * param = ¶ms[elem2param[map[i]][map[j]][map[j]]]; + Param * param = ¶ms[elem3param[map[i]][map[j]][map[j]]]; fc.c_cutoff_outer[i][j].cutsq = static_cast(param->cutsq); fc.c_first_loop[i][j].bigr = static_cast(param->bigr); fc.c_first_loop[i][j].bigd = static_cast(param->bigd); diff --git a/src/USER-MEAMC/pair_meamc.cpp b/src/USER-MEAMC/pair_meamc.cpp index 29d81e9516..67ab3522ad 100644 --- a/src/USER-MEAMC/pair_meamc.cpp +++ b/src/USER-MEAMC/pair_meamc.cpp @@ -55,7 +55,7 @@ PairMEAMC::PairMEAMC(LAMMPS *lmp) : Pair(lmp) allocated = 0; - nelements = 0; + nlibelements = 0; meam_inst = new MEAM(memory); scale = nullptr; @@ -78,7 +78,6 @@ PairMEAMC::~PairMEAMC() memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(scale); - delete [] map; } } @@ -239,23 +238,23 @@ void PairMEAMC::coeff(int narg, char **arg) error->all(FLERR,"Incorrect args for pair coefficients"); // MEAM element names between 2 filenames - // nelements = # of MEAM elements + // nlibelements = # of MEAM elements // elements = list of unique element names - if (nelements) { - elements.clear(); + if (nlibelements) { + libelements.clear(); mass.clear(); } - nelements = paridx - 3; - if (nelements < 1) error->all(FLERR,"Incorrect args for pair coefficients"); - if (nelements > maxelt) + nlibelements = paridx - 3; + if (nlibelements < 1) error->all(FLERR,"Incorrect args for pair coefficients"); + if (nlibelements > maxelt) error->all(FLERR,fmt::format("Too many elements extracted from MEAM " "library (current limit: {}). Increase " "'maxelt' in meam.h and recompile.", maxelt)); - for (int i = 0; i < nelements; i++) { - elements.push_back(arg[i+3]); + for (int i = 0; i < nlibelements; i++) { + libelements.push_back(arg[i+3]); mass.push_back(0.0); } @@ -269,12 +268,12 @@ void PairMEAMC::coeff(int narg, char **arg) // read args that map atom types to MEAM elements // map[i] = which element the Ith atom type is, -1 if not mapped - for (int i = 4 + nelements; i < narg; i++) { - m = i - (4+nelements) + 1; + for (int i = 4 + nlibelements; i < narg; i++) { + m = i - (4+nlibelements) + 1; int j; - for (j = 0; j < nelements; j++) - if (elements[j] == arg[i]) break; - if (j < nelements) map[m] = j; + for (j = 0; j < nlibelements; j++) + if (libelements[j] == arg[i]) break; + if (j < nlibelements) map[m] = j; else if (strcmp(arg[i],"NULL") == 0) map[m] = -1; else error->all(FLERR,"Incorrect args for pair coefficients"); } @@ -359,25 +358,25 @@ void PairMEAMC::read_files(const std::string &globalfile, void PairMEAMC::read_global_meamc_file(const std::string &globalfile) { // allocate parameter arrays - std::vector lat(nelements); - std::vector ielement(nelements); - std::vector ibar(nelements); - std::vector z(nelements); - std::vector atwt(nelements); - std::vector alpha(nelements); - std::vector b0(nelements); - std::vector b1(nelements); - std::vector b2(nelements); - std::vector b3(nelements); - std::vector alat(nelements); - std::vector esub(nelements); - std::vector asub(nelements); - std::vector t0(nelements); - std::vector t1(nelements); - std::vector t2(nelements); - std::vector t3(nelements); - std::vector rozero(nelements); - std::vector found(nelements, false); + std::vector lat(nlibelements); + std::vector ielement(nlibelements); + std::vector ibar(nlibelements); + std::vector z(nlibelements); + std::vector atwt(nlibelements); + std::vector alpha(nlibelements); + std::vector b0(nlibelements); + std::vector b1(nlibelements); + std::vector b2(nlibelements); + std::vector b3(nlibelements); + std::vector alat(nlibelements); + std::vector esub(nlibelements); + std::vector asub(nlibelements); + std::vector t0(nlibelements); + std::vector t1(nlibelements); + std::vector t2(nlibelements); + std::vector t3(nlibelements); + std::vector rozero(nlibelements); + std::vector found(nlibelements, false); // open global meamf file on proc 0 @@ -401,9 +400,9 @@ void PairMEAMC::read_global_meamc_file(const std::string &globalfile) // skip if element name isn't in element list int index; - for (index = 0; index < nelements; index++) - if (elements[index] == element) break; - if (index == nelements) continue; + for (index = 0; index < nlibelements; index++) + if (libelements[index] == element) break; + if (index == nlibelements) continue; // skip if element already appeared (technically error in library file, but always ignored) @@ -452,47 +451,47 @@ void PairMEAMC::read_global_meamc_file(const std::string &globalfile) // error if didn't find all elements in file - if (nset != nelements) { + if (nset != nlibelements) { std::string msg = "Did not find all elements in MEAM library file, missing:"; - for (int i = 0; i < nelements; i++) + for (int i = 0; i < nlibelements; i++) if (!found[i]) { msg += " "; - msg += elements[i]; + msg += libelements[i]; } error->one(FLERR,msg); } } // distribute complete parameter sets - MPI_Bcast(lat.data(), nelements, MPI_INT, 0, world); - MPI_Bcast(ielement.data(), nelements, MPI_INT, 0, world); - MPI_Bcast(ibar.data(), nelements, MPI_INT, 0, world); - MPI_Bcast(z.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(atwt.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(alpha.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(b0.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(b1.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(b2.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(b3.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(alat.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(esub.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(asub.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(t0.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(t1.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(t2.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(t3.data(), nelements, MPI_DOUBLE, 0, world); - MPI_Bcast(rozero.data(), nelements, MPI_DOUBLE, 0, world); + MPI_Bcast(lat.data(), nlibelements, MPI_INT, 0, world); + MPI_Bcast(ielement.data(), nlibelements, MPI_INT, 0, world); + MPI_Bcast(ibar.data(), nlibelements, MPI_INT, 0, world); + MPI_Bcast(z.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(atwt.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(alpha.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(b0.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(b1.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(b2.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(b3.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(alat.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(esub.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(asub.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(t0.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(t1.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(t2.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(t3.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(rozero.data(), nlibelements, MPI_DOUBLE, 0, world); // pass element parameters to MEAM package - meam_inst->meam_setup_global(nelements, lat.data(), ielement.data(), atwt.data(), + meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), t2.data(), t3.data(), rozero.data(), ibar.data()); // set element masses - for (int i = 0; i < nelements; i++) mass[i] = atwt[i]; + for (int i = 0; i < nlibelements; i++) mass[i] = atwt[i]; } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-MEAMC/pair_meamc.h b/src/USER-MEAMC/pair_meamc.h index 6bf6923869..24625c4076 100644 --- a/src/USER-MEAMC/pair_meamc.h +++ b/src/USER-MEAMC/pair_meamc.h @@ -47,12 +47,11 @@ class PairMEAMC : public Pair { private: class MEAM *meam_inst; - double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - std::vector elements; // names of unique elements - std::vector mass; // mass of each element + double cutmax; // max cutoff for all elements + int nlibelements; // # of library elements + std::vector libelements; // names of library elements + std::vector mass; // mass of library element - int *map; // mapping from atom types (1-indexed) to elements (1-indexed) double **scale; // scaling factor for adapt void allocate(); diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index 7481ca35d4..7acaf90e4f 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -67,12 +67,7 @@ PairAGNI::PairAGNI(LAMMPS *lmp) : Pair(lmp) no_virial_fdotr_compute = 1; - nelements = 0; - elements = nullptr; - elem2param = nullptr; - nparams = 0; params = nullptr; - map = nullptr; cutmax = 0.0; } @@ -82,9 +77,6 @@ PairAGNI::PairAGNI(LAMMPS *lmp) : Pair(lmp) PairAGNI::~PairAGNI() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; if (params) { for (int i = 0; i < nparams; ++i) { memory->destroy(params[i].eta); @@ -94,12 +86,11 @@ PairAGNI::~PairAGNI() memory->destroy(params); params = nullptr; } - memory->destroy(elem2param); + memory->destroy(elem1param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; } } @@ -135,7 +126,7 @@ void PairAGNI::compute(int eflag, int vflag) ztmp = x[i][2]; fxtmp = fytmp = fztmp = 0.0; - const Param &iparam = params[elem2param[itype]]; + const Param &iparam = params[elem1param[itype]]; Vx = new double[iparam.numeta]; Vy = new double[iparam.numeta]; Vz = new double[iparam.numeta]; @@ -238,46 +229,10 @@ void PairAGNI::settings(int narg, char ** /* arg */) void PairAGNI::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); + map_element2type(narg-3,arg+3); - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } if (nelements != 1) error->all(FLERR,"Cannot handle multi-element systems with this potential"); @@ -285,25 +240,6 @@ void PairAGNI::coeff(int narg, char **arg) read_file(arg[2]); setup_params(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -466,10 +402,10 @@ void PairAGNI::setup_params() int i,m,n; double rtmp; - // set elem2param for all elements + // set elem1param for all elements - memory->destroy(elem2param); - memory->create(elem2param,nelements,"pair:elem2param"); + memory->destroy(elem1param); + memory->create(elem1param,nelements,"pair:elem1param"); for (i = 0; i < nelements; i++) { n = -1; @@ -480,7 +416,7 @@ void PairAGNI::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i] = n; + elem1param[i] = n; } // compute parameter values derived from inputs diff --git a/src/USER-MISC/pair_agni.h b/src/USER-MISC/pair_agni.h index 6fba506d04..0a33c11b95 100644 --- a/src/USER-MISC/pair_agni.h +++ b/src/USER-MISC/pair_agni.h @@ -45,11 +45,6 @@ class PairAGNI : public Pair { protected: double cutmax; // max cutoff for all elements - int nelements; // # of unique atom type labels - char **elements; // names of unique elements - int *elem2param; // mapping from element pairs to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets int atomic_feature_version; // version of fingerprint Param *params; // parameter set for an I-J interaction virtual void allocate(); diff --git a/src/USER-MISC/pair_drip.cpp b/src/USER-MISC/pair_drip.cpp index 45b49ee293..0f571dd41e 100644 --- a/src/USER-MISC/pair_drip.cpp +++ b/src/USER-MISC/pair_drip.cpp @@ -22,17 +22,17 @@ #include "pair_drip.h" -#include - -#include #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "neighbor.h" +#include "memory.h" #include "neigh_list.h" #include "neigh_request.h" -#include "memory.h" -#include "error.h" +#include "neighbor.h" + +#include +#include using namespace LAMMPS_NS; @@ -51,10 +51,6 @@ PairDRIP::PairDRIP(LAMMPS *lmp) : Pair(lmp) params = nullptr; nearest3neigh = nullptr; - elements = nullptr; - elem2param = nullptr; - map = nullptr; - nelements = 0; cutmax = 0.0; } @@ -65,14 +61,8 @@ PairDRIP::~PairDRIP() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; } - if (elements != nullptr) { - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - elements = nullptr; - } memory->destroy(params); memory->destroy(elem2param); memory->destroy(nearest3neigh); @@ -127,64 +117,10 @@ void PairDRIP::settings(int narg, char ** /* arg */) void PairDRIP::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } - + map_element2type(narg-3,arg+3); read_file(arg[2]); - - - // clear setflag since coeff() called once with I,J = * * - n = atom->ntypes; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - setflag[i][j] = 0; - - int count = 0; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } diff --git a/src/USER-MISC/pair_drip.h b/src/USER-MISC/pair_drip.h index 3ea6c735a6..59dac076c8 100644 --- a/src/USER-MISC/pair_drip.h +++ b/src/USER-MISC/pair_drip.h @@ -58,10 +58,6 @@ protected: }; Param *params; // parameter set for I-J interactions int **nearest3neigh; // nearest 3 neighbors of atoms - char **elements; // names of unique elements - int **elem2param; // mapping from element pairs to parameters - int *map; // mapping from atom types to elements - int nelements; // # of unique elements double cutmax; // max cutoff for all species void read_file(char *); diff --git a/src/USER-MISC/pair_edip.cpp b/src/USER-MISC/pair_edip.cpp index 12390ba69d..88b8728c38 100644 --- a/src/USER-MISC/pair_edip.cpp +++ b/src/USER-MISC/pair_edip.cpp @@ -23,18 +23,18 @@ #include "pair_edip.h" -#include -#include - -#include #include "atom.h" -#include "neighbor.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "memory.h" #include "neigh_list.h" #include "neigh_request.h" -#include "force.h" -#include "comm.h" -#include "memory.h" -#include "error.h" +#include "neighbor.h" + +#include +#include +#include using namespace LAMMPS_NS; @@ -64,11 +64,7 @@ PairEDIP::PairEDIP(LAMMPS *lmp) : manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; } /* ---------------------------------------------------------------------- @@ -77,16 +73,12 @@ PairEDIP::PairEDIP(LAMMPS *lmp) : PairEDIP::~PairEDIP() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; deallocateGrids(); deallocatePreLoops(); @@ -198,7 +190,7 @@ void PairEDIP::compute(int eflag, int vflag) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; r_ij = sqrt(r_ij); @@ -313,7 +305,7 @@ void PairEDIP::compute(int eflag, int vflag) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; r_ij = sqrt(r_ij); @@ -367,7 +359,7 @@ void PairEDIP::compute(int eflag, int vflag) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; dr_ik[0] = x[k][0] - xtmp; dr_ik[1] = x[k][1] - ytmp; @@ -766,47 +758,9 @@ void PairEDIP::initGrids(void) void PairEDIP::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } - + map_element2type(narg-3,arg+3); if (nelements != 1) error->all(FLERR,"Pair style edip only supports single element potentials"); @@ -815,25 +769,6 @@ void PairEDIP::coeff(int narg, char **arg) read_file(arg[2]); setup_params(); - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - // allocate tables and internal structures allocatePreLoops(); @@ -1015,12 +950,12 @@ void PairEDIP::setup_params() int i,j,k,m,n; double rtmp; - // set elem2param for all triplet combinations + // set elem3param for all triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -1034,7 +969,7 @@ void PairEDIP::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // set cutoff square diff --git a/src/USER-MISC/pair_edip.h b/src/USER-MISC/pair_edip.h index 6c4a37d795..006c124229 100644 --- a/src/USER-MISC/pair_edip.h +++ b/src/USER-MISC/pair_edip.h @@ -87,12 +87,6 @@ class PairEDIP : public Pair { double u4; double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction void allocate(); diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index c0969831b9..4db52da11a 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -82,11 +82,7 @@ PairEDIPMulti::PairEDIPMulti(LAMMPS *lmp) : Pair(lmp), preForceCoord(nullptr) manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; } /* ---------------------------------------------------------------------- @@ -95,16 +91,12 @@ PairEDIPMulti::PairEDIPMulti(LAMMPS *lmp) : Pair(lmp), preForceCoord(nullptr) PairEDIPMulti::~PairEDIPMulti() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; } deallocatePreLoops(); } @@ -173,7 +165,7 @@ void PairEDIPMulti::compute(int eflag, int vflag) r_ij = delx * delx + dely * dely + delz * delz; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; r_ij = sqrt(r_ij); @@ -214,7 +206,7 @@ void PairEDIPMulti::compute(int eflag, int vflag) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; r_ij = sqrt(r_ij); @@ -246,8 +238,8 @@ void PairEDIPMulti::compute(int eflag, int vflag) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = x[k][0] - xtmp; dr_ik[1] = x[k][1] - ytmp; @@ -537,71 +529,15 @@ void PairEDIPMulti::settings(int narg, char **/*arg*/) void PairEDIPMulti::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup(); - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - // (re-)allocate tables and internal structures deallocatePreLoops(); @@ -784,12 +720,12 @@ void PairEDIPMulti::setup() int i,j,k,m,n; double rtmp; - // set elem2param for all triplet combinations + // set elem3param for all triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -803,7 +739,7 @@ void PairEDIPMulti::setup() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // set cutoff square diff --git a/src/USER-MISC/pair_edip_multi.h b/src/USER-MISC/pair_edip_multi.h index cf1d56945f..2aba064aa9 100644 --- a/src/USER-MISC/pair_edip_multi.h +++ b/src/USER-MISC/pair_edip_multi.h @@ -54,12 +54,6 @@ class PairEDIPMulti : public Pair { double *preForceCoord; double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction void allocate(); diff --git a/src/USER-MISC/pair_extep.cpp b/src/USER-MISC/pair_extep.cpp index ea4a8031a1..c64c7474cd 100644 --- a/src/USER-MISC/pair_extep.cpp +++ b/src/USER-MISC/pair_extep.cpp @@ -52,18 +52,13 @@ PairExTeP::PairExTeP(LAMMPS *lmp) : Pair(lmp) centroidstressflag = CENTROID_NOTAVAIL; ghostneigh = 1; - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; maxlocal = 0; SR_numneigh = nullptr; SR_firstneigh = nullptr; ipage = nullptr; pgsize = oneatom = 0; - map = nullptr; Nt = nullptr; Nd = nullptr; @@ -75,11 +70,8 @@ PairExTeP::PairExTeP(LAMMPS *lmp) : Pair(lmp) PairExTeP::~PairExTeP() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); memory->destroy(SR_numneigh); memory->sfree(SR_firstneigh); @@ -91,7 +83,6 @@ PairExTeP::~PairExTeP() memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(cutghost); - delete [] map; } } @@ -159,7 +150,7 @@ void PairExTeP::SR_neigh() rsq = delx*delx + dely*dely + delz*delz; jtype=map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq < params[iparam_ij].cutsq) { neighptr[n++] = j; @@ -246,7 +237,7 @@ void PairExTeP::compute(int eflag, int vflag) delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq > params[iparam_ij].cutsq) continue; repulsive(¶ms[iparam_ij],rsq,fpair,eflag,evdwl); @@ -270,7 +261,7 @@ void PairExTeP::compute(int eflag, int vflag) j &= NEIGHMASK; jtag = tag[j]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; delr1[0] = x[j][0] - xtmp; delr1[1] = x[j][1] - ytmp; @@ -337,7 +328,7 @@ void PairExTeP::compute(int eflag, int vflag) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -352,7 +343,7 @@ void PairExTeP::compute(int eflag, int vflag) /* F_IJ (2) */ // compute force components due to spline derivatives // uses only the part with FXY_x (FXY_y is done when i and j are inversed) - int iparam_ik = elem2param[itype][ktype][0]; + int iparam_ik = elem3param[itype][ktype][0]; double fc_ik_d = ters_fc_d(r2,¶ms[iparam_ik]); double fc_prefac_ik_0 = 1.0 * fc_ik_d * fa / r2; double fc_prefac_ik = dFc_dNtij * fc_prefac_ik_0; @@ -396,7 +387,7 @@ void PairExTeP::compute(int eflag, int vflag) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -455,71 +446,15 @@ void PairExTeP::settings(int narg, char **/*arg*/) void PairExTeP::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); spline_init(); setup(); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -818,12 +753,12 @@ void PairExTeP::setup() { int i,j,k,m,n; - // set elem2param for all element triplet combinations + // set elem3param for all element triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -837,7 +772,7 @@ void PairExTeP::setup() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // compute parameter values derived from inputs diff --git a/src/USER-MISC/pair_extep.h b/src/USER-MISC/pair_extep.h index 599147c46e..08ee6d9a82 100644 --- a/src/USER-MISC/pair_extep.h +++ b/src/USER-MISC/pair_extep.h @@ -48,30 +48,24 @@ class PairExTeP : public Pair { double c1,c2,c3,c4; int ielement,jelement,kelement; int powermint; - double Z_i,Z_j; // added for ExTePZBL + double Z_i,Z_j; // added for ExTePZBL double ZBLcut,ZBLexpscale; - double c5,ca1,ca4; // added for ExTePMOD + double c5,ca1,ca4; // added for ExTePMOD double powern_del; }; Param *params; // parameter set for an I-J-K interaction - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets - int maxlocal; // size of numneigh, firstneigh arrays - int maxpage; // # of pages currently allocated - int pgsize; // size of neighbor page - int oneatom; // max # of neighbors for one atom - MyPage *ipage; // neighbor list pages - int *SR_numneigh; // # of pair neighbors for each atom - int **SR_firstneigh; // ptr to 1st neighbor of each atom + int maxlocal; // size of numneigh, firstneigh arrays + int maxpage; // # of pages currently allocated + int pgsize; // size of neighbor page + int oneatom; // max # of neighbors for one atom + MyPage *ipage; // neighbor list pages + int *SR_numneigh; // # of pair neighbors for each atom + int **SR_firstneigh; // ptr to 1st neighbor of each atom - double *Nt, *Nd; // sum of cutoff fns ( f_C ) with SR neighs + double *Nt, *Nd; // sum of cutoff fns ( f_C ) with SR neighs void allocate(); void spline_init(); diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.cpp b/src/USER-MISC/pair_ilp_graphene_hbn.cpp index 982e67d4c1..2870d175c4 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.cpp +++ b/src/USER-MISC/pair_ilp_graphene_hbn.cpp @@ -22,20 +22,19 @@ #include "pair_ilp_graphene_hbn.h" -#include - -#include #include "atom.h" +#include "citeme.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "neighbor.h" +#include "memory.h" +#include "my_page.h" #include "neigh_list.h" #include "neigh_request.h" -#include "my_page.h" -#include "memory.h" -#include "error.h" -#include "citeme.h" +#include "neighbor.h" +#include +#include using namespace LAMMPS_NS; @@ -66,13 +65,8 @@ PairILPGrapheneHBN::PairILPGrapheneHBN(LAMMPS *lmp) : Pair(lmp) pvector = new double[nextra]; // initialize element to parameter maps - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; cutILPsq = nullptr; - map = nullptr; nmax = 0; maxlocal = 0; @@ -110,13 +104,8 @@ PairILPGrapheneHBN::~PairILPGrapheneHBN() memory->destroy(offset); } - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - memory->destroy(params); memory->destroy(elem2param); memory->destroy(cutILPsq); - if (allocated) delete [] map; } /* ---------------------------------------------------------------------- @@ -168,68 +157,10 @@ void PairILPGrapheneHBN::settings(int narg, char **arg) void PairILPGrapheneHBN::coeff(int narg, char **arg) { - int i,j,n; - - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); if (!allocated) allocate(); - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } - - + map_element2type(narg-3,arg+3); read_file(arg[2]); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - cut[i][j] = cut_global; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.h b/src/USER-MISC/pair_ilp_graphene_hbn.h index aadb792cad..4f5e187782 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.h +++ b/src/USER-MISC/pair_ilp_graphene_hbn.h @@ -56,12 +56,6 @@ class PairILPGrapheneHBN : public Pair { int ielement,jelement; }; Param *params; // parameter set for I-J interactions - char **elements; // names of unique elements - int **elem2param; // mapping from element pairs to parameters - int *map; // mapping from atom types to elements - int nelements; // # of unique elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets int nmax; // max # of atoms double cut_global; diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp index c5fa33bbac..45ad36dd7c 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp @@ -21,21 +21,20 @@ ------------------------------------------------------------------------- */ #include "pair_kolmogorov_crespi_full.h" -#include - -#include #include "atom.h" +#include "citeme.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "neighbor.h" +#include "memory.h" +#include "my_page.h" #include "neigh_list.h" #include "neigh_request.h" -#include "my_page.h" -#include "memory.h" -#include "error.h" -#include "citeme.h" +#include "neighbor.h" +#include +#include using namespace LAMMPS_NS; @@ -66,13 +65,8 @@ PairKolmogorovCrespiFull::PairKolmogorovCrespiFull(LAMMPS *lmp) : Pair(lmp) pvector = new double[nextra]; // initialize element to parameter maps - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; cutKCsq = nullptr; - map = nullptr; nmax = 0; maxlocal = 0; @@ -111,13 +105,9 @@ PairKolmogorovCrespiFull::~PairKolmogorovCrespiFull() memory->destroy(offset); } - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); memory->destroy(elem2param); memory->destroy(cutKCsq); - if (allocated) delete [] map; } /* ---------------------------------------------------------------------- @@ -169,68 +159,9 @@ void PairKolmogorovCrespiFull::settings(int narg, char **arg) void PairKolmogorovCrespiFull::coeff(int narg, char **arg) { - int i,j,n; - - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); if (!allocated) allocate(); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } - - + map_element2type(narg-3,arg+3); read_file(arg[2]); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - cut[i][j] = cut_global; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.h b/src/USER-MISC/pair_kolmogorov_crespi_full.h index f7d9237be4..dd2721d37e 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.h +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.h @@ -57,12 +57,6 @@ class PairKolmogorovCrespiFull : public Pair { int ielement,jelement; }; Param *params; // parameter set for I-J interactions - char **elements; // names of unique elements - int **elem2param; // mapping from element pairs to parameters - int *map; // mapping from atom types to elements - int nelements; // # of unique elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets int nmax; // max # of atoms double cut_global; diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp index 1bea688be5..4b5de2314e 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp @@ -23,16 +23,15 @@ #include "pair_kolmogorov_crespi_z.h" -#include - -#include #include "atom.h" #include "comm.h" -#include "force.h" -#include "neigh_list.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" +#include +#include using namespace LAMMPS_NS; @@ -69,12 +68,8 @@ PairKolmogorovCrespiZ::~PairKolmogorovCrespiZ() memory->destroy(offset); } - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); memory->destroy(elem2param); - if (allocated) delete [] map; } /* ---------------------------------------------------------------------- */ @@ -221,45 +216,13 @@ void PairKolmogorovCrespiZ::settings(int narg, char **arg) void PairKolmogorovCrespiZ::coeff(int narg, char **arg) { - int i,j,n; - - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); if (!allocated) allocate(); int ilo,ihi,jlo,jhi; utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error); utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } - + map_element2type(narg-3,arg+3,false); read_file(arg[2]); // set setflag only for i,j pairs where both are mapped to elements diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.h b/src/USER-MISC/pair_kolmogorov_crespi_z.h index 1a90fdfa0b..7d242d67fd 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.h +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.h @@ -43,12 +43,6 @@ class PairKolmogorovCrespiZ : public Pair { int ielement,jelement; }; Param *params; // parameter set for I-J interactions - char **elements; // names of unique elements - int **elem2param; // mapping from element pairs to parameters - int *map; // mapping from atom types to elements - int nelements; // # of unique elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets double cut_global; double **cut; diff --git a/src/USER-MISC/pair_lebedeva_z.cpp b/src/USER-MISC/pair_lebedeva_z.cpp index a600f5b761..afd7209c6b 100644 --- a/src/USER-MISC/pair_lebedeva_z.cpp +++ b/src/USER-MISC/pair_lebedeva_z.cpp @@ -24,16 +24,15 @@ #include "pair_lebedeva_z.h" -#include - -#include #include "atom.h" #include "comm.h" -#include "force.h" -#include "neigh_list.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" +#include +#include using namespace LAMMPS_NS; @@ -48,12 +47,7 @@ PairLebedevaZ::PairLebedevaZ(LAMMPS *lmp) : Pair(lmp) restartinfo = 0; // initialize element to parameter maps - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; - map = nullptr; // always compute energy offset offset_flag = 1; @@ -70,12 +64,8 @@ PairLebedevaZ::~PairLebedevaZ() memory->destroy(offset); } - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); memory->destroy(elem2param); - if (allocated) delete [] map; } /* ---------------------------------------------------------------------- */ @@ -217,45 +207,13 @@ void PairLebedevaZ::settings(int narg, char **arg) void PairLebedevaZ::coeff(int narg, char **arg) { - int i,j,n; - - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); if (!allocated) allocate(); int ilo,ihi,jlo,jhi; utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error); utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } - + map_element2type(narg-3,arg+3,false); read_file(arg[2]); // set setflag only for i,j pairs where both are mapped to elements diff --git a/src/USER-MISC/pair_lebedeva_z.h b/src/USER-MISC/pair_lebedeva_z.h index e221087a0a..57cf445889 100644 --- a/src/USER-MISC/pair_lebedeva_z.h +++ b/src/USER-MISC/pair_lebedeva_z.h @@ -43,12 +43,6 @@ class PairLebedevaZ : public Pair { int ielement,jelement; }; Param *params; // parameter set for I-J interactions - char **elements; // names of unique elements - int **elem2param; // mapping from element pairs to parameters - int *map; // mapping from atom types to elements - int nelements; // # of unique elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets double cut_global; double **cut; diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index a6bf602c70..e956d96cf2 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -32,18 +32,18 @@ ------------------------------------------------------------------------- */ #include "pair_meam_spline.h" -#include -#include #include "atom.h" -#include "force.h" #include "comm.h" -#include "neighbor.h" +#include "error.h" +#include "force.h" +#include "memory.h" #include "neigh_list.h" #include "neigh_request.h" -#include "memory.h" -#include "error.h" +#include "neighbor.h" +#include +#include using namespace LAMMPS_NS; @@ -55,10 +55,6 @@ PairMEAMSpline::PairMEAMSpline(LAMMPS *lmp) : Pair(lmp) restartinfo = 0; one_coeff = 1; - nelements = 0; - elements = nullptr; - map = nullptr; - Uprime_values = nullptr; nmax = 0; maxNeighbors = 0; @@ -80,10 +76,6 @@ PairMEAMSpline::PairMEAMSpline(LAMMPS *lmp) : Pair(lmp) PairMEAMSpline::~PairMEAMSpline() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - delete[] twoBodyInfo; memory->destroy(Uprime_values); @@ -98,8 +90,6 @@ PairMEAMSpline::~PairMEAMSpline() delete[] gs; delete[] zero_atom_energies; - - delete [] map; } } @@ -389,11 +379,6 @@ void PairMEAMSpline::coeff(int narg, char **arg) if (narg != 3 + atom->ntypes) error->all(FLERR,"Incorrect args for pair coefficients"); - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - // read potential file: also sets the number of elements. read_file(arg[2]); diff --git a/src/USER-MISC/pair_meam_spline.h b/src/USER-MISC/pair_meam_spline.h index d1dc5064f5..b20454f18d 100644 --- a/src/USER-MISC/pair_meam_spline.h +++ b/src/USER-MISC/pair_meam_spline.h @@ -67,10 +67,6 @@ public: double memory_usage(); protected: - char **elements; // names of unique elements - int *map; // mapping from atom types to elements - int nelements; // # of unique elements - class SplineFunction { public: /// Default constructor. diff --git a/src/USER-MISC/pair_meam_sw_spline.cpp b/src/USER-MISC/pair_meam_sw_spline.cpp index 58c0f75546..ff7b89fbe7 100644 --- a/src/USER-MISC/pair_meam_sw_spline.cpp +++ b/src/USER-MISC/pair_meam_sw_spline.cpp @@ -24,18 +24,18 @@ ------------------------------------------------------------------------- */ #include "pair_meam_sw_spline.h" -#include -#include #include "atom.h" -#include "force.h" #include "comm.h" -#include "neighbor.h" +#include "error.h" +#include "force.h" +#include "memory.h" #include "neigh_list.h" #include "neigh_request.h" -#include "memory.h" -#include "error.h" +#include "neighbor.h" +#include +#include using namespace LAMMPS_NS; @@ -49,9 +49,6 @@ PairMEAMSWSpline::PairMEAMSWSpline(LAMMPS *lmp) : Pair(lmp) manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; - nelements = 0; - elements = nullptr; - Uprime_values = nullptr; //ESWprime_values = nullptr; nmax = 0; @@ -66,10 +63,6 @@ PairMEAMSWSpline::PairMEAMSWSpline(LAMMPS *lmp) : Pair(lmp) PairMEAMSWSpline::~PairMEAMSWSpline() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - delete[] twoBodyInfo; memory->destroy(Uprime_values); //memory->destroy(ESWprime_values); @@ -77,7 +70,6 @@ PairMEAMSWSpline::~PairMEAMSWSpline() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; } } @@ -381,46 +373,9 @@ void PairMEAMSWSpline::settings(int narg, char **/*arg*/) void PairMEAMSWSpline::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // for now, only allow single element @@ -431,25 +386,6 @@ void PairMEAMSWSpline::coeff(int narg, char **arg) // read potential file read_file(arg[2]); - - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- diff --git a/src/USER-MISC/pair_meam_sw_spline.h b/src/USER-MISC/pair_meam_sw_spline.h index 7b40d123ed..ecf56c7931 100644 --- a/src/USER-MISC/pair_meam_sw_spline.h +++ b/src/USER-MISC/pair_meam_sw_spline.h @@ -54,9 +54,6 @@ public: double memory_usage(); protected: - char **elements; // names of unique elements - int *map; // mapping from atom types to elements - int nelements; // # of unique elements class SplineFunction { public: diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index 0d5bbc1147..ed05961fa7 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -22,21 +22,19 @@ #include "pair_tersoff_table.h" -#include - -#include #include "atom.h" -#include "neighbor.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "memory.h" #include "neigh_list.h" #include "neigh_request.h" -#include "force.h" -#include "comm.h" -#include "memory.h" - -#include "tokenizer.h" +#include "neighbor.h" #include "potential_file_reader.h" +#include "tokenizer.h" -#include "error.h" +#include +#include using namespace LAMMPS_NS; @@ -64,11 +62,7 @@ PairTersoffTable::PairTersoffTable(LAMMPS *lmp) : Pair(lmp) centroidstressflag = CENTROID_NOTAVAIL; unit_convert_flag = utils::get_supported_conversions(utils::ENERGY); - nelements = 0; - elements = nullptr; - nparams = maxparam = 0; params = nullptr; - elem2param = nullptr; allocated = 0; preGtetaFunction = preGtetaFunctionDerived = nullptr; @@ -88,17 +82,12 @@ PairTersoffTable::PairTersoffTable(LAMMPS *lmp) : Pair(lmp) PairTersoffTable::~PairTersoffTable() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; memory->destroy(params); - memory->destroy(elem2param); + memory->destroy(elem3param); if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; - } deallocateGrids(); deallocatePreLoops(); @@ -177,7 +166,7 @@ void PairTersoffTable::compute(int eflag, int vflag) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; @@ -208,8 +197,8 @@ void PairTersoffTable::compute(int eflag, int vflag) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -264,7 +253,7 @@ void PairTersoffTable::compute(int eflag, int vflag) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; @@ -308,8 +297,8 @@ void PairTersoffTable::compute(int eflag, int vflag) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -333,8 +322,8 @@ void PairTersoffTable::compute(int eflag, int vflag) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -392,8 +381,8 @@ void PairTersoffTable::compute(int eflag, int vflag) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -457,8 +446,8 @@ void PairTersoffTable::compute(int eflag, int vflag) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -608,7 +597,7 @@ void PairTersoffTable::allocateGrids(void) r = -1.0; deltaArgumentGtetaFunction = 1.0 / GRIDDENSITY_GTETA; - int iparam = elem2param[i][i][i]; + int iparam = elem3param[i][i][i]; double c = params[iparam].c; double d = params[iparam].d; double h = params[iparam].h; @@ -628,7 +617,7 @@ void PairTersoffTable::allocateGrids(void) for (i=0; intypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - // clear setflag since coeff() called once with I,J = * * - - n = atom->ntypes; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - // allocate tables and internal structures + allocatePreLoops(); allocateGrids(); } @@ -966,12 +900,12 @@ void PairTersoffTable::setup_params() { int i,j,k,m,n; - // set elem2param for all triplet combinations + // set elem3param for all triplet combinations // must be a single exact match to lines read from file // do not allow for ACB in place of ABC - memory->destroy(elem2param); - memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param"); + memory->destroy(elem3param); + memory->create(elem3param,nelements,nelements,nelements,"pair:elem3param"); for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) @@ -985,7 +919,7 @@ void PairTersoffTable::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + elem3param[i][j][k] = n; } // set cutoff square diff --git a/src/USER-MISC/pair_tersoff_table.h b/src/USER-MISC/pair_tersoff_table.h index d63a5be5a6..84e6f6fe50 100644 --- a/src/USER-MISC/pair_tersoff_table.h +++ b/src/USER-MISC/pair_tersoff_table.h @@ -59,12 +59,6 @@ class PairTersoffTable : public Pair { double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction void allocate(); diff --git a/src/USER-OMP/pair_agni_omp.cpp b/src/USER-OMP/pair_agni_omp.cpp index 02a6126e03..258c833cdf 100644 --- a/src/USER-OMP/pair_agni_omp.cpp +++ b/src/USER-OMP/pair_agni_omp.cpp @@ -101,7 +101,7 @@ void PairAGNIOMP::eval(int iifrom, int iito, ThrData * const thr) ztmp = x[i].z; fxtmp = fytmp = fztmp = 0.0; - const Param &iparam = params[elem2param[itype]]; + const Param &iparam = params[elem1param[itype]]; Vx = new double[iparam.numeta]; Vy = new double[iparam.numeta]; Vz = new double[iparam.numeta]; diff --git a/src/USER-OMP/pair_comb_omp.cpp b/src/USER-OMP/pair_comb_omp.cpp index cfde8ff905..52c8855738 100644 --- a/src/USER-OMP/pair_comb_omp.cpp +++ b/src/USER-OMP/pair_comb_omp.cpp @@ -139,7 +139,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) iq = q[i]; NCo[i] = 0; nj = 0; - iparam_i = elem2param[itype][itype][itype]; + iparam_i = elem3param[itype][itype][itype]; // self energy, only on i atom @@ -180,7 +180,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; // long range q-dependent @@ -242,7 +242,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) for (jj = 0; jj < sht_jnum; jj++) { j = sht_jlist[jj]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (params[iparam_ij].hfocor > 0.0) { delr1[0] = x[j][0] - xtmp; @@ -264,7 +264,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) j = sht_jlist[jj]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; // this Qj for q-dependent BSi @@ -288,7 +288,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) k = sht_jlist[kk]; if (j == k) continue; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -332,7 +332,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr) k = sht_jlist[kk]; if (j == k) continue; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k][0] - xtmp; delr2[1] = x[k][1] - ytmp; @@ -434,7 +434,7 @@ double PairCombOMP::yasu_char(double *qf_fix, int &igroup) const double ytmp = x[i][1]; const double ztmp = x[i][2]; const double iq = q[i]; - const int iparam_i = elem2param[itype][itype][itype]; + const int iparam_i = elem3param[itype][itype][itype]; // charge force from self energy @@ -467,7 +467,7 @@ double PairCombOMP::yasu_char(double *qf_fix, int &igroup) delr1[2] = x[j][2] - ztmp; double rsq1 = dot3(delr1,delr1); - const int iparam_ij = elem2param[itype][jtype][jtype]; + const int iparam_ij = elem3param[itype][jtype][jtype]; // long range q-dependent @@ -505,7 +505,7 @@ double PairCombOMP::yasu_char(double *qf_fix, int &igroup) delr1[2] = x[j][2] - ztmp; double rsq1 = dot3(delr1,delr1); - const int iparam_ij = elem2param[itype][jtype][jtype]; + const int iparam_ij = elem3param[itype][jtype][jtype]; if (rsq1 > params[iparam_ij].cutsq) continue; nj ++; diff --git a/src/USER-OMP/pair_edip_omp.cpp b/src/USER-OMP/pair_edip_omp.cpp index 106d038743..b2e8708305 100644 --- a/src/USER-OMP/pair_edip_omp.cpp +++ b/src/USER-OMP/pair_edip_omp.cpp @@ -184,7 +184,7 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; r_ij = sqrt(r_ij); @@ -299,7 +299,7 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; r_ij = sqrt(r_ij); @@ -353,7 +353,7 @@ void PairEDIPOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; dr_ik[0] = x[k].x - xtmp; dr_ik[1] = x[k].y - ytmp; diff --git a/src/USER-OMP/pair_sw_omp.cpp b/src/USER-OMP/pair_sw_omp.cpp index 92d0d0c15a..28e450f517 100644 --- a/src/USER-OMP/pair_sw_omp.cpp +++ b/src/USER-OMP/pair_sw_omp.cpp @@ -121,7 +121,7 @@ void PairSWOMP::eval(int iifrom, int iito, ThrData * const thr) rsq = delx*delx + dely*dely + delz*delz; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (rsq >= params[ijparam].cutsq) { continue; } else { @@ -161,7 +161,7 @@ void PairSWOMP::eval(int iifrom, int iito, ThrData * const thr) for (jj = 0; jj < jnumm1; jj++) { j = neighshort_thr[jj]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; delr1[0] = x[j].x - xtmp; delr1[1] = x[j].y - ytmp; delr1[2] = x[j].z - ztmp; @@ -173,8 +173,8 @@ void PairSWOMP::eval(int iifrom, int iito, ThrData * const thr) for (kk = jj+1; kk < numshort; kk++) { k = neighshort_thr[kk]; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; diff --git a/src/USER-OMP/pair_tersoff_mod_c_omp.cpp b/src/USER-OMP/pair_tersoff_mod_c_omp.cpp index c6947bbde7..8f255ee1ba 100644 --- a/src/USER-OMP/pair_tersoff_mod_c_omp.cpp +++ b/src/USER-OMP/pair_tersoff_mod_c_omp.cpp @@ -157,7 +157,7 @@ void PairTersoffMODCOMP::eval(int iifrom, int iito, ThrData * const thr) rsq = rsqtmp; } - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq > params[iparam_ij].cutsq) continue; repulsive(¶ms[iparam_ij],rsq,fpair,EFLAG,evdwl); @@ -185,7 +185,7 @@ void PairTersoffMODCOMP::eval(int iifrom, int iito, ThrData * const thr) j = jlist[jj]; j &= NEIGHMASK; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; delr1[0] = x[j].x - xtmp; delr1[1] = x[j].y - ytmp; @@ -210,7 +210,7 @@ void PairTersoffMODCOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; @@ -251,7 +251,7 @@ void PairTersoffMODCOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; diff --git a/src/USER-OMP/pair_tersoff_mod_omp.cpp b/src/USER-OMP/pair_tersoff_mod_omp.cpp index e689803c38..454a387982 100644 --- a/src/USER-OMP/pair_tersoff_mod_omp.cpp +++ b/src/USER-OMP/pair_tersoff_mod_omp.cpp @@ -159,7 +159,7 @@ void PairTersoffMODOMP::eval(int iifrom, int iito, ThrData * const thr) rsq = rsqtmp; } - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq > params[iparam_ij].cutsq) continue; repulsive(¶ms[iparam_ij],rsq,fpair,EFLAG,evdwl); @@ -187,7 +187,7 @@ void PairTersoffMODOMP::eval(int iifrom, int iito, ThrData * const thr) j = jlist[jj]; j &= NEIGHMASK; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; delr1[0] = x[j].x - xtmp; delr1[1] = x[j].y - ytmp; @@ -212,7 +212,7 @@ void PairTersoffMODOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; @@ -253,7 +253,7 @@ void PairTersoffMODOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[kk]; k &= NEIGHMASK; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; diff --git a/src/USER-OMP/pair_tersoff_omp.cpp b/src/USER-OMP/pair_tersoff_omp.cpp index 7fb3c70d78..c12e3b9859 100644 --- a/src/USER-OMP/pair_tersoff_omp.cpp +++ b/src/USER-OMP/pair_tersoff_omp.cpp @@ -173,7 +173,7 @@ void PairTersoffOMP::eval(int iifrom, int iito, ThrData * const thr) } jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; if (rsq >= params[iparam_ij].cutsq) continue; repulsive(¶ms[iparam_ij],rsq,fpair,EFLAG,evdwl); @@ -200,7 +200,7 @@ void PairTersoffOMP::eval(int iifrom, int iito, ThrData * const thr) for (jj = 0; jj < numshort; jj++) { j = neighshort_thr[jj]; jtype = map[type[j]]; - iparam_ij = elem2param[itype][jtype][jtype]; + iparam_ij = elem3param[itype][jtype][jtype]; delr1[0] = x[j].x - xtmp; delr1[1] = x[j].y - ytmp; @@ -224,7 +224,7 @@ void PairTersoffOMP::eval(int iifrom, int iito, ThrData * const thr) if (jj == kk) continue; k = neighshort_thr[kk]; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; @@ -264,7 +264,7 @@ void PairTersoffOMP::eval(int iifrom, int iito, ThrData * const thr) if (jj == kk) continue; k = neighshort_thr[kk]; ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ijk = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; diff --git a/src/USER-OMP/pair_tersoff_table_omp.cpp b/src/USER-OMP/pair_tersoff_table_omp.cpp index 2e52492491..02752c8577 100644 --- a/src/USER-OMP/pair_tersoff_table_omp.cpp +++ b/src/USER-OMP/pair_tersoff_table_omp.cpp @@ -154,7 +154,7 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; @@ -185,8 +185,8 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k].x; dr_ik[1] = ytmp -x[k].y; @@ -241,7 +241,7 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) r_ij = dr_ij[0]*dr_ij[0] + dr_ij[1]*dr_ij[1] + dr_ij[2]*dr_ij[2]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (r_ij > params[ijparam].cutsq) continue; @@ -285,8 +285,8 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k].x; dr_ik[1] = ytmp -x[k].y; @@ -310,8 +310,8 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k].x; dr_ik[1] = ytmp -x[k].y; @@ -370,8 +370,8 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k].x; dr_ik[1] = ytmp -x[k].y; @@ -436,8 +436,8 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) k = jlist[neighbor_k]; k &= NEIGHMASK; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k].x; dr_ik[1] = ytmp -x[k].y; diff --git a/src/USER-OMP/pair_vashishta_omp.cpp b/src/USER-OMP/pair_vashishta_omp.cpp index 303de78e37..23d7235578 100644 --- a/src/USER-OMP/pair_vashishta_omp.cpp +++ b/src/USER-OMP/pair_vashishta_omp.cpp @@ -143,7 +143,7 @@ void PairVashishtaOMP::eval(int iifrom, int iito, ThrData * const thr) } jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (rsq >= params[ijparam].cutsq) continue; twobody(¶ms[ijparam],rsq,fpair,EFLAG,evdwl); @@ -164,7 +164,7 @@ void PairVashishtaOMP::eval(int iifrom, int iito, ThrData * const thr) for (jj = 0; jj < jnumm1; jj++) { j = neighshort_thr[jj]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; delr1[0] = x[j].x - xtmp; delr1[1] = x[j].y - ytmp; delr1[2] = x[j].z - ztmp; @@ -177,8 +177,8 @@ void PairVashishtaOMP::eval(int iifrom, int iito, ThrData * const thr) for (kk = jj+1; kk < numshort; kk++) { k = neighshort_thr[kk]; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; diff --git a/src/USER-OMP/pair_vashishta_table_omp.cpp b/src/USER-OMP/pair_vashishta_table_omp.cpp index 50c985ad68..c03d827d9b 100644 --- a/src/USER-OMP/pair_vashishta_table_omp.cpp +++ b/src/USER-OMP/pair_vashishta_table_omp.cpp @@ -141,7 +141,7 @@ void PairVashishtaTableOMP::eval(int iifrom, int iito, ThrData * const thr) } jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; if (rsq >= params[ijparam].cutsq) continue; twobody_table(params[ijparam],rsq,fpair,EFLAG,evdwl); @@ -162,7 +162,7 @@ void PairVashishtaTableOMP::eval(int iifrom, int iito, ThrData * const thr) for (jj = 0; jj < jnumm1; jj++) { j = neighshort_thr[jj]; jtype = map[type[j]]; - ijparam = elem2param[itype][jtype][jtype]; + ijparam = elem3param[itype][jtype][jtype]; delr1[0] = x[j].x - xtmp; delr1[1] = x[j].y - ytmp; delr1[2] = x[j].z - ztmp; @@ -175,8 +175,8 @@ void PairVashishtaTableOMP::eval(int iifrom, int iito, ThrData * const thr) for (kk = jj+1; kk < numshort; kk++) { k = neighshort_thr[kk]; ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; + ikparam = elem3param[itype][ktype][ktype]; + ijkparam = elem3param[itype][jtype][ktype]; delr2[0] = x[k].x - xtmp; delr2[1] = x[k].y - ytmp; diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index fe78fbbb37..4d6f240ec6 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -22,23 +22,23 @@ #include "pair_reaxc.h" -#include - -#include -#include #include "atom.h" -#include "update.h" -#include "force.h" +#include "citeme.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "modify.h" +#include "error.h" #include "fix.h" #include "fix_reaxc.h" -#include "citeme.h" +#include "force.h" #include "memory.h" -#include "error.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "update.h" + +#include +#include +#include // for strcasecmp() #include "reaxc_defs.h" #include "reaxc_types.h" @@ -175,7 +175,6 @@ PairReaxC::~PairReaxC() memory->destroy(setflag); memory->destroy(cutsq); memory->destroy(cutghost); - delete [] map; delete [] chi; delete [] eta; diff --git a/src/USER-REAXC/pair_reaxc.h b/src/USER-REAXC/pair_reaxc.h index a833ddbcf0..53b41ba9c8 100644 --- a/src/USER-REAXC/pair_reaxc.h +++ b/src/USER-REAXC/pair_reaxc.h @@ -62,9 +62,6 @@ class PairReaxC : public Pair { protected: char *fix_id; double cutmax; - int nelements; // # of unique elements - char **elements; // names of unique elements - int *map; class FixReaxC *fix_reax; double *chi,*eta,*gamma; diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index 7ed37fefc4..5a27855a47 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -91,10 +91,6 @@ PairSMTBQ::PairSMTBQ(LAMMPS *lmp) : Pair(lmp) ds = 0.0; kmax = 0; - nelements = 0; - elements = nullptr; - nparams = 0; - maxparam = 0; params = nullptr; intparams = nullptr; @@ -153,8 +149,6 @@ PairSMTBQ::~PairSMTBQ() { int i; if (elements) { - for ( i = 0; i < nelements; i++) delete [] elements[i]; - for (i = 0; i < atom->ntypes ; i++ ) free( params[i].nom); for (i = 1; i <= maxintparam ; i++ ) free( intparams[i].typepot); for (i = 1; i <= maxintparam ; i++ ) free( intparams[i].mode); @@ -166,7 +160,6 @@ PairSMTBQ::~PairSMTBQ() free(writeenerg); free(Bavard); - delete [] elements; memory->sfree(params); memory->sfree(intparams); @@ -216,7 +209,6 @@ PairSMTBQ::~PairSMTBQ() if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); - delete [] map; delete [] esm; } @@ -252,92 +244,30 @@ void PairSMTBQ::settings(int narg, char ** /* arg */) void PairSMTBQ::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (strstr(force->pair_style,"hybrid")) + if (utils::strmatch(force->pair_style,"^hybrid")) error->all(FLERR,"Pair style SMTBQ is not compatible with hybrid styles"); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - n = strlen(arg[i]) + 1; - elements[j] = new char[n]; - strcpy(elements[j],arg[i]); - nelements++; - } - } + map_element2type(narg-3,arg+3); // read potential file and initialize potential parameters read_file(arg[2]); - n = atom->ntypes; - // generate Coulomb 1/r energy look-up table - if (comm->me == 0 && screen) fprintf(screen,"Pair SMTBQ:\n"); if (comm->me == 0 && screen) - fprintf(screen," generating Coulomb integral lookup table ...\n"); + fputs("Pair SMTBQ: generating Coulomb integral lookup table ...\n",screen); tabqeq(); // ------------ - if (comm->me == 0 && screen) - fprintf(screen," generating Second Moment integral lookup table ...\n"); + fputs(" generating Second Moment integral lookup table ...\n",screen); tabsm(); - - // ------------ - - // clear setflag since coeff() called once with I,J = * * - - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- diff --git a/src/USER-SMTBQ/pair_smtbq.h b/src/USER-SMTBQ/pair_smtbq.h index 4681c94895..8bf1cba57c 100644 --- a/src/USER-SMTBQ/pair_smtbq.h +++ b/src/USER-SMTBQ/pair_smtbq.h @@ -60,8 +60,6 @@ protected: int loopmax; // max of iteration double cutmax; // max cutoff for all elements - int nelements; // # of unique elements - char **elements; // names of unique elements char *QEqMode; // name of QEqMode char *Bavard; // Verbose parameter char *writepot; // write or not the electronegativity component @@ -70,11 +68,8 @@ protected: double zlim1QEq; // z limit for QEq equilibration double zlim2QEq; // z limit for QEq equilibration double QOxInit; // Initial charge for oxygen atoms (if the charge is not specified) - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets - int maxintparam; // max # of interaction sets - int maxintsm; // max # of interaction SM + int maxintparam; // max # of interaction sets + int maxintsm; // max # of interaction SM double r1Coord,r2Coord; Param *params; // parameter set for an I atom Intparam *intparams; // parameter set for an I interaction diff --git a/src/input.cpp b/src/input.cpp index 53fcc606db..f96cf8c75c 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1697,6 +1697,9 @@ void Input::pair_coeff() error->all(FLERR,"Pair_coeff command before simulation box is defined"); if (force->pair == nullptr) error->all(FLERR,"Pair_coeff command before pair_style is defined"); + if ((narg < 2) || (force->pair->one_coeff && ((strcmp(arg[0],"*") != 0) + || (strcmp(arg[1],"*") != 0)))) + error->all(FLERR,"Incorrect args for pair coefficients"); force->pair->coeff(narg,arg); } diff --git a/src/pair.cpp b/src/pair.cpp index 27a8831eb1..767fa638cf 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -106,6 +106,13 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp) num_tally_compute = 0; list_tally_compute = nullptr; + nelements = nparams = maxparam = 0; + elements = nullptr; + elem1param = nullptr; + elem2param = nullptr; + elem3param = nullptr; + map = nullptr; + nondefault_history_transfer = 0; beyond_contact = 0; @@ -129,6 +136,11 @@ Pair::~Pair() if (copymode) return; + if (elements) + for (int i = 0; i < nelements; i++) delete[] elements[i]; + delete[] elements; + + delete[] map; memory->destroy(eatom); memory->destroy(vatom); memory->destroy(cvatom); @@ -776,6 +788,68 @@ void Pair::del_tally_callback(Compute *ptr) } } +/* ------------------------------------------------------------------- + build element to atom type mapping for manybody potentials + also clear and reset setflag[][] array and check missing entries +---------------------------------------------------------------------- */ + +void Pair::map_element2type(int narg, char **arg, bool update_setflag) +{ + int i,j; + const int ntypes = atom->ntypes; + + // read args that map atom types to elements in potential file + // map[i] = which element the Ith atom type is, -1 if "NULL" + // nelements = # of unique elements + // elements = list of element names + + if (narg != ntypes) + error->all(FLERR,"Incorrect args for pair coefficients"); + + if (elements) { + for (i = 0; i < nelements; i++) delete[] elements[i]; + delete[] elements; + } + elements = new char*[ntypes]; + for (i = 0; i < ntypes; i++) elements[i] = nullptr; + + nelements = 0; + map[0] = -1; + for (i = 1; i <= narg; i++) { + std::string entry = arg[i-1]; + if (entry == "NULL") { + map[i] = -1; + continue; + } + for (j = 0; j < nelements; j++) + if (entry == elements[j]) break; + map[i] = j; + if (j == nelements) { + elements[j] = utils::strdup(entry); + nelements++; + } + } + + // if requested, clear setflag[i][j] and set it for type pairs + // where both are mapped to elements in map. + + if (update_setflag) { + + int count = 0; + for (i = 1; i <= ntypes; i++) { + for (j = i; j <= ntypes; j++) { + setflag[i][j] = 0; + if ((map[i] >= 0) && (map[j] >= 0)) { + setflag[i][j] = 1; + count++; + } + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + } +} + /* ---------------------------------------------------------------------- setup for energy, virial computation see integrate::ev_set() for bitwise settings of eflag/vflag diff --git a/src/pair.h b/src/pair.h index 9bca64fbf3..b25ad448eb 100644 --- a/src/pair.h +++ b/src/pair.h @@ -216,17 +216,27 @@ class Pair : protected Pointers { virtual void del_tally_callback(class Compute *); protected: - int instance_me; // which Pair class instantiation I am + int instance_me; // which Pair class instantiation I am + int special_lj[4]; // copied from force->special_lj for Kokkos + int suffix_flag; // suffix compatibility flag - int special_lj[4]; // copied from force->special_lj for Kokkos - - int suffix_flag; // suffix compatibility flag - - // pair_modify settings - int offset_flag,mix_flag; // flags for offset and mixing - double tabinner; // inner cutoff for Coulomb table - double tabinner_disp; // inner cutoff for dispersion table + // pair_modify settings + int offset_flag,mix_flag; // flags for offset and mixing + double tabinner; // inner cutoff for Coulomb table + double tabinner_disp; // inner cutoff for dispersion table + protected: + // for mapping of elements to atom types and parameters + // mostly used for manybody potentials + int nelements; // # of unique elements + char **elements; // names of unique elements + int *elem1param; // mapping from elements to parameters + int **elem2param; // mapping from element pairs to parameters + int ***elem3param; // mapping from element triplets to parameters + int *map; // mapping from atom types to elements + int nparams; // # of stored parameter sets + int maxparam; // max # of parameter sets + void map_element2type(int, char**, bool update_setflag=true); public: // custom data type for accessing Coulomb tables diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 68790c0f03..55529f9eae 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -49,13 +49,8 @@ PairCoulStreitz::PairCoulStreitz(LAMMPS *lmp) : Pair(lmp) restartinfo = 0; one_coeff = 1; nmax = 0; - nelements = 0; - elements = nullptr; - nparams = 0; - maxparam = 0; params = nullptr; - elem2param = nullptr; } /* ---------------------------------------------------------------------- @@ -64,12 +59,8 @@ PairCoulStreitz::PairCoulStreitz(LAMMPS *lmp) : Pair(lmp) PairCoulStreitz::~PairCoulStreitz() { - if (elements) - for (int i = 0; i < nelements; i++) delete [] elements[i]; - - delete [] elements; memory->sfree(params); - memory->destroy(elem2param); + memory->destroy(elem1param); if (allocated) { memory->destroy(setflag); @@ -80,7 +71,6 @@ PairCoulStreitz::~PairCoulStreitz() memory->destroy(qeq_g); memory->destroy(qeq_z); memory->destroy(qeq_c); - delete [] map; } } @@ -130,69 +120,19 @@ void PairCoulStreitz::settings(int narg, char **arg) void PairCoulStreitz::coeff(int narg, char **arg) { - int i,j,n; - if (!allocated) allocate(); - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if "NULL" - // nelements = # of unique elements - // elements = list of element names - - if (elements) { - for (i = 0; i < nelements; i++) delete [] elements[i]; - delete [] elements; - } - elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; - - nelements = 0; - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - if (strcmp(arg[i],elements[j]) == 0) break; - map[i-2] = j; - if (j == nelements) { - elements[j] = utils::strdup(arg[i]); - nelements++; - } - } + map_element2type(narg-3, arg+3); // read potential file and initialize potential parameters read_file(arg[2]); setup_params(); - n = atom->ntypes; - - // clear setflag since coeff() called once with I,J = * * + const int n = atom->ntypes; for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - - int count = 0; - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - if (map[i] >= 0 && map[j] >= 0) { + for (int j = 1; j <= n; j++) scale[i][j] = 1.0; - setflag[i][j] = 1; - count++; - } - - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -308,10 +248,10 @@ void PairCoulStreitz::setup_params() { int i,m,n; - // set elem2param + // set elem1param - memory->destroy(elem2param); - memory->create(elem2param,nelements,"pair:elem2param"); + memory->destroy(elem1param); + memory->create(elem1param,nelements,"pair:elem1param"); for (i = 0; i < nelements; i++) { n = -1; @@ -322,7 +262,7 @@ void PairCoulStreitz::setup_params() } } if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i] = n; + elem1param[i] = n; } // Wolf sum self energy @@ -381,7 +321,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) ytmp = x[i][1]; ztmp = x[i][2]; itype = map[type[i]]; - iparam_i = elem2param[itype]; + iparam_i = elem1param[itype]; qi = q[i]; zei = params[iparam_i].zeta; @@ -401,7 +341,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) j &= NEIGHMASK; jtype = map[type[j]]; - iparam_j = elem2param[jtype]; + iparam_j = elem1param[jtype]; qj = q[j]; zej = params[iparam_j].zeta; zj = params[iparam_j].zcore; @@ -454,7 +394,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) ytmp = x[i][1]; ztmp = x[i][2]; itype = map[type[i]]; - iparam_i = elem2param[itype]; + iparam_i = elem1param[itype]; qi = q[i]; zei = params[iparam_i].zeta; @@ -473,7 +413,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) j = jlist[jj]; j &= NEIGHMASK; jtype = map[type[j]]; - iparam_j = elem2param[jtype]; + iparam_j = elem1param[jtype]; qj = q[j]; zej = params[iparam_j].zeta; zj = params[iparam_j].zcore; diff --git a/src/pair_coul_streitz.h b/src/pair_coul_streitz.h index 2f62846212..12da6afcfe 100644 --- a/src/pair_coul_streitz.h +++ b/src/pair_coul_streitz.h @@ -45,14 +45,8 @@ class PairCoulStreitz : public Pair { }; int nmax; - int nelements; // # of unique elements - char **elements; // names of unique elements - int *elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets double precision; - Param *params; // parameter set for an I-J-K interaction + Param *params; // parameter sets for elements // Kspace parameters int kspacetype;