Commit JT 031119

- add min_post_force in precession
This commit is contained in:
julient31
2019-03-11 17:37:44 -06:00
parent 5fff18932d
commit cc2b5fbb80
7 changed files with 19 additions and 95 deletions

View File

@ -1,5 +1,4 @@
# bcc iron in a 3d periodic box
print "Test 1"
units metal
dimension 3

View File

@ -13,8 +13,6 @@ region box block 0.0 68.0 0.0 68.0 0.0 1.0
create_box 1 box
create_atoms 1 box
#read_data ../examples/SPIN/gneb_bfo/initial.iron_spin
# setting mass, mag. moments, and interactions for bcc iron
mass 1 1.0
@ -34,20 +32,8 @@ neigh_modify every 10 check yes delay 20
fix 1 all precession/spin anisotropy 0.0000033 0.0 0.0 1.0
fix 2 all langevin/spin 0.1 0.0 21
fix 3 all nve/spin lattice no
#fix 3 all neb/spin 1.0
#fix 4 all nve/spin lattice no
#parallel ideal
timestep 0.0001
#thermo 10
#compute outsp all property/atom spx spy spz sp fmx fmy fmz
#dump 1 all custom 100 dump_bfo.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3]
#min_style spinmin
#minimize 1.0e-6 1.0e-6 1000 10000
#minimize 1.0e-6 1.0e-6 10000 10000
#minimize 1.0e-7 1.0e-7 10000 10000
compute out_mag all spin
compute out_pe all pe
@ -66,18 +52,6 @@ thermo_modify format float %20.15g
compute outsp all property/atom spx spy spz sp fmx fmy fmz
dump 200 all custom 1 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7]
#timestep 0.0001
#run 1
min_style spinmin
#minimize 1.0e-6 1.0e-6 1000 10000
#minimize 1.0e-6 1.0e-6 10000 10000
minimize 1.0e-8 1.0e-8 10000 1000
#write_dump all custom dump_bfo.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3]
#compute outsp all property/atom spx spy spz sp fmx fmy fmz
#dump 1 all custom 1 dump_bfo.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3]
#thermo 1
#neb/spin 0.0 0.1 10 10 10 final ../examples/SPIN/gneb_bfo/final.iron_spin
#neb/spin 0.0 0.1 1000 1000 100 final ../examples/SPIN/gneb_bfo/final.iron_spin
minimize 1.0e-6 1.0e-6 10000 10000
#minimize 1.0e-8 1.0e-8 10000 1000

View File

@ -13,8 +13,6 @@ region box block 0.0 4.0 0.0 4.0 0.0 1.0
create_box 1 box
create_atoms 1 box
#read_data ../examples/SPIN/gneb_bfo/initial.iron_spin
# setting mass, mag. moments, and interactions for bcc iron
mass 1 55.845
@ -31,16 +29,9 @@ neigh_modify every 10 check yes delay 20
fix 1 all precession/spin anisotropy 0.001 0.0 0.0 1.0
fix 2 all langevin/spin 0.1 0.0 21
fix 3 all nve/spin lattice no
#fix 3 all neb/spin 1.0
#fix 4 all nve/spin lattice no
#parallel ideal
timestep 0.0001
#min_style spinmin
#minimize 1.0e-6 1.0e-6 1000 10000
#minimize 1.0e-8 1.0e-6 1000 10000
compute out_mag all spin
compute out_pe all pe
compute out_ke all ke
@ -58,14 +49,6 @@ thermo_modify format float %20.15g
compute outsp all property/atom spx spy spz sp fmx fmy fmz
dump 1 all custom 1 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7]
#timestep 0.0001
#run 1
min_style spinmin
#minimize 1.0e-6 1.0e-6 1000 10000
minimize 1.0e-8 1.0e-6 1000 10000
#neb/spin 0.0 0.1 10 10 10 final ../examples/SPIN/gneb_bfo/final.iron_spin
#neb/spin 0.0 0.1 1000 1000 100 final ../examples/SPIN/gneb_bfo/final.iron_spin
minimize 1.0e-6 1.0e-6 1000 10000
#minimize 1.0e-8 1.0e-6 1000 10000

View File

@ -115,6 +115,7 @@ int FixPrecessionSpin::setmask()
{
int mask = 0;
mask |= POST_FORCE;
mask |= MIN_POST_FORCE;
mask |= THERMO_ENERGY;
mask |= POST_FORCE_RESPA;
return mask;
@ -283,3 +284,10 @@ double FixPrecessionSpin::compute_scalar()
}
return emag_all;
}
/* ---------------------------------------------------------------------- */
void FixPrecessionSpin::min_post_force(int vflag)
{
post_force(vflag);
}

View File

