Unverified Commit 390fc873 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1355 from julient31/bfo_spin

bugfix update for SPIN package
parents 6b8a768f ab0c35be
Loading
Loading
Loading
Loading
+57 −31
Original line number Diff line number Diff line
@@ -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);
      }
    }

  }

}

/* ----------------------------------------------------------------------
+52 −28
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ void PairSpinExchange::settings(int narg, char **arg)
}

/* ----------------------------------------------------------------------
   set coeffs for one or more type spin pairs (only one for now)
   set coeffs for one or more type spin pairs
------------------------------------------------------------------------- */

void PairSpinExchange::coeff(int narg, char **arg)
@@ -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);
}

+65 −40
Original line number Diff line number Diff line
@@ -142,7 +142,6 @@ void PairSpinMagelec::coeff(int narg, char **arg)
  }
  if (count == 0)
    error->all(FLERR,"Incorrect args in pair_style command");

}

/* ----------------------------------------------------------------------
@@ -287,7 +286,7 @@ void PairSpinMagelec::compute(int eflag, int vflag)
      // compute me interaction

      if (rsq <= local_cut2) {
        compute_magelec(i,j,rsq,eij,fmi,spj);
        compute_magelec(i,j,eij,fmi,spj);
        if (lattice_flag) {
          compute_magelec_mech(i,j,fi,spi,spj);
        }
@@ -320,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])
{
@@ -332,24 +333,48 @@ void PairSpinMagelec::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

  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++) {
    
@@ -372,15 +397,15 @@ void PairSpinMagelec::compute_single_pair(int ii, double fmi[3])
      eij[2] = -inorm*delz;
    
      if (rsq <= local_cut2) {
      compute_magelec(i,j,rsq,eij,fmi,spj);
        compute_magelec(ii,j,eij,fmi,spj);
      }
    }
  }

}

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

void PairSpinMagelec::compute_magelec(int i, int j, double /*rsq*/, double eij[3], double fmi[3], double spj[3])
void PairSpinMagelec::compute_magelec(int i, int j, double eij[3], double fmi[3], double spj[3])
{
  int *type = atom->type;
  int itype, jtype;
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class PairSpinMagelec : public PairSpin {
  void compute(int, int);
  void compute_single_pair(int, double *);

  void compute_magelec(int, int, double, double *, double *, double *);
  void compute_magelec(int, int, double *, double *, double *);
  void compute_magelec_mech(int, int, double *, double *, double *);

  void write_restart(FILE *);
+60 −34
Original line number Diff line number Diff line
@@ -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);
      }
    }
  }

}

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