Commit MPI algorithm
This commit is contained in:
@ -83,7 +83,7 @@ fix 1 all force/spin zeeman 0.0 0.0 0.0 1.0
|
|||||||
fix 2 all langevin/spin 0.0 0.0 0.0 21
|
fix 2 all langevin/spin 0.0 0.0 0.0 21
|
||||||
|
|
||||||
#Magnetic integration fix
|
#Magnetic integration fix
|
||||||
fix 3 all integration/spin serial
|
fix 3 all integration/spin mpi
|
||||||
|
|
||||||
#compute real time, total magnetization, magnetic energy, and spin temperature
|
#compute real time, total magnetization, magnetic energy, and spin temperature
|
||||||
#Iteration | Time | Mx | My | Mz | |M| | Em | Tm
|
#Iteration | Time | Mx | My | Mz | |M| | Em | Tm
|
||||||
@ -115,5 +115,5 @@ 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 10000
|
run 10000
|
||||||
#run 100
|
#run 2
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,8 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp)
|
|||||||
xcol_data = 4;
|
xcol_data = 4;
|
||||||
|
|
||||||
forceclearflag = 1;
|
forceclearflag = 1;
|
||||||
atom->mumag_flag = atom->sp_flag = 1;
|
atom->mumag_flag = 1;
|
||||||
|
atom->sp_flag = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,8 @@ FixIntegrationSpin::FixIntegrationSpin(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
FixIntegrationSpin::~FixIntegrationSpin(){
|
FixIntegrationSpin::~FixIntegrationSpin()
|
||||||
|
{
|
||||||
//delete lockpairspin;
|
//delete lockpairspin;
|
||||||
//delete lockforcespin;
|
//delete lockforcespin;
|
||||||
memory->destroy(xi);
|
memory->destroy(xi);
|
||||||
@ -124,8 +125,6 @@ int FixIntegrationSpin::setmask()
|
|||||||
|
|
||||||
void FixIntegrationSpin::init()
|
void FixIntegrationSpin::init()
|
||||||
{
|
{
|
||||||
//FixNVE::init();
|
|
||||||
|
|
||||||
// set timesteps
|
// set timesteps
|
||||||
dtv = update->dt;
|
dtv = update->dt;
|
||||||
dtf = 0.5 * update->dt * force->ftm2v;
|
dtf = 0.5 * update->dt * force->ftm2v;
|
||||||
@ -181,11 +180,6 @@ void FixIntegrationSpin::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set flags for the different magnetic interactions
|
|
||||||
// if (magpair_flag) {
|
|
||||||
// if (lockpairspinexchange->exch_flag == 1) exch_flag = 1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (magforce_flag) {
|
if (magforce_flag) {
|
||||||
if (lockforcespin->zeeman_flag == 1) zeeman_flag = 1;
|
if (lockforcespin->zeeman_flag == 1) zeeman_flag = 1;
|
||||||
if (lockforcespin->aniso_flag == 1) aniso_flag = 1;
|
if (lockforcespin->aniso_flag == 1) aniso_flag = 1;
|
||||||
@ -220,11 +214,6 @@ void FixIntegrationSpin::initial_integrate(int vflag)
|
|||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
|
|
||||||
//#define MAG_TEST
|
|
||||||
#if defined MAG_TEST
|
|
||||||
tagint *tag = atom->tag;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// advance spin-lattice system, vsrsv
|
// advance spin-lattice system, vsrsv
|
||||||
// update half v for all particles
|
// update half v for all particles
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
@ -237,19 +226,14 @@ void FixIntegrationSpin::initial_integrate(int vflag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MPI_TEST
|
||||||
|
|
||||||
// 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();
|
||||||
#if defined MAG_TEST
|
|
||||||
if (j == 0) {
|
|
||||||
//for (int i = 0; i < nlocal; i++) {
|
|
||||||
printf("L1: test atom i=%d, tagi=%d \n",0,tag[0]);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
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];
|
||||||
@ -259,6 +243,9 @@ void FixIntegrationSpin::initial_integrate(int vflag)
|
|||||||
ComputeInteractionsSpin(i);
|
ComputeInteractionsSpin(i);
|
||||||
AdvanceSingleSpin(i,dts,sp,fm);
|
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();
|
||||||
@ -271,6 +258,9 @@ void FixIntegrationSpin::initial_integrate(int vflag)
|
|||||||
ComputeInteractionsSpin(i);
|
ComputeInteractionsSpin(i);
|
||||||
AdvanceSingleSpin(i,dts,sp,fm);
|
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
|
||||||
@ -302,13 +292,6 @@ 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();
|
||||||
#if defined MAG_TEST
|
|
||||||
if (j == 0) {
|
|
||||||
//for (int i = 0; i < nlocal; i++) {
|
|
||||||
printf("L2 test atom i=%d, tagi=%d \n",0,tag[0]);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
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];
|
||||||
@ -318,6 +301,9 @@ void FixIntegrationSpin::initial_integrate(int vflag)
|
|||||||
ComputeInteractionsSpin(i);
|
ComputeInteractionsSpin(i);
|
||||||
AdvanceSingleSpin(i,dts,sp,fm);
|
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();
|
||||||
@ -330,6 +316,9 @@ void FixIntegrationSpin::initial_integrate(int vflag)
|
|||||||
ComputeInteractionsSpin(i);
|
ComputeInteractionsSpin(i);
|
||||||
AdvanceSingleSpin(i,dts,sp,fm);
|
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
|
||||||
@ -363,12 +352,6 @@ void FixIntegrationSpin::ComputeInteractionsSpin(int ii)
|
|||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
const int newton_pair = force->newton_pair;
|
const int newton_pair = force->newton_pair;
|
||||||
|
|
||||||
//#define SERIAL2
|
|
||||||
#if defined SERIAL2
|
|
||||||
int num_j;
|
|
||||||
tagint *tag = atom->tag;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// add test here
|
// add test here
|
||||||
if (exch_flag) {
|
if (exch_flag) {
|
||||||
inum = lockpairspinexchange->list->inum;
|
inum = lockpairspinexchange->list->inum;
|
||||||
@ -386,13 +369,6 @@ void FixIntegrationSpin::ComputeInteractionsSpin(int ii)
|
|||||||
int vflag = 0;
|
int vflag = 0;
|
||||||
int pair_compute_flag = 1;
|
int pair_compute_flag = 1;
|
||||||
|
|
||||||
//#define SERIAL1
|
|
||||||
#if defined SERIAL1
|
|
||||||
if (mpi_flag == 0) {
|
|
||||||
comm->forward_comm();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// force computation for spin i
|
// force computation for spin i
|
||||||
i = ilist[ii];
|
i = ilist[ii];
|
||||||
|
|
||||||
@ -416,17 +392,6 @@ void FixIntegrationSpin::ComputeInteractionsSpin(int ii)
|
|||||||
itype = type[ii];
|
itype = type[ii];
|
||||||
jtype = type[j];
|
jtype = type[j];
|
||||||
|
|
||||||
#if defined SERIAL2
|
|
||||||
if (mpi_flag == 0) {
|
|
||||||
if (j >= nlocal) {
|
|
||||||
num_j = atom->map(tag[j]);
|
|
||||||
sp[j][0] = sp[num_j][0];
|
|
||||||
sp[j][1] = sp[num_j][1];
|
|
||||||
sp[j][2] = sp[num_j][2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
spj[0] = sp[j][0];
|
spj[0] = sp[j][0];
|
||||||
spj[1] = sp[j][1];
|
spj[1] = sp[j][1];
|
||||||
spj[2] = sp[j][2];
|
spj[2] = sp[j][2];
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class FixIntegrationSpin : public Fix {
|
|||||||
protected:
|
protected:
|
||||||
int extra, mpi_flag;
|
int extra, mpi_flag;
|
||||||
|
|
||||||
// vel., force, and spin timesteps
|
// velocity, force, and spin timesteps
|
||||||
double dtv,dtf,dts;
|
double dtv,dtf,dts;
|
||||||
|
|
||||||
// mag. interaction flags
|
// mag. interaction flags
|
||||||
|
|||||||
@ -220,8 +220,6 @@ void FixLangevinSpin::add_temperature(double *fmi)
|
|||||||
double rz = sigma*(-1.0+2.0*random->uniform());
|
double rz = sigma*(-1.0+2.0*random->uniform());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// printf("test Gaussian vals: %g \n",rx);
|
|
||||||
|
|
||||||
// adding the random field
|
// adding the random field
|
||||||
fmi[0] += rx;
|
fmi[0] += rx;
|
||||||
fmi[1] += ry;
|
fmi[1] += ry;
|
||||||
|
|||||||
@ -33,11 +33,9 @@ class FixLangevinSpin : public Fix {
|
|||||||
void setup(int);
|
void setup(int);
|
||||||
// virtual void post_force(int);
|
// virtual void post_force(int);
|
||||||
void post_force_respa(int, int, int);
|
void post_force_respa(int, int, int);
|
||||||
// add transverse damping and temperature
|
void add_tdamping(double *, double *); // add transverse damping
|
||||||
void add_tdamping(double *, double *);
|
void add_temperature(double *); // add temperature
|
||||||
void add_temperature(double *);
|
int tdamp_flag, ldamp_flag, temp_flag; // damping and temperature flags
|
||||||
// associated flags
|
|
||||||
int tdamp_flag, ldamp_flag, temp_flag;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double *spi, *fmi;
|
double *spi, *fmi;
|
||||||
|
|||||||
Reference in New Issue
Block a user