diff --git a/doc/src/Section_howto.txt b/doc/src/Section_howto.txt index e852e0abd4..6ee2eecda9 100644 --- a/doc/src/Section_howto.txt +++ b/doc/src/Section_howto.txt @@ -36,7 +36,8 @@ This section describes how to perform common tasks using LAMMPS. 6.24 "Setting parameters for the kspace_style pppm/disp command"_#howto_24 6.25 "Polarizable models"_#howto_25 6.26 "Adiabatic core/shell model"_#howto_26 -6.27 "Drude induced dipoles"_#howto_27 :all(b) +6.27 "Drude induced dipoles"_#howto_27 +6.28 "Magnetic spins"_#howto_28 :all(b) The example input scripts included in the LAMMPS distribution and highlighted in "Section 7"_Section_example.html also show how to @@ -2837,6 +2838,7 @@ CS-Info # header of additional section :pre 4 2 5 3 6 3 +The interactions between the 7 4 8 4 (...) :pre @@ -2906,6 +2908,54 @@ with a Coulomb pair style. It may be useful to use {coul/long/cs} or similar from the CORESHELL package if the core and Drude particle come too close, which can cause numerical issues. +:line + +6.28 Magnetic spins :link(howto_28),h4 + +The magnetic spin simualtions are enabled by the SPIN package, whose +implementation is detailed in "Tranchida"_#Tranchida7. + +The model representents the simulation of atomic magnetic spins coupled +to lattice vibrations. The dynamics of those magnetic spins can be used +to simulate a broad range a phenomena related to magneto-elasticity, or +or to study the influence of defects on the magnetic properties of +materials. + +The magnetic spins are interacting with each others and with the +lattice via pair interactions. Typically, the magnetic exchange +interaction can be defined using the +"pair/spin/exchange"_pair_spin_exchange.html command. This exchange +applies a magnetic torque to a given spin, considering the orientation +of its neighboring spins and their relative distances. +It also applies a force on the atoms as a function of the spin +orientations and their associated inter-atomic distances. + +The command "fix precession/spin"_fix_precession_spin.html allows to +apply a constant magnetic torque on all the spins in the system. This +torque can be an external magnetic field (Zeeman interaction), or an +uniaxial magnetic anisotropy. + +A Langevin thermostat can be applied to those magnetic spins using +"fix langevin/spin"_fix_langevin_spin.html. Typically, this thermostat +can be coupled to another Langevin thermostat applied to the atoms +using "fix langevin"_fix_langevin.html in order to simulate +thermostated spin-lattice system. + +The magnetic Gilbert damping can also be applied using "fix +langevin/spin"_fix_langevin_spin.html. It allows to either dissipate +the thermal energy of the Langevin thermostat, or to perform a +relaxation of the magnetic configuration toward an equilibrium state. + +All the computed magnetic properties can be outputed by two main +commands. The first one is "compute spin"_compute_spin.html, that +enables to evaluate magnetic averaged quantities, such as the total +magnetization of the system along x, y, or z, the spin temperature, or +the magnetic energy. The second command is "compute +property/atom"_compute_property_atom.html. It enables to output all the +per atom magnetic quantities. Typically, the orientation of a given +magnetic spin, or the magnetic force acting on this spin. + + :line :line @@ -2957,3 +3007,7 @@ Phys, 79, 926 (1983). :link(howto-Lamoureux) [(Lamoureux and Roux)] G. Lamoureux, B. Roux, J. Chem. Phys 119, 3025 (2003) + +:link(Tranchida7) +[(Tranchida)] Tranchida, Plimpton, Thibaudeau and Thompson, +arXiv preprint arXiv:1801.10233, (2018). diff --git a/doc/src/compute_property_atom.txt b/doc/src/compute_property_atom.txt index bac19918ba..c0970d5121 100644 --- a/doc/src/compute_property_atom.txt +++ b/doc/src/compute_property_atom.txt @@ -19,6 +19,7 @@ input = one or more atom attributes :l x, y, z, xs, ys, zs, xu, yu, zu, ix, iy, iz, vx, vy, vz, fx, fy, fz, q, mux, muy, muz, mu, + sp, spx, spy, spz, fmx, fmy, fmz, radius, diameter, omegax, omegay, omegaz, angmomx, angmomy, angmomz, shapex,shapey, shapez, @@ -46,6 +47,9 @@ input = one or more atom attributes :l q = atom charge mux,muy,muz = orientation of dipole moment of atom mu = magnitude of dipole moment of atom + sp = atomic magnetic spin moment + spx, spy, spz = direction of the atomic magnetic spin + fmx, fmy, fmz = magnetic force radius,diameter = radius,diameter of spherical particle omegax,omegay,omegaz = angular velocity of spherical particle angmomx,angmomy,angmomz = angular momentum of aspherical particle @@ -82,7 +86,8 @@ input = one or more atom attributes :l compute 1 all property/atom xs vx fx mux compute 2 all property/atom type -compute 1 all property/atom ix iy iz :pre +compute 1 all property/atom ix iy iz +compute 3 all property/atom sp spx spy spz :pre [Description:] @@ -152,6 +157,10 @@ The vector or array values will be in whatever "units"_units.html the corresponding attribute is in, e.g. velocity units for vx, charge units for q, etc. +For the spin quantities, sp is in the units of the Bohr magneton, spx, +spy, and spz are adimentional quantities, and fmx, fmy and fmz are +given in rad.THz. + [Restrictions:] none [Related commands:] diff --git a/doc/src/fix_integration_spin.txt b/doc/src/fix_nve_spin.txt similarity index 78% rename from doc/src/fix_integration_spin.txt rename to doc/src/fix_nve_spin.txt index 4538e22284..4f25003c5f 100644 --- a/doc/src/fix_integration_spin.txt +++ b/doc/src/fix_nve_spin.txt @@ -6,22 +6,22 @@ :line -fix integration/spin command :h3 +fix nve/spin command :h3 [Syntax:] -fix ID group-ID integration/spin keyword values :pre +fix ID group-ID nve/spin keyword values :pre ID, group-ID are documented in "fix"_fix.html command :ulb,l -integration/spin = style name of this fix command :l +nve/spin = style name of this fix command :l keyword = {lattice} :l {lattice} value = {no} or {yes} :pre :ule [Examples:] -fix 3 all integration/spin lattice yes -fix 1 all integration/spin lattice no :pre +fix 3 all nve/spin lattice yes +fix 1 all nve/spin lattice no :pre [Description:] @@ -32,7 +32,7 @@ of fixed atoms (lattice = no), or if atoms are moving (lattice = yes). By default (lattice = yes), a spin-lattice integration is performed. -The {integration/spin} fix applies a Suzuki-Trotter decomposition to +The {nve/spin} fix applies a Suzuki-Trotter decomposition to the equations of motion of the spin lattice system, following the scheme: :c,image(Eqs/fix_integration_spin_stdecomposition.jpg) @@ -51,9 +51,8 @@ This fix style can only be used if LAMMPS was built with the SPIN package. See the "Making LAMMPS"_Section_start.html#start_3 section for more info on packages. -When the spin algorithm is used for serial calculations, it is -necessary to define a map via the atom_modify command. -Typically, by adding the command: +To use the spin algorithm, it is necessary to define a map with +the atom_modify command. Typically, by adding the command: atom_modify map array :pre diff --git a/doc/src/fix_force_spin.txt b/doc/src/fix_precession_spin.txt similarity index 85% rename from doc/src/fix_force_spin.txt rename to doc/src/fix_precession_spin.txt index 6ab207fda3..9ef7a7230c 100644 --- a/doc/src/fix_force_spin.txt +++ b/doc/src/fix_precession_spin.txt @@ -6,14 +6,14 @@ :line -fix force/spin command :h3 +fix precession/spin command :h3 [Syntax:] -fix ID group force/spin style args :pre +fix ID group precession/spin style args :pre ID, group are documented in "fix"_fix.html command :ulb,l -force/spin = style name of this fix command :l +precession/spin = style name of this fix command :l style = {zeeman} or {aniso} :l {zeeman} args = H x y z H = intensity of the magnetic field (in Tesla) @@ -25,8 +25,8 @@ style = {zeeman} or {aniso} :l [Examples:] -fix 1 all force/spin zeeman 0.1 0.0 0.0 1.0 -fix 1 all force/spin aniso 0.001 0.0 0.0 1.0 :pre +fix 1 all precession/spin zeeman 0.1 0.0 0.0 1.0 +fix 1 all precession/spin aniso 0.001 0.0 0.0 1.0 :pre [Description:] @@ -61,7 +61,7 @@ files"_restart.html. [Restrictions:] -The {force/spin} style is part of the SPIN package. +The {precession/spin} style is part of the SPIN package. This style is only enabled if LAMMPS was built with this package, and if the atom_style "spin" was declared. See the "Making LAMMPS"_Section_start.html#start_3 section for more info. diff --git a/examples/SPIN/cobalt_hcp/in.spin.cobalt_hcp b/examples/SPIN/cobalt_hcp/in.spin.cobalt_hcp index 9076cd6d6c..bd807e4efe 100644 --- a/examples/SPIN/cobalt_hcp/in.spin.cobalt_hcp +++ b/examples/SPIN/cobalt_hcp/in.spin.cobalt_hcp @@ -54,4 +54,4 @@ thermo 10 compute outsp all property/atom spx spy spz sp fmx fmy fmz dump 100 all custom 1 dump_cobalt_hcp.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] -run 20000 +run 2000 diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 0660032e02..a842335cd3 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -67,6 +67,8 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : sector_flag = NONE; mech_flag = 1; + nlocal_max = 0; + // checking if map array or hash is defined if (atom->map_style == 0) @@ -220,11 +222,14 @@ void FixNVESpin::init() if (sector_flag) sectoring(); // init. size tables of stacking variables (sectoring) - + + nlocal_max = atom->nlocal; stack_head = memory->grow(stack_head,nsectors,"NVE/spin:stack_head"); stack_foot = memory->grow(stack_foot,nsectors,"NVE/spin:stack_foot"); - forward_stacks = memory->grow(forward_stacks,atom->nmax,"NVE/spin:forward_stacks"); - backward_stacks = memory->grow(backward_stacks,atom->nmax,"NVE/spin:backward_stacks"); + forward_stacks = memory->grow(forward_stacks,nlocal_max,"NVE/spin:forward_stacks"); + backward_stacks = memory->grow(backward_stacks,nlocal_max,"NVE/spin:backward_stacks"); + if (nlocal_max == 0) + error->all(FLERR,"Incorrect value of nlocal_max"); } @@ -359,6 +364,12 @@ void FixNVESpin::pre_neighbor() double **x = atom->x; int nlocal = atom->nlocal; + if (nlocal_max < nlocal) { // grow linked lists if necessary + nlocal_max = nlocal; + forward_stacks = memory->grow(forward_stacks,nlocal_max,"NVE/spin:forward_stacks"); + backward_stacks = memory->grow(backward_stacks,nlocal_max,"NVE/spin:backward_stacks"); + } + for (int j = 0; j < nsectors; j++) { stack_head[j] = -1; stack_foot[j] = -1; @@ -455,7 +466,7 @@ void FixNVESpin::ComputeInteractionsSpin(int ii) temp_cut = 0.0; - if (exch_flag) { // exchange + if (exch_flag) { // exchange temp_cut = lockpairspinexchange->cut_spin_exchange[itype][jtype]; cut_2 = temp_cut*temp_cut; if (rsq <= cut_2) { @@ -474,7 +485,7 @@ void FixNVESpin::ComputeInteractionsSpin(int ii) } } - if (soc_dmi_flag) { // soc_dmi + if (soc_dmi_flag) { // soc_dmi temp_cut = lockpairspinsocdmi->cut_soc_dmi[itype][jtype]; cut_2 = temp_cut*temp_cut; if (rsq <= cut_2) { @@ -482,7 +493,7 @@ void FixNVESpin::ComputeInteractionsSpin(int ii) } } - if (me_flag) { // me + if (me_flag) { // me temp_cut = lockpairspinme->cut_spin_me[itype][jtype]; cut_2 = temp_cut*temp_cut; if (rsq <= cut_2) { @@ -496,19 +507,19 @@ void FixNVESpin::ComputeInteractionsSpin(int ii) } if (magprecession_flag) { // magnetic precession - if (zeeman_flag) { // zeeman + if (zeeman_flag) { // zeeman lockprecessionspin->compute_zeeman(i,fmi); } - if (aniso_flag) { // aniso + if (aniso_flag) { // aniso lockprecessionspin->compute_anisotropy(i,spi,fmi); } } - if (maglangevin_flag) { // mag. langevin - if (tdamp_flag) { // transverse damping + if (maglangevin_flag) { // mag. langevin + if (tdamp_flag) { // transverse damping locklangevinspin->add_tdamping(spi,fmi); } - if (temp_flag) { // spin temperature + if (temp_flag) { // spin temperature locklangevinspin->add_temperature(fmi); } } @@ -522,7 +533,7 @@ void FixNVESpin::ComputeInteractionsSpin(int ii) } /* ---------------------------------------------------------------------- - divide each domain into sectors + divide each domain into 8 sectors ---------------------------------------------------------------------- */ void FixNVESpin::sectoring() diff --git a/src/SPIN/fix_nve_spin.h b/src/SPIN/fix_nve_spin.h index 3fd96a67d4..c3cda17848 100644 --- a/src/SPIN/fix_nve_spin.h +++ b/src/SPIN/fix_nve_spin.h @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------ + Contributing authors: Julien Tranchida (SNL) + Aidan Thompson (SNL) +------------------------------------------------------------------------- */ + #ifdef FIX_CLASS FixStyle(nve/spin,FixNVESpin) @@ -44,13 +49,15 @@ class FixNVESpin : public Fix { void pre_neighbor(); protected: - int sector_flag; // sector_flag = 0 if serial algorithm - // sector_flag = 1 if parallel algorithm - int mech_flag; // mech_flag = 0 if spins only - // mech_flag = 1 if spin-lattice calc. + int sector_flag; // sector_flag = 0 if serial algorithm + // sector_flag = 1 if parallel algorithm + int mech_flag; // mech_flag = 0 if spins only + // mech_flag = 1 if spin-lattice calc. - double dtv, dtf, dts; // velocity, force, and spin timesteps + double dtv, dtf, dts; // velocity, force, and spin timesteps + int nlocal_max; // max value of nlocal (for lists size) + int magpair_flag; // magnetic pair flags int exch_flag; int soc_neel_flag, soc_dmi_flag;