adding modifications for more than one fix langevin/spin in fix nve/spin

This commit is contained in:
julient31
2021-04-12 16:18:22 -06:00
parent bb52cf9377
commit 455bb933c8
8 changed files with 83 additions and 27 deletions

View File

@ -6,7 +6,7 @@ import matplotlib.pyplot as plt
import mpmath as mp import mpmath as mp
hbar=0.658212 # Planck's constant (eV.fs/rad) hbar=0.658212 # Planck's constant (eV.fs/rad)
# J0=0.05 # per-neighbor exchange interaction (eV) J0=0.05 # per-neighbor exchange interaction (eV)
# exchange interaction parameters # exchange interaction parameters
J1 = 11.254 # in eV J1 = 11.254 # in eV

View File

@ -30,8 +30,8 @@ neighbor 0.1 bin
neigh_modify every 10 check yes delay 20 neigh_modify every 10 check yes delay 20
fix 1 all precession/spin zeeman 0.0 0.0 0.0 1.0 fix 1 all precession/spin zeeman 0.0 0.0 0.0 1.0
fix 2 all langevin 200.0 200.0 1.0 48279 fix 2 all langevin 200.0 200.0 0.1 48279
fix 3 all langevin/spin 0.0 0.00001 321 fix 3 all langevin/spin 0.0 0.0 321
fix 4 all nve/spin lattice moving fix 4 all nve/spin lattice moving
timestep 0.001 timestep 0.001

View File

@ -21,16 +21,19 @@ mass 1 55.845
set group all spin 2.2 0.0 0.0 1.0 set group all spin 2.2 0.0 0.0 1.0
velocity all create 0 4928459 rot yes dist gaussian velocity all create 0 4928459 rot yes dist gaussian
pair_style hybrid/overlay eam/alloy spin/exchange 3.5 # pair_style hybrid/overlay eam/alloy spin/exchange 3.5
pair_style hybrid/overlay eam/alloy spin/exchange 4.0 spin/neel 4.0
pair_coeff * * eam/alloy Fe_Mishin2006.eam.alloy Fe pair_coeff * * eam/alloy Fe_Mishin2006.eam.alloy Fe
pair_coeff * * spin/exchange exchange 3.4 0.1 0.2171 1.841 pair_coeff * * spin/exchange exchange 3.4 0.1 0.2171 1.841
pair_coeff * * spin/neel neel 4.0 0.02 0.0 1.841 0.0 0.0 1.0
neighbor 0.1 bin neighbor 0.1 bin
neigh_modify every 10 check yes delay 20 neigh_modify every 10 check yes delay 20
fix 1 all precession/spin zeeman 0.0 0.0 0.0 1.0 fix 1 all precession/spin zeeman 0.0 0.0 0.0 1.0
fix 2 all langevin/spin 200.0 0.01 321 fix 2 all langevin 0.0 0.0 0.0 48279
fix 3 all nve/spin lattice moving fix 3 all langevin/spin 200.0 0.01 321
fix 4 all nve/spin lattice moving
timestep 0.001 timestep 0.001
# compute and output options # compute and output options

View File

@ -24,6 +24,7 @@
#include "fix_langevin_spin.h" #include "fix_langevin_spin.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include "atom.h"
#include "comm.h" #include "comm.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
@ -163,3 +164,14 @@ void FixLangevinSpin::add_temperature(double fmi[3])
fmi[1] *= gil_factor; fmi[1] *= gil_factor;
fmi[2] *= gil_factor; fmi[2] *= gil_factor;
} }
/* ---------------------------------------------------------------------- */
void FixLangevinSpin::compute_single_langevin(int i, double spi[3], double fmi[3])
{
int *mask = atom->mask;
if (mask[i] & groupbit) {
if (tdamp_flag) add_tdamping(spi,fmi);
if (temp_flag) add_temperature(fmi);
}
}

View File

