New MPI algorithm (still to be checked)

This commit is contained in:
julient31 2017-11-28 13:52:08 -07:00
parent f1182df776
commit 49f0a7a89a
3 changed files with 120 additions and 26 deletions

View File

@ -8,6 +8,8 @@ dimension 3
boundary p p p boundary p p p
#boundary f f f #boundary f f f
#newton off
#setting atom_style to spin: #setting atom_style to spin:
atom_style spin atom_style spin
@ -21,7 +23,7 @@ atom_modify map array
########################### ###########################
lattice fcc 3.54 lattice fcc 3.54
region box block 0.0 8.0 0.0 8.0 0.0 8.0 region box block 0.0 5.0 0.0 5.0 0.0 5.0
create_box 1 box create_box 1 box
create_atoms 1 box create_atoms 1 box
@ -36,21 +38,19 @@ group single_spin id 10
mass 1 58.93 mass 1 58.93
#Setting spins orientation and moment #Setting spins orientation and moment
#set group all spin/random 31 1.72 set group all spin/random 31 1.72
set group all spin 1.72 0.0 0.0 1.0 #set group all spin 1.72 0.0 0.0 1.0
set group single_spin spin/random 11 1.72 #set group single_spin spin/random 11 1.72
velocity all create 200 4928459 rot yes dist gaussian velocity all create 200 4928459 rot yes dist gaussian
#Magneto-mechanic interactions for bulk fcc Cobalt #Magneto-mechanic interactions for bulk fcc Cobalt
#pair_style pair/spin/exchange 4.0 #pair_style pair/spin/exchange 4.0
#pair_style eam/alloy #pair_style eam/alloy
#pair_style hybrid/overlay eam/alloy pair/spin/soc 4.0
#pair_style hybrid/overlay eam/alloy pair/spin/exchange 4.0 pair/spin/soc/neel 4.0 #pair_style hybrid/overlay eam/alloy pair/spin/exchange 4.0 pair/spin/soc/neel 4.0
#pair_style hybrid/overlay eam/alloy pair/spin/exchange 6.5
pair_style hybrid/overlay eam/alloy pair/spin/exchange 4.0 pair_style hybrid/overlay eam/alloy pair/spin/exchange 4.0
pair_coeff * * eam/alloy ../Co_PurjaPun_2012.eam.alloy Co pair_coeff * * eam/alloy ../examples/SPIN/Co_PurjaPun_2012.eam.alloy Co
#pair_coeff * * ../Co_PurjaPun_2012.eam.alloy Co #pair_coeff * * ../Co_PurjaPun_2012.eam.alloy Co
#pair_style pair/spin 4.0 #pair_style pair/spin 4.0
@ -114,6 +114,6 @@ thermo_modify format float %20.15g
dump 1 all custom 500 dump_VSRSV.lammpstrj type x y z spx spy spz dump 1 all custom 500 dump_VSRSV.lammpstrj type x y z spx spy spz
#Running the simulations for N timesteps #Running the simulations for N timesteps
#run 100
run 10000 run 10000
#run 2

View File

