Commit JT 030419

- correction of pair_spin calculations
- corrects an error between i and ii lists in single/pair calc.
This commit is contained in:
julient31 2019-03-04 08:04:11 -07:00
parent 849e52040a
commit ab0c35be93
4 changed files with 228 additions and 134 deletions

View File

@ -329,7 +329,9 @@ void PairSpinDmi::compute(int eflag, int vflag)
}
/* ---------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
update the pair interactions fmi acting on the spin ii
------------------------------------------------------------------------- */
void PairSpinDmi::compute_single_pair(int ii, double fmi[3])
{
@ -341,24 +343,49 @@ void PairSpinDmi::compute_single_pair(int ii, double fmi[3])
double delx,dely,delz;
double spj[3];
int i,j,jnum,itype,jtype;
int *ilist,*jlist,*numneigh,**firstneigh;
int i,j,jnum,itype,jtype,ntypes;
int k,locflag;
int *jlist,*numneigh,**firstneigh;
double rsq, inorm;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
i = ilist[ii];
itype = type[i];
// check if interaction applies to type of ii
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
itype = type[ii];
ntypes = atom->ntypes;
locflag = 0;
k = 1;
while (k <= ntypes) {
if (k <= itype) {
if (setflag[k][itype] == 1) {
locflag =1;
break;
}
k++;
} else if (k > itype) {
if (setflag[itype][k] == 1) {
locflag =1;
break;
}
k++;
} else error->all(FLERR,"Wrong type number");
}
jlist = firstneigh[i];
jnum = numneigh[i];
// if interaction applies to type ii,
// locflag = 1 and compute pair interaction
//i = ilist[ii];
if (locflag == 1) {
xi[0] = x[ii][0];
xi[1] = x[ii][1];
xi[2] = x[ii][2];
jlist = firstneigh[ii];
jnum = numneigh[ii];
for (int jj = 0; jj < jnum; jj++) {
@ -382,11 +409,10 @@ void PairSpinDmi::compute_single_pair(int ii, double fmi[3])
local_cut2 = cut_spin_dmi[itype][jtype]*cut_spin_dmi[itype][jtype];
if (rsq <= local_cut2) {
compute_dmi(i,j,eij,fmi,spj);
compute_dmi(ii,j,eij,fmi,spj);
}
}
}
}
/* ----------------------------------------------------------------------

View File

@ -318,7 +318,6 @@ void PairSpinExchange::compute(int eflag, int vflag)
void PairSpinExchange::compute_single_pair(int ii, double fmi[3])
{
int *type = atom->type;
double **x = atom->x;
double **sp = atom->sp;
@ -327,24 +326,48 @@ void PairSpinExchange::compute_single_pair(int ii, double fmi[3])
double delx,dely,delz;
double spj[3];
int i,j,jnum,itype,jtype;
int *ilist,*jlist,*numneigh,**firstneigh;
int i,j,jnum,itype,jtype,ntypes;
int k,locflag;
int *jlist,*numneigh,**firstneigh;
double rsq;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
i = ilist[ii];
itype = type[i];
// check if interaction applies to type of ii
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
itype = type[ii];
ntypes = atom->ntypes;
locflag = 0;
k = 1;
while (k <= ntypes) {
if (k <= itype) {
if (setflag[k][itype] == 1) {
locflag =1;
break;
}
k++;
} else if (k > itype) {
if (setflag[itype][k] == 1) {
locflag =1;
break;
}
k++;
} else error->all(FLERR,"Wrong type number");
}
jlist = firstneigh[i];
jnum = numneigh[i];
// if interaction applies to type ii,
// locflag = 1 and compute pair interaction
if (locflag == 1) {
xi[0] = x[ii][0];
xi[1] = x[ii][1];
xi[2] = x[ii][2];
jlist = firstneigh[ii];
jnum = numneigh[ii];
for (int jj = 0; jj < jnum; jj++) {
@ -363,10 +386,10 @@ void PairSpinExchange::compute_single_pair(int ii, double fmi[3])
rsq = delx*delx + dely*dely + delz*delz;
if (rsq <= local_cut2) {
compute_exchange(i,j,rsq,fmi,spj);
compute_exchange(ii,j,rsq,fmi,spj);
}
}
}
}
/* ----------------------------------------------------------------------
@ -528,3 +551,4 @@ void PairSpinExchange::read_restart_settings(FILE *fp)
MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
}

View File

@ -319,7 +319,9 @@ void PairSpinMagelec::compute(int eflag, int vflag)
}
/* ---------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
update the pair interactions fmi acting on the spin ii
------------------------------------------------------------------------- */
void PairSpinMagelec::compute_single_pair(int ii, double fmi[3])
{
@ -331,30 +333,48 @@ void PairSpinMagelec::compute_single_pair(int ii, double fmi[3])
double delx,dely,delz;
double spj[3];
int i,j,inum,jnum,itype,jtype;
int *ilist,*jlist,*numneigh,**firstneigh;
int i,j,jnum,itype,jtype,ntypes;
int k,locflag;
int *jlist,*numneigh,**firstneigh;
double rsq, inorm;
inum = list->inum;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
// compute pair if
// check if interaction applies to type of ii
if (ii < inum) {
itype = type[ii];
ntypes = atom->ntypes;
locflag = 0;
k = 1;
while (k <= ntypes) {
if (k <= itype) {
if (setflag[k][itype] == 1) {
locflag =1;
break;
}
k++;
} else if (k > itype) {
if (setflag[itype][k] == 1) {
locflag =1;
break;
}
k++;
} else error->all(FLERR,"Wrong type number");
}
i = ilist[ii];
itype = type[i];
// if interaction applies to type ii,
// locflag = 1 and compute pair interaction
xi[0] = xi[1] = xi[2] = 0.0;
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
if (locflag == 1) {
jlist = firstneigh[i];
jnum = numneigh[i];
xi[0] = x[ii][0];
xi[1] = x[ii][1];
xi[2] = x[ii][2];
jlist = firstneigh[ii];
jnum = numneigh[ii];
for (int jj = 0; jj < jnum; jj++) {
@ -377,12 +397,10 @@ void PairSpinMagelec::compute_single_pair(int ii, double fmi[3])
eij[2] = -inorm*delz;
if (rsq <= local_cut2) {
compute_magelec(i,j,eij,fmi,spj);
compute_magelec(ii,j,eij,fmi,spj);
}
}
}
}
/* ---------------------------------------------------------------------- */

View File

@ -330,7 +330,9 @@ void PairSpinNeel::compute(int eflag, int vflag)
}
/* ---------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
update the pair interactions fmi acting on the spin ii
------------------------------------------------------------------------- */
void PairSpinNeel::compute_single_pair(int ii, double fmi[3])
{
@ -342,30 +344,54 @@ void PairSpinNeel::compute_single_pair(int ii, double fmi[3])
double xi[3], rij[3], eij[3];
double spi[3], spj[3];
int i,j,jnum,itype,jtype;
int *ilist,*jlist,*numneigh,**firstneigh;
int i,j,jnum,itype,jtype,ntypes;
int k,locflag;
int *jlist,*numneigh,**firstneigh;
double rsq, inorm;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
i = ilist[ii];
itype = type[i];
// check if interaction applies to type of ii
spi[0] = sp[i][0];
spi[1] = sp[i][1];
spi[2] = sp[i][2];
itype = type[ii];
ntypes = atom->ntypes;
locflag = 0;
k = 1;
while (k <= ntypes) {
if (k <= itype) {
if (setflag[k][itype] == 1) {
locflag =1;
break;
}
k++;
} else if (k > itype) {
if (setflag[itype][k] == 1) {
locflag =1;
break;
}
k++;
} else error->all(FLERR,"Wrong type number");
}
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
// if interaction applies to type ii,
// locflag = 1 and compute pair interaction
if (locflag == 1) {
spi[0] = sp[ii][0];
spi[1] = sp[ii][1];
spi[2] = sp[ii][2];
xi[0] = x[ii][0];
xi[1] = x[ii][1];
xi[2] = x[ii][2];
eij[0] = eij[1] = eij[2] = 0.0;
jlist = firstneigh[i];
jnum = numneigh[i];
jlist = firstneigh[ii];
jnum = numneigh[ii];
for (int jj = 0; jj < jnum; jj++) {
@ -389,10 +415,10 @@ void PairSpinNeel::compute_single_pair(int ii, double fmi[3])
eij[2] = inorm*rij[2];
if (rsq <= local_cut2) {
compute_neel(i,j,rsq,eij,fmi,spi,spj);
compute_neel(ii,j,rsq,eij,fmi,spi,spj);
}
}
}
}
/* ---------------------------------------------------------------------- */