From f2096ded96f5321f942ea86a2770f9178056e255 Mon Sep 17 00:00:00 2001 From: julient31 Date: Mon, 19 Apr 2021 17:09:53 -0600 Subject: [PATCH] - improved design of test_problem - cleaned up langevin/spin - started doc for stt and hexaniso --- doc/src/fix_precession_spin.rst | 11 +++++++---- examples/SPIN/test_problems/README | 11 +++++++++++ examples/SPIN/test_problems/run_all.sh | 25 +++++++++++++++++++++++++ src/SPIN/fix_langevin_spin.cpp | 26 +------------------------- src/SPIN/fix_langevin_spin.h | 6 ------ 5 files changed, 44 insertions(+), 35 deletions(-) create mode 100755 examples/SPIN/test_problems/run_all.sh diff --git a/doc/src/fix_precession_spin.rst b/doc/src/fix_precession_spin.rst index 5e818374a0..033c244131 100644 --- a/doc/src/fix_precession_spin.rst +++ b/doc/src/fix_precession_spin.rst @@ -12,7 +12,7 @@ Syntax * ID, group are documented in :doc:`fix ` command * precession/spin = style name of this fix command -* style = *zeeman* or *anisotropy* or *cubic* +* style = *zeeman* or *anisotropy* or *cubic* or *stt* or *hexaniso* .. parsed-literal:: @@ -22,12 +22,15 @@ Syntax *anisotropy* args = K x y z K = intensity of the magnetic anisotropy (in eV) x y z = vector direction of the anisotropy - - .. parsed-literal:: - *cubic* args = K1 K2c n1x n1y n1x n2x n2y n2z n3x n3y n3z K1 and K2c = intensity of the magnetic anisotropy (in eV) n1x to n3z = three direction vectors of the cubic anisotropy + *stt* args = J x y z + H = intensity of the spin-transfer torque field (in Tesla) + x y z = vector direction of the field + *hexaniso* args = K6 x y z + H = intensity of the spin-transfer torque field (in Tesla) + x y z = vector direction of the field Examples """""""" diff --git a/examples/SPIN/test_problems/README b/examples/SPIN/test_problems/README index 0a1362ec9c..17e0935a35 100644 --- a/examples/SPIN/test_problems/README +++ b/examples/SPIN/test_problems/README @@ -45,3 +45,14 @@ directory. results (computed by the python script). Note: This example is a reworked version of a test problem provided by Martin Kroger (ETHZ). + +- validation_nve: + simulates a small assembly of magnetic atoms (54). The atoms are + coupled by an exchange interaction and a mechanical potential + (EAM here). + This example represents an NVE run: the total energy of the + system is preserved, whereas the spin and lattice energy + reservoirs are exchanging energy. + Run as: ./run-test-nve.sh + Output: res_lammps.dat contains the data. The results are displayed + by nve_spin_lattice.pdf. diff --git a/examples/SPIN/test_problems/run_all.sh b/examples/SPIN/test_problems/run_all.sh new file mode 100755 index 0000000000..fb682e3ef5 --- /dev/null +++ b/examples/SPIN/test_problems/run_all.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# test 1: damping and exchange +cd validation_damped_exchange/ +./run-test-exchange.sh +rm dump.data res_lammps.dat res_llg.dat +cd .. + +# test 2: damping and Zeeman +cd validation_damped_precession/ +./run-test-prec.sh +rm res_lammps.dat res_llg.dat +cd .. + +# test 3: langevin, damping and Zeeman +cd validation_langevin_precession/ +./run-test-prec.sh +rm average_spin test-prec-spin.in res_lammps.dat res_langevin.dat +cd .. + +# test 4: NVE run, test Etot preservation +cd validation_nve/ +./run-test-nve.sh +rm nve_spin_lattice.pdf res_lammps.dat +cd .. diff --git a/src/SPIN/fix_langevin_spin.cpp b/src/SPIN/fix_langevin_spin.cpp index b4de180406..0b566ce60b 100644 --- a/src/SPIN/fix_langevin_spin.cpp +++ b/src/SPIN/fix_langevin_spin.cpp @@ -45,7 +45,7 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ FixLangevinSpin::FixLangevinSpin(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), id_temp(nullptr), random(nullptr) + Fix(lmp, narg, arg), random(nullptr) { if (narg != 6) error->all(FLERR,"Illegal langevin/spin command"); @@ -53,14 +53,6 @@ FixLangevinSpin::FixLangevinSpin(LAMMPS *lmp, int narg, char **arg) : alpha_t = utils::numeric(FLERR,arg[4],false,lmp); seed = utils::inumeric(FLERR,arg[5],false,lmp); - dynamic_group_allow = 1; - scalar_flag = 1; - global_freq = 1; - extscalar = 1; - ecouple_flag = 1; - nevery = 1; - tallyflag = 1; - if (alpha_t < 0.0) { error->all(FLERR,"Illegal langevin/spin command"); } else if (alpha_t == 0.0) { @@ -117,10 +109,8 @@ void FixLangevinSpin::init() double hbar = force->hplanck/MY_2PI; // eV/(rad.THz) double kb = force->boltz; // eV/K - // D = (MY_2PI*alpha_t*gil_factor*kb*temp); D = (alpha_t*gil_factor*kb*temp); - // D = (12.0/MY_2PI)*(MY_2PI*alpha_t*gil_factor*kb*temp); D /= (hbar*dts); sigma = sqrt(2.0*D); } @@ -163,7 +153,6 @@ void FixLangevinSpin::add_temperature(int i, double spi[3], double fmi[3]) double rz = sigma*random->gaussian(); double hbar = force->hplanck/MY_2PI; - energyS += 0.25*hbar*(rx*spi[0]+ry*spi[1]+rz*spi[2])*update->dt; // adding the random field fmi[0] += rx; @@ -187,16 +176,3 @@ void FixLangevinSpin::compute_single_langevin(int i, double spi[3], double fmi[3 if (temp_flag) add_temperature(i,spi,fmi); } } - -/* ---------------------------------------------------------------------- */ - -double FixLangevinSpin::compute_scalar() -{ - if (!tallyflag) return 0.0; - - double energy_all; - MPI_Allreduce(&energyS,&energy_all,1,MPI_DOUBLE,MPI_SUM,world); - return -energy_all; -} - -/* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/fix_langevin_spin.h b/src/SPIN/fix_langevin_spin.h index 2a8a654597..090e5b666a 100644 --- a/src/SPIN/fix_langevin_spin.h +++ b/src/SPIN/fix_langevin_spin.h @@ -36,7 +36,6 @@ class FixLangevinSpin : public Fix { void add_tdamping(double *, double *); // add transverse damping void add_temperature(int, double *, double *); void compute_single_langevin(int, double *, double *); - virtual double compute_scalar(); protected: double alpha_t; // transverse mag. damping @@ -44,11 +43,6 @@ class FixLangevinSpin : public Fix { double temp; // spin bath temperature double D,sigma; // bath intensity var. double gil_factor; // gilbert's prefactor - double energyS; - int nlocal_max; - int tallyflag; - char *id_temp; - class Compute *temperature; int nlevels_respa; class RanMars *random;