Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bfo spin #1355

Merged
merged 3 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 57 additions & 31 deletions src/SPIN/pair_spin_dmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand All @@ -341,52 +343,76 @@ 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;

// check if interaction applies to type of ii

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] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
//i = ilist[ii];
if (locflag == 1) {

jlist = firstneigh[i];
jnum = numneigh[i];
xi[0] = x[ii][0];
xi[1] = x[ii][1];
xi[2] = x[ii][2];

for (int jj = 0; jj < jnum; jj++) {
jlist = firstneigh[ii];
jnum = numneigh[ii];

j = jlist[jj];
j &= NEIGHMASK;
jtype = type[j];
for (int jj = 0; jj < jnum; jj++) {

spj[0] = sp[j][0];
spj[1] = sp[j][1];
spj[2] = sp[j][2];
j = jlist[jj];
j &= NEIGHMASK;
jtype = type[j];

delx = xi[0] - x[j][0];
dely = xi[1] - x[j][1];
delz = xi[2] - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
inorm = 1.0/sqrt(rsq);
eij[0] = -inorm*delx;
eij[1] = -inorm*dely;
eij[2] = -inorm*delz;
spj[0] = sp[j][0];
spj[1] = sp[j][1];
spj[2] = sp[j][2];

local_cut2 = cut_spin_dmi[itype][jtype]*cut_spin_dmi[itype][jtype];
delx = xi[0] - x[j][0];
dely = xi[1] - x[j][1];
delz = xi[2] - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
inorm = 1.0/sqrt(rsq);
eij[0] = -inorm*delx;
eij[1] = -inorm*dely;
eij[2] = -inorm*delz;

if (rsq <= local_cut2) {
compute_dmi(i,j,eij,fmi,spj);
}
local_cut2 = cut_spin_dmi[itype][jtype]*cut_spin_dmi[itype][jtype];

if (rsq <= local_cut2) {
compute_dmi(ii,j,eij,fmi,spj);
}
}
}

}

/* ----------------------------------------------------------------------
Expand Down
80 changes: 52 additions & 28 deletions src/SPIN/pair_spin_exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -327,46 +326,70 @@ 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

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");
}

// if interaction applies to type ii,
// locflag = 1 and compute pair interaction

xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
if (locflag == 1) {

xi[0] = x[ii][0];
xi[1] = x[ii][1];
xi[2] = x[ii][2];

jlist = firstneigh[i];
jnum = numneigh[i];
jlist = firstneigh[ii];
jnum = numneigh[ii];

for (int jj = 0; jj < jnum; jj++) {
for (int jj = 0; jj < jnum; jj++) {

j = jlist[jj];
j &= NEIGHMASK;
jtype = type[j];
local_cut2 = cut_spin_exchange[itype][jtype]*cut_spin_exchange[itype][jtype];
j = jlist[jj];
j &= NEIGHMASK;
jtype = type[j];
local_cut2 = cut_spin_exchange[itype][jtype]*cut_spin_exchange[itype][jtype];

spj[0] = sp[j][0];
spj[1] = sp[j][1];
spj[2] = sp[j][2];
spj[0] = sp[j][0];
spj[1] = sp[j][1];
spj[2] = sp[j][2];

delx = xi[0] - x[j][0];
dely = xi[1] - x[j][1];
delz = xi[2] - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
delx = xi[0] - x[j][0];
dely = xi[1] - x[j][1];
delz = xi[2] - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;

if (rsq <= local_cut2) {
compute_exchange(i,j,rsq,fmi,spj);
if (rsq <= local_cut2) {
compute_exchange(ii,j,rsq,fmi,spj);
}
}
}

}
}

/* ----------------------------------------------------------------------
Expand Down Expand Up @@ -528,3 +551,4 @@ void PairSpinExchange::read_restart_settings(FILE *fp)
MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
}


105 changes: 65 additions & 40 deletions src/SPIN/pair_spin_magelec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ void PairSpinMagelec::coeff(int narg, char **arg)
}
if (count == 0)
error->all(FLERR,"Incorrect args in pair_style command");

}

/* ----------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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])
{
Expand All @@ -332,55 +333,79 @@ 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;

// check if interaction applies to type of ii

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];

xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];

jlist = firstneigh[i];
jnum = numneigh[i];

for (int jj = 0; jj < jnum; jj++) {

j = jlist[jj];
j &= NEIGHMASK;
jtype = type[j];
local_cut2 = cut_spin_magelec[itype][jtype]*cut_spin_magelec[itype][jtype];

spj[0] = sp[j][0];
spj[1] = sp[j][1];
spj[2] = sp[j][2];

delx = xi[0] - x[j][0];
dely = xi[1] - x[j][1];
delz = xi[2] - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
inorm = 1.0/sqrt(rsq);
eij[0] = -inorm*delx;
eij[1] = -inorm*dely;
eij[2] = -inorm*delz;

if (rsq <= local_cut2) {
compute_magelec(i,j,rsq,eij,fmi,spj);
// 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++) {

j = jlist[jj];
j &= NEIGHMASK;
jtype = type[j];
local_cut2 = cut_spin_magelec[itype][jtype]*cut_spin_magelec[itype][jtype];

spj[0] = sp[j][0];
spj[1] = sp[j][1];
spj[2] = sp[j][2];

delx = xi[0] - x[j][0];
dely = xi[1] - x[j][1];
delz = xi[2] - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
inorm = 1.0/sqrt(rsq);
eij[0] = -inorm*delx;
eij[1] = -inorm*dely;
eij[2] = -inorm*delz;

if (rsq <= local_cut2) {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/SPIN/pair_spin_magelec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
Loading