@ -33,8 +33,9 @@ class FixPrecessionSpin : public Fix {
int setmask();
void init();
void setup(int);
virtual void post_force(int);
virtual void post_force_respa(int, int, int);
void post_force(int);
void post_force_respa(int, int, int);
void min_post_force(int);
double compute_scalar();
int zeeman_flag, aniso_flag;

View File

@ -88,7 +88,7 @@ void MinSpinMin::reset_vectors()
}
/* ----------------------------------------------------------------------
minimization via QuickMin damped dynamics
minimization via damped spin dynamics
------------------------------------------------------------------------- */
int MinSpinMin::iterate(int maxiter)
@ -98,16 +98,6 @@ int MinSpinMin::iterate(int maxiter)
//double dtvone,dtv,dtf,dtfm;
int flag,flagall;
//alpha_final = 0.0;
// search for and allocate neb_spin fix
//int ineb;
//for (ineb = 0; ineb < modify->nfix; ineb++)
// if (strcmp(modify->fix[ineb]->style,"neb/spin") == 0) break;
//if (ineb == modify->nfix) error->all(FLERR,"spinmin requires use of fix neb/spin");
//fneb = (FixNEB_spin *) modify->fix[ineb];
for (int iter = 0; iter < maxiter; iter++) {
if (timer->check_timeout(niter))
@ -118,12 +108,10 @@ int MinSpinMin::iterate(int maxiter)
// optimize timestep accross processes / replicas
//dts = fneb->evaluate_dt();
dts = evaluate_dt();
// apply damped precessional dynamics to the spins
//fneb->advance_spins(dts);
advance_spins(dts);
@ -351,8 +339,6 @@ double MinSpinMin::evaluate_dt()
void MinSpinMin::advance_spins(double dts)
{
//int j=0;
//int *sametag = atom->sametag;
int nlocal = atom->nlocal;
int *mask = atom->mask;
double **sp = atom->sp;
@ -360,18 +346,14 @@ void MinSpinMin::advance_spins(double dts)
double tdampx,tdampy,tdampz;
double msq,scale,fm2,energy,dts2;
double alpha;
//double spi[3],fmi[3];
double cp[3],g[3];
//cp[0] = cp[1] = cp[2] = 0.0;
//g[0] = g[1] = g[2] = 0.0;
dts2 = dts*dts;
// fictitious Gilbert damping of 1
alpha = 1.0;
//printf("test inside spinmin, dts %g \n",dts);
//printf("test inside spinmin, fmi i=%d, %g %g %g \n",1,fm[1][0],fm[1][1],fm[1][2]);
// loop on all spins on proc.
@ -379,14 +361,6 @@ void MinSpinMin::advance_spins(double dts)
// for (int i = 0; i < nlocal; i++)
// if (mask[i] & groupbit) {
for (int i = 0; i < nlocal; i++) {
//spi[0] = sp[i][0];
//spi[1] = sp[i][1];
//spi[2] = sp[i][2];
//
//fmi[0] = fm[i][0];
//fmi[1] = fm[i][1];
//fmi[2] = fm[i][2];
// calc. damping torque
@ -394,8 +368,6 @@ void MinSpinMin::advance_spins(double dts)
tdampy = -alpha*(fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2]);
tdampz = -alpha*(fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0]);
//printf("for %d, test tdamp: %g %g %g \n",i,tdampx,tdampy,tdampz);
// apply advance algorithm (geometric, norm preserving)
fm2 = (tdampx*tdampx+tdampy*tdampy+tdampz*tdampz);
@ -405,15 +377,10 @@ void MinSpinMin::advance_spins(double dts)
cp[1] = tdampz*sp[i][0]-tdampx*sp[i][2];
cp[2] = tdampx*sp[i][1]-tdampy*sp[i][0];
//printf("for %d, test cp: %g %g %g \n",i,cp[0],cp[1],cp[2]);
g[0] = sp[i][0]+cp[0]*dts;
g[1] = sp[i][1]+cp[1]*dts;
g[2] = sp[i][2]+cp[2]*dts;
//g[0] += (fm[i][0]*energy-0.5*sp[i][0]*fm2)*0.5*dts2;
//g[1] += (fm[i][1]*energy-0.5*sp[i][1]*fm2)*0.5*dts2;
//g[2] += (fm[i][2]*energy-0.5*sp[i][2]*fm2)*0.5*dts2;
g[0] += (tdampx*energy-0.5*sp[i][0]*fm2)*0.5*dts2;
g[1] += (tdampy*energy-0.5*sp[i][1]*fm2)*0.5*dts2;
g[2] += (tdampz*energy-0.5*sp[i][2]*fm2)*0.5*dts2;
@ -421,10 +388,6 @@ void MinSpinMin::advance_spins(double dts)
g[0] /= (1+0.25*fm2*dts2);
g[1] /= (1+0.25*fm2*dts2);
g[2] /= (1+0.25*fm2*dts2);
//printf("test inside spinmin, spi i=%d, %g %g %g \n",i,sp[i][0],sp[i][1],sp[i][2]);
//printf("test inside spinmin, fmi i=%d, %g %g %g \n",i,fm[i][0],fm[i][1],fm[i][2]);
//printf("for %d, test g: %g %g %g \n",i,g[0],g[1],g[2]);
sp[i][0] = g[0];
sp[i][1] = g[1];
@ -455,8 +418,5 @@ void MinSpinMin::advance_spins(double dts)
//
}
//printf("test inside spinmin, dts = %g \n",dts);
//printf("test inside spinmin, fmi i=%d, %g %g %g \n",1,fm[1][0],fm[1][1],fm[1][2]);
//printf("test inside spinmin, spi i=%d, %g %g %g \n",1,sp[1][0],sp[1][1],sp[1][2]);
}

View File

@ -39,14 +39,13 @@ class MinSpinMin : public Min {
private:
// spin timestep
// global and spin timesteps
double dt;
double dts;
double *spvec; // variables for atomic dof, as 1d vector
double *fmvec; // variables for atomic dof, as 1d vector
double dt;
bigint last_negative;
};