#include "meam.h"
#include <algorithm>
using namespace LAMMPS_NS;
void
MEAM::meam_checkindex(int num, int lim, int nidx, int* idx , int* ierr)
{
*ierr = 0;
if (nidx < num) {
*ierr = 2;
return;
}
for (int i = 0; i < num; i++) {
if ((idx[i] < 0) || (idx[i] >= lim)) {
*ierr = 3;
return;
}
}
}
void
MEAM::meam_setup_param(int which, double value, int nindex, int* index , int* errorflag)
{
int i1, i2;
lattice_t vlat;
*errorflag = 0;
switch (which) {
case 0:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->Ec_meam[index[0]][index[1]] = value;
break;
case 1:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->alpha_meam[index[0]][index[1]] = value;
break;
case 2:
meam_checkindex(1, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->rho0_meam[index[0]] = value;
break;
case 3:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->delta_meam[index[0]][index[1]] = value;
break;
case 4:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
vlat = (lattice_t)value;
this->lattce_meam[index[0]][index[1]] = vlat;
break;
case 5:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->attrac_meam[index[0]][index[1]] = value;
break;
case 6:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->repuls_meam[index[0]][index[1]] = value;
break;
case 7:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
i1 = std::min(index[0], index[1]);
i2 = std::max(index[0], index[1]);
this->nn2_meam[i1][i2] = (int)value;
break;
case 8:
meam_checkindex(3, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->Cmin_meam[index[0]][index[1]][index[2]] = value;
break;
case 9:
meam_checkindex(3, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->Cmax_meam[index[0]][index[1]][index[2]] = value;
break;
case 10:
this->rc_meam = value;
break;
case 11:
this->delr_meam = value;
break;
case 12:
this->augt1 = (int)value;
break;
case 13:
this->gsmooth_factor = value;
break;
case 14:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
this->re_meam[index[0]][index[1]] = value;
break;
case 15:
this->ialloy = (int)value;
break;
case 16:
this->mix_ref_t = (int)value;
break;
case 17:
this->erose_form = (int)value;
break;
case 18:
meam_checkindex(2, neltypes, nindex, index, errorflag);
if (*errorflag != 0)
return;
i1 = std::min(index[0], index[1]);
i2 = std::max(index[0], index[1]);
this->zbl_meam[i1][i2] = (int)value;
break;
case 19:
this->emb_lin_neg = (int)value;
break;
case 20:
this->bkgd_dyn = (int)value;
break;
default:
*errorflag = 1;
}
}