@ -26,7 +26,7 @@ namespace LAMMPS_NS {
class FixLangevinSpin : public Fix { class FixLangevinSpin : public Fix {
public: public:
int tdamp_flag,ldamp_flag,temp_flag; // damping and temperature flags int tdamp_flag,temp_flag; // damping and temperature flags
FixLangevinSpin(class LAMMPS *, int, char **); FixLangevinSpin(class LAMMPS *, int, char **);
virtual ~FixLangevinSpin(); virtual ~FixLangevinSpin();
@ -35,6 +35,7 @@ class FixLangevinSpin : public Fix {
void setup(int); void setup(int);
void add_tdamping(double *, double *); // add transverse damping void add_tdamping(double *, double *); // add transverse damping
void add_temperature(double *); // add temperature void add_temperature(double *); // add temperature
void compute_single_langevin(int, double *, double *);
protected: protected:
double alpha_t; // transverse mag. damping double alpha_t; // transverse mag. damping

View File

@ -60,7 +60,8 @@ enum{NONE};
FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), Fix(lmp, narg, arg),
pair(nullptr), spin_pairs(nullptr), pair(nullptr), spin_pairs(nullptr), locklangevinspin(nullptr),
locksetforcespin(nullptr), lockprecessionspin(nullptr),
rsec(nullptr), stack_head(nullptr), stack_foot(nullptr), rsec(nullptr), stack_head(nullptr), stack_foot(nullptr),
backward_stacks(nullptr), forward_stacks(nullptr) backward_stacks(nullptr), forward_stacks(nullptr)
{ {
@ -76,7 +77,7 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) :
npairspin = 0; npairspin = 0;
// test nprec // test nprec
nprecspin = 0; nprecspin = nlangspin = nsetspin = 0;
// checking if map array or hash is defined // checking if map array or hash is defined
@ -128,7 +129,6 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) :
maglangevin_flag = 0; maglangevin_flag = 0;
tdamp_flag = temp_flag = 0; tdamp_flag = temp_flag = 0;
setforce_spin_flag = 0; setforce_spin_flag = 0;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -141,6 +141,8 @@ FixNVESpin::~FixNVESpin()
memory->destroy(forward_stacks); memory->destroy(forward_stacks);
memory->destroy(backward_stacks); memory->destroy(backward_stacks);
delete [] spin_pairs; delete [] spin_pairs;
delete [] locklangevinspin;
delete [] lockprecessionspin;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -261,20 +263,52 @@ void FixNVESpin::init()
if (count2 != nprecspin) if (count2 != nprecspin)
error->all(FLERR,"Incorrect number of fix precession/spin"); error->all(FLERR,"Incorrect number of fix precession/spin");
// ptrs on the FixLangevinSpin class // set ptrs for fix langevin/spin styles
// loop 1: obtain # of fix langevin/spin styles
for (iforce = 0; iforce < modify->nfix; iforce++) { for (iforce = 0; iforce < modify->nfix; iforce++) {
if (strstr(modify->fix[iforce]->style,"langevin/spin")) { if (strstr(modify->fix[iforce]->style,"langevin/spin")) {
maglangevin_flag = 1; nlangspin++;
locklangevinspin = (FixLangevinSpin *) modify->fix[iforce];
} }
} }
if (maglangevin_flag) { // init length of vector of ptrs to precession/spin styles
if (locklangevinspin->tdamp_flag == 1) tdamp_flag = 1;
if (locklangevinspin->temp_flag == 1) temp_flag = 1; if (nlangspin > 0) {
locklangevinspin = new FixLangevinSpin*[nprecspin];
} }
// loop 2: fill vector with ptrs to precession/spin styles
count2 = 0;
if (nlangspin > 0) {
for (iforce = 0; iforce < modify->nfix; iforce++) {
if (strstr(modify->fix[iforce]->style,"langevin/spin")) {
maglangevin_flag = 1;
locklangevinspin[count2] = (FixLangevinSpin *) modify->fix[iforce];
count2++;
}
}
}
if (count2 != nlangspin)
error->all(FLERR,"Incorrect number of fix precession/spin");
// // ptrs on the FixLangevinSpin class
// for (iforce = 0; iforce < modify->nfix; iforce++) {
// if (strstr(modify->fix[iforce]->style,"langevin/spin")) {
// maglangevin_flag = 1;
// locklangevinspin = (FixLangevinSpin *) modify->fix[iforce];
// }
// }
// if (maglangevin_flag) {
// if (locklangevinspin->tdamp_flag == 1) tdamp_flag = 1;
// if (locklangevinspin->temp_flag == 1) temp_flag = 1;
// }
// ptrs FixSetForceSpin classes // ptrs FixSetForceSpin classes
for (iforce = 0; iforce < modify->nfix; iforce++) { for (iforce = 0; iforce < modify->nfix; iforce++) {
@ -515,12 +549,15 @@ void FixNVESpin::ComputeInteractionsSpin(int i)
// update langevin damping and random force // update langevin damping and random force
if (maglangevin_flag) { // mag. langevin if (maglangevin_flag) { // mag. langevin
if (tdamp_flag) { // transverse damping for (int k = 0; k < nlangspin; k++) {
locklangevinspin->add_tdamping(spi,fmi); locklangevinspin[k]->compute_single_langevin(i,spi,fmi);
}
if (temp_flag) { // spin temperature
locklangevinspin->add_temperature(fmi);
} }
// if (tdamp_flag) { // transverse damping
// locklangevinspin->add_tdamping(spi,fmi);
// }
// if (temp_flag) { // spin temperature
// locklangevinspin->add_temperature(fmi);
// }
} }
// update setforce of magnetic interactions // update setforce of magnetic interactions

View File

@ -61,11 +61,15 @@ friend class PairSpin;
int tdamp_flag, temp_flag; int tdamp_flag, temp_flag;
int setforce_spin_flag; int setforce_spin_flag;
// pointers to magnetic fixes // pointers to fix langevin/spin styles
// class FixPrecessionSpin *lockprecessionspin; int nlangspin;
class FixLangevinSpin *locklangevinspin; class FixLangevinSpin **locklangevinspin;
class FixSetForceSpin *locksetforcespin;
// pointers to fix setforce/spin styles
int nsetspin;
class FixSetForceSpin *locksetforcespin; // to be done
// pointers to fix precession/spin styles // pointers to fix precession/spin styles

View File

@ -433,7 +433,6 @@ void FixPrecessionSpin::compute_anisotropy(double spi[3], double fmi[3])
fmi[0] += scalar*Kax; fmi[0] += scalar*Kax;
fmi[1] += scalar*Kay; fmi[1] += scalar*Kay;
fmi[2] += scalar*Kaz; fmi[2] += scalar*Kaz;
// printf("fm pres1: %g %g %g \n",fmi[0],fmi[1],fmi[2]);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */