diff --git a/examples/SPIN/cobalt_fcc/exchange_fit_fcc_co/exchange_fcc_cobalt.dat b/examples/SPIN/cobalt_fcc/exchange_fit_fcc_co/exchange_fcc_cobalt.dat new file mode 100644 index 0000000000000000000000000000000000000000..dce45c090dfb92ea3d9dd2c31fe925df9dc1bc01 --- /dev/null +++ b/examples/SPIN/cobalt_fcc/exchange_fit_fcc_co/exchange_fcc_cobalt.dat @@ -0,0 +1,5 @@ +2.503 0.01476 +3.54 0.001497 +4.33 0.001578 +5.01 -0.001224 +5.597 0.000354 diff --git a/examples/SPIN/cobalt_fcc/exchange_fit_fcc_co/exchange_fit.py b/examples/SPIN/cobalt_fcc/exchange_fit_fcc_co/exchange_fit.py new file mode 100644 index 0000000000000000000000000000000000000000..09be6db3e4de0ed5b564fdcc460c0ba3d9efbdb2 --- /dev/null +++ b/examples/SPIN/cobalt_fcc/exchange_fit_fcc_co/exchange_fit.py @@ -0,0 +1,32 @@ +#Program fitting the exchange interaction +#Model curve: Bethe-Slater function +import numpy as np, pylab, tkinter +import matplotlib.pyplot as plt +from scipy.optimize import curve_fit +from decimal import * + +print("Loop begin") + +#Definition of the Bethe-Slater function +def func(x,a,b,c): + return 4*a*((x/c)**2)*(1-b*(x/c)**2)*np.exp(-(x/c)**2) + +#Exchange coeff table (data to fit) +rdata, Jdata = np.loadtxt('exchange_fcc_cobalt.dat', usecols=(0,1), unpack=True) +plt.plot(rdata, Jdata, 'b-', label='data') + +#Perform the fit +popt, pcov = curve_fit(func, rdata, Jdata, bounds=(0, [500.,5.,5.])) +plt.plot(rdata, func(rdata, *popt), 'r--', label='fit') + +#Print the fitted params +print("Parameters: a={:.10} (in meV), b={:.10} (adim), c={:.10} (in Ang)".format(*popt)) + +#Ploting the result +plt.xlabel('r_ij') +pylab.xlim([0,6.5]) +plt.ylabel('J_ij') +plt.legend() +plt.show() + +print("Loop end") diff --git a/examples/SPIN/iron/exchange_fit_bcc_iron/exchange_bcc_iron.dat b/examples/SPIN/iron/exchange_fit_bcc_iron/exchange_bcc_iron.dat index 7cfe1cb5866284e07ffcee88791f1cffa10ad81d..58134f244466c5a60bb103b73e6f8ba61414e14b 100644 --- a/examples/SPIN/iron/exchange_fit_bcc_iron/exchange_bcc_iron.dat +++ b/examples/SPIN/iron/exchange_fit_bcc_iron/exchange_bcc_iron.dat @@ -1,3 +1,5 @@ 2.4824 0.01948336 2.8665 0.01109 4.0538 -0.0002176 +4.753 -0.001714 +4.965 -0.001986 diff --git a/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fcc_ni.dat b/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fcc_ni.dat index 4e5aa4765957bd9d196f7543751fb5ce174634b4..376f6fd16242f4255bd4ba277efb0cfd1e5b4ddc 100644 --- a/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fcc_ni.dat +++ b/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fcc_ni.dat @@ -1,5 +1,5 @@ -2.495 8.3 -3.524 -3.99 -4.31 0.998 -4.99 -0.955 -5.56 0.213 +2.492 0.0028027 +3.524 0.0000816 +4.316 0.0003537 +4.984 0.0001632 +5.572 0.0000408 diff --git a/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fcc_ni2.dat b/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fcc_ni2.dat new file mode 100644 index 0000000000000000000000000000000000000000..4e5aa4765957bd9d196f7543751fb5ce174634b4 --- /dev/null +++ b/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fcc_ni2.dat @@ -0,0 +1,5 @@ +2.495 8.3 +3.524 -3.99 +4.31 0.998 +4.99 -0.955 +5.56 0.213 diff --git a/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fit.py b/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fit.py index dd07e9f29578766554c7349f72b9f6b78a7fd079..4046fa45f7c9dde935e492daf7fdf9453daea82a 100644 --- a/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fit.py +++ b/examples/SPIN/nickel/exchange_fit_fcc_ni/exchange_fit.py @@ -16,7 +16,7 @@ rdata, Jdata = np.loadtxt('exchange_fcc_ni.dat', usecols=(0,1), unpack=True) plt.plot(rdata, Jdata, 'b-', label='data') # perform the fit -popt, pcov = curve_fit(func, rdata, Jdata, bounds=(0, [500.,5.,5.])) +popt, pcov = curve_fit(func, rdata, Jdata, bounds=([0.0,-1.0,0.0], [100.,5.,5.])) plt.plot(rdata, func(rdata, *popt), 'r--', label='fit') # print the fitted parameters @@ -24,7 +24,8 @@ print("Parameters: a={:.10} (in meV), b={:.10} (adim), c={:.10} (in Ang)".format # ploting the result plt.xlabel('r_ij') -pylab.xlim([0,6.5]) +pylab.xlim([0.0,6.5]) +#pylab.ylim([-2.0,10.0]) plt.ylabel('J_ij') plt.legend() plt.show() diff --git a/src/SPIN/README b/src/SPIN/README new file mode 100644 index 0000000000000000000000000000000000000000..e371e3976746e4b900fca5d135e6dda30831aedd --- /dev/null +++ b/src/SPIN/README @@ -0,0 +1,25 @@ +The SPIN package enables coupled spin dynamics and molecular +dynamics simulations. + +The package provides the following features: + +* defining a classical magnetic atomic spin associated to each magnetic +atom in the system +* integrating the equations of motion for the coupled spin-lattice system +* implementing magnetic pair interactions and magnetic forces +* thermostating and applying a transverse damping to the magnetic spins +* computing and outputing magnetic quantities + +The different options provided by this package are explained in the +LAMMPS documentation. + +Once you have successfully built LAMMPS with this package, you can test +it using one of the input files provided from the examples/SPIN dir: + +./lmp_serial < lammps/examples/SPIN/cobalt_hcp/in.spin.cobalt_hcp + + +== Credits and license == + +The person who created this package is Julien Tranchida (jtranch at +sandia.gov). You can contact him if you have questions. diff --git a/src/SPIN/atom_vec_spin.h b/src/SPIN/atom_vec_spin.h index 4177a4c8608b13dcd54d50480b9e851d35eb0a04..99d4a86189f68bce2494bf874dbb153e8cc8e3a6 100644 --- a/src/SPIN/atom_vec_spin.h +++ b/src/SPIN/atom_vec_spin.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef ATOM_CLASS AtomStyle(spin,AtomVecSpin) diff --git a/src/SPIN/compute_spin.h b/src/SPIN/compute_spin.h index 872694cd89fece87c3eebbf5aebab2fc056ba3f4..59f0ce2876d3e718d08c88bece84475a74dc04ef 100644 --- a/src/SPIN/compute_spin.h +++ b/src/SPIN/compute_spin.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef COMPUTE_CLASS ComputeStyle(compute/spin,ComputeSpin) diff --git a/src/SPIN/fix_langevin_spin.h b/src/SPIN/fix_langevin_spin.h index ac7506c4c5c1c6da5ecc5f6c43a7506784a1acae..0f90a77c1445c7afb092fdd042d3b048a96b56d5 100644 --- a/src/SPIN/fix_langevin_spin.h +++ b/src/SPIN/fix_langevin_spin.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef FIX_CLASS FixStyle(langevin/spin,FixLangevinSpin) diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 2d3f73cd7776b36fbe626a6c19aaa4d454f1073a..2f13bdd6503b63f3e38b09d6b80d46e9405bb4e1 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -27,6 +27,7 @@ #include "atom.h" #include "atom_vec.h" +#include "citeme.h" #include "error.h" #include "fix_precession_spin.h" #include "fix_nve_spin.h" @@ -50,6 +51,16 @@ using namespace FixConst; using namespace MathConst; using namespace MathExtra; +static const char cite_fix_nve_spin[] = + "fix nve/spin command:\n\n" + "@article{tranchida2018massively,\n" + "title={Massively parallel symplectic algorithm for coupled magnetic spin " + "dynamics and molecular dynamics},\n" + "author={Tranchida, J and Plimpton, SJ and Thibaudeau, P and Thompson, AP},\n" + "journal={arXiv preprint arXiv:1801.10233},\n" + "year={2018}\n" + "}\n\n"; + enum{NONE}; /* ---------------------------------------------------------------------- */ @@ -60,7 +71,8 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : backward_stacks(NULL), forward_stacks(NULL), pair(NULL), spin_pairs(NULL) { - + if (lmp->citeme) lmp->citeme->add(cite_fix_nve_spin); + if (narg < 4) error->all(FLERR,"Illegal fix/NVE/spin command"); time_integrate = 1; diff --git a/src/SPIN/fix_nve_spin.h b/src/SPIN/fix_nve_spin.h index 686c391299b3161599cd22c3389186ea4c1c9b13..c7d88ef60501ab2d54b7c119bb7c2e73ea86f8a2 100644 --- a/src/SPIN/fix_nve_spin.h +++ b/src/SPIN/fix_nve_spin.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef FIX_CLASS FixStyle(nve/spin,FixNVESpin) diff --git a/src/SPIN/fix_precession_spin.h b/src/SPIN/fix_precession_spin.h index 5e1047ff670a097ecee609af787394af677cb9bf..2a616b61f0842a673965facc70003d1c354d7c89 100644 --- a/src/SPIN/fix_precession_spin.h +++ b/src/SPIN/fix_precession_spin.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef FIX_CLASS FixStyle(precession/spin,FixPrecessionSpin) diff --git a/src/SPIN/pair_spin.h b/src/SPIN/pair_spin.h index e71f2eb117fef30667731677630afb1f341e7504..94f8433108fddc557e1251c87d0a8370206fda02 100755 --- a/src/SPIN/pair_spin.h +++ b/src/SPIN/pair_spin.h @@ -11,8 +11,12 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#ifdef PAIR_CLASS + PairStyle(pair/spin,PairSpin) +#else + #ifndef LMP_PAIR_SPIN_H #define LMP_PAIR_SPIN_H diff --git a/src/SPIN/pair_spin_dmi.cpp b/src/SPIN/pair_spin_dmi.cpp index 99b41f77c8eb9d3af490875566188889ee41670d..7f07efc9c8bf83c678bac5a512eeed33530d86aa 100755 --- a/src/SPIN/pair_spin_dmi.cpp +++ b/src/SPIN/pair_spin_dmi.cpp @@ -101,7 +101,6 @@ void PairSpinDmi::settings(int narg, char **arg) void PairSpinDmi::coeff(int narg, char **arg) { -// const double hbar = force->hplanck/MY_2PI; if (!allocated) allocate(); @@ -130,15 +129,16 @@ void PairSpinDmi::coeff(int narg, char **arg) for (int j = MAX(jlo,i); j <= jhi; j++) { cut_spin_dmi[i][j] = rij; DM[i][j] = dm; - v_dmx[i][j] = dmx; - v_dmy[i][j] = dmy; - v_dmz[i][j] = dmz; + v_dmx[i][j] = dmx * dm; + v_dmy[i][j] = dmy * dm; + v_dmz[i][j] = dmz * dm; setflag[i][j] = 1; count++; } } if (count == 0) error->all(FLERR,"Incorrect args in pair_style command"); + } /* ---------------------------------------------------------------------- @@ -351,7 +351,6 @@ void PairSpinDmi::compute_single_pair(int ii, double fmi[3]) } - /* ---------------------------------------------------------------------- compute the dmi interaction between spin i and spin j ------------------------------------------------------------------------- */ @@ -368,13 +367,16 @@ void PairSpinDmi::compute_dmi(int i, int j, double rsq, double fmi[3], double sp if (rsq <= local_cut2) { double dmix, dmiy, dmiz; - dmix = DM[itype][jtype] * v_dmx[itype][jtype]; - dmiy = DM[itype][jtype] * v_dmy[itype][jtype]; - dmiz = DM[itype][jtype] * v_dmz[itype][jtype]; + //dmix = DM[itype][jtype] * v_dmx[itype][jtype]; + //dmiy = DM[itype][jtype] * v_dmy[itype][jtype]; + //dmiz = DM[itype][jtype] * v_dmz[itype][jtype]; + dmix = v_dmx[itype][jtype]; + dmiy = v_dmy[itype][jtype]; + dmiz = v_dmz[itype][jtype]; - fmi[0] -= (spj[1]*dmiz - spj[2]*dmiy); - fmi[1] -= (spj[2]*dmix - spj[0]*dmiz); - fmi[2] -= (spj[0]*dmiy - spj[1]*dmix); + fmi[0] += (spj[1]*dmiz - spj[2]*dmiy); + fmi[1] += (spj[2]*dmix - spj[0]*dmiz); + fmi[2] += (spj[0]*dmiy - spj[1]*dmix); } } @@ -390,7 +392,6 @@ void PairSpinDmi::compute_dmi_mech(int i, int j, double fi[3], double spi[3], do fi[2] += 0.0; } - /* ---------------------------------------------------------------------- allocate all arrays ------------------------------------------------------------------------- */ diff --git a/src/SPIN/pair_spin_dmi.h b/src/SPIN/pair_spin_dmi.h index da9f8d1494a5d33e30a6d546cb251c599fceb206..fda38b48fdb750958b8c07df601da0439c455e27 100755 --- a/src/SPIN/pair_spin_dmi.h +++ b/src/SPIN/pair_spin_dmi.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef PAIR_CLASS PairStyle(spin/dmi,PairSpinDmi) diff --git a/src/SPIN/pair_spin_exchange.h b/src/SPIN/pair_spin_exchange.h index 66750743bbd359a3286e37a3fde040165d27a747..07536a18bd88e97332c7b165ebf2bff0fb0e837c 100755 --- a/src/SPIN/pair_spin_exchange.h +++ b/src/SPIN/pair_spin_exchange.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef PAIR_CLASS PairStyle(spin/exchange,PairSpinExchange) diff --git a/src/SPIN/pair_spin_me.h b/src/SPIN/pair_spin_me.h index 58ea6b3eda98585c585f2d4288ee3b8755556616..cd1a93ad6e94601688b21876cc2d12285a785d9f 100755 --- a/src/SPIN/pair_spin_me.h +++ b/src/SPIN/pair_spin_me.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef PAIR_CLASS PairStyle(spin/me,PairSpinMe) diff --git a/src/SPIN/pair_spin_neel.h b/src/SPIN/pair_spin_neel.h index 114e1843dea7a2b2563166b5d9fe5cfb959c68bf..d59f92df26b18bc527af478d50eba9e8d40cd7b1 100755 --- a/src/SPIN/pair_spin_neel.h +++ b/src/SPIN/pair_spin_neel.h @@ -11,16 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------ - Contributing authors: Julien Tranchida (SNL) - Aidan Thompson (SNL) - - Please cite the related publication: - Tranchida, J., Plimpton, S. J., Thibaudeau, P., & Thompson, A. P. (2018). - Massively parallel symplectic algorithm for coupled magnetic spin dynamics - and molecular dynamics. arXiv preprint arXiv:1801.10233. -------------------------------------------------------------------------- */ - #ifdef PAIR_CLASS PairStyle(spin/neel,PairSpinNeel)