@ -109,6 +109,7 @@ FixIntegrationSpin::~FixIntegrationSpin()
memory->destroy(spj); memory->destroy(spj);
memory->destroy(fmi); memory->destroy(fmi);
memory->destroy(fmj); memory->destroy(fmj);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -190,6 +191,7 @@ void FixIntegrationSpin::init()
if (locklangevinspin->temp_flag == 1) temp_flag = 1; if (locklangevinspin->temp_flag == 1) temp_flag = 1;
} }
// perform the sectoring if mpi integration // perform the sectoring if mpi integration
if (mpi_flag) sectoring(); if (mpi_flag) sectoring();
@ -200,7 +202,6 @@ void FixIntegrationSpin::init()
void FixIntegrationSpin::initial_integrate(int vflag) void FixIntegrationSpin::initial_integrate(int vflag)
{ {
double dtfm,msq,scale,fm2,fmsq,sp2,spsq,energy; double dtfm,msq,scale,fm2,fmsq,sp2,spsq,energy;
double cp[3],g[3];
double **x = atom->x; double **x = atom->x;
double **v = atom->v; double **v = atom->v;
@ -226,7 +227,20 @@ void FixIntegrationSpin::initial_integrate(int vflag)
} }
} }
#define MPI_TEST //#define SEC
#define LIST
#if defined LIST
//printf("sectors = %d \n",nsectors);
int adv_list[nsectors][nlocal];
int k[nsectors];
for (int j = 0; j < nsectors; j++) {
k[j] = 0;
for (int i = 0; i < nlocal; i++) {
adv_list[j][i] = 0;
}
}
int s, p;
// update half s for all particles // update half s for all particles
if (extra == SPIN) { if (extra == SPIN) {
@ -234,6 +248,7 @@ void FixIntegrationSpin::initial_integrate(int vflag)
int nseci; int nseci;
for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal
comm->forward_comm(); comm->forward_comm();
k[j] = 0;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
xi[0] = x[i][0]; xi[0] = x[i][0];
xi[1] = x[i][1]; xi[1] = x[i][1];
@ -242,25 +257,23 @@ void FixIntegrationSpin::initial_integrate(int vflag)
if (j != nseci) continue; if (j != nseci) continue;
ComputeInteractionsSpin(i); ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm); AdvanceSingleSpin(i,dts,sp,fm);
adv_list[j][k[j]] = i;
k[j]++;
} }
#if defined MPI_TEST
MPI_Barrier(world);
#endif
} }
for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal int ntest = 0;
comm->forward_comm(); for (int j = 0; j < nsectors; j++) {
for (int i = nlocal-1; i >= 0; i--) { ntest += k[j];
xi[0] = x[i][0]; }
xi[1] = x[i][1]; if (ntest != nlocal) error->all(FLERR,"error, S(k[j]) != nlocal");
xi[2] = x[i][2];
nseci = coords2sector(xi); for (int j = nsectors-1; j >= 0; j--) {
if (j != nseci) continue; comm->forward_comm();
ComputeInteractionsSpin(i); for (int i = k[j]-1; i >= 0; i--) {
AdvanceSingleSpin(i,dts,sp,fm); p = adv_list[j][i];
ComputeInteractionsSpin(p);
AdvanceSingleSpin(p,dts,sp,fm);
} }
#if defined MPI_TEST
MPI_Barrier(world);
#endif
} }
} else if (mpi_flag == 0) { // serial seq. update } else if (mpi_flag == 0) { // serial seq. update
comm->forward_comm(); // comm. positions of ghost atoms comm->forward_comm(); // comm. positions of ghost atoms
@ -276,6 +289,54 @@ void FixIntegrationSpin::initial_integrate(int vflag)
} }
} else error->all(FLERR,"Illegal fix integration/spin command"); } else error->all(FLERR,"Illegal fix integration/spin command");
} }
#endif
#if defined SEC
// update half s for all particles
if (extra == SPIN) {
if (mpi_flag == 1) { // mpi seq. update
int nseci;
for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal
comm->forward_comm();
for (int i = 0; i < nlocal; i++) {
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
nseci = coords2sector(xi);
if (j != nseci) continue;
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
}
for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal
comm->forward_comm();
for (int i = nlocal-1; i >= 0; i--) {
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
nseci = coords2sector(xi);
if (j != nseci) continue;
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
}
} else if (mpi_flag == 0) { // serial seq. update
comm->forward_comm(); // comm. positions of ghost atoms
for (int i = 0; i < nlocal-1; i++){ // advance quarter s for nlocal
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
ComputeInteractionsSpin(nlocal-1);
AdvanceSingleSpin(nlocal-1,2.0*dts,sp,fm); // advance half s for 1
for (int i = nlocal-2; i >= 0; i--){ // advance quarter s for nlocal
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
} else error->all(FLERR,"Illegal fix integration/spin command");
}
#endif
// update x for all particles // update x for all particles
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
@ -286,39 +347,27 @@ void FixIntegrationSpin::initial_integrate(int vflag)
} }
} }
#if defined LIST
// update half s for all particles // update half s for all particles
if (extra == SPIN) { if (extra == SPIN) {
if (mpi_flag == 1) { // mpi seq. update if (mpi_flag == 1) { // mpi seq. update
int nseci; int nseci;
for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal
comm->forward_comm(); comm->forward_comm();
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < k[j]; i++) {
xi[0] = x[i][0]; p = adv_list[j][i];
xi[1] = x[i][1]; ComputeInteractionsSpin(p);
xi[2] = x[i][2]; AdvanceSingleSpin(p,dts,sp,fm);
nseci = coords2sector(xi);
if (j != nseci) continue;
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
} }
#if defined MPI_TEST
MPI_Barrier(world);
#endif
} }
for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal
comm->forward_comm(); comm->forward_comm();
for (int i = nlocal-1; i >= 0; i--) { for (int i = k[j]-1; i >= 0; i--) {
xi[0] = x[i][0]; p = adv_list[j][i];
xi[1] = x[i][1]; ComputeInteractionsSpin(p);
xi[2] = x[i][2]; AdvanceSingleSpin(p,dts,sp,fm);
nseci = coords2sector(xi);
if (j != nseci) continue;
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
} }
#if defined MPI_TEST
MPI_Barrier(world);
#endif
} }
} else if (mpi_flag == 0) { // serial seq. update } else if (mpi_flag == 0) { // serial seq. update
comm->forward_comm(); // comm. positions of ghost atoms comm->forward_comm(); // comm. positions of ghost atoms
@ -334,7 +383,52 @@ void FixIntegrationSpin::initial_integrate(int vflag)
} }
} else error->all(FLERR,"Illegal fix integration/spin command"); } else error->all(FLERR,"Illegal fix integration/spin command");
} }
#endif
#if defined SEC
// update half s for all particles
if (extra == SPIN) {
if (mpi_flag == 1) { // mpi seq. update
int nseci;
for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal
comm->forward_comm();
for (int i = 0; i < nlocal; i++) {
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
nseci = coords2sector(xi);
if (j != nseci) continue;
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
}
for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal
comm->forward_comm();
for (int i = nlocal-1; i >= 0; i--) {
xi[0] = x[i][0];
xi[1] = x[i][1];
xi[2] = x[i][2];
nseci = coords2sector(xi);
if (j != nseci) continue;
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
}
} else if (mpi_flag == 0) { // serial seq. update
comm->forward_comm(); // comm. positions of ghost atoms
for (int i = 0; i < nlocal-1; i++){ // advance quarter s for nlocal
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
ComputeInteractionsSpin(nlocal-1);
AdvanceSingleSpin(nlocal-1,2.0*dts,sp,fm); // advance half s for 1
for (int i = nlocal-2; i >= 0; i--){ // advance quarter s for nlocal
ComputeInteractionsSpin(i);
AdvanceSingleSpin(i,dts,sp,fm);
}
} else error->all(FLERR,"Illegal fix integration/spin command");
}
#endif
} }

View File

@ -175,9 +175,9 @@ void PairSpinExchange::compute(int eflag, int vflag)
f[j][0] += fj[0]; f[j][0] += fj[0];
f[j][1] += fj[1]; f[j][1] += fj[1];
f[j][2] += fj[2]; f[j][2] += fj[2];
fm[j][0] += fmj[0]; //fm[j][0] += fmj[0];
fm[j][1] += fmj[1]; //fm[j][1] += fmj[1];
fm[j][2] += fmj[2]; //fm[j][2] += fmj[2];
} }
if (eflag) { if (eflag) {