ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
stoner_wohlfarth_thermal.cpp File Reference
#include <config/config.hpp>
#include "magnetostatics/stoner_wohlfarth_thermal.hpp"
#include "cell_system/CellStructure.hpp"
#include "cells.hpp"
#include "constraints/Constraints.hpp"
#include "constraints/HomogeneousMagneticField.hpp"
#include "errorhandling.hpp"
#include "random.hpp"
#include "rotation.hpp"
#include "thermostat.hpp"
#include "virtual_sites/relative.hpp"
#include <nlopt.hpp>
#include <cassert>
#include <cmath>
#include <numbers>
#include <tuple>
#include <utility>
#include <vector>
+ Include dependency graph for stoner_wohlfarth_thermal.cpp:

Go to the source code of this file.

Functions

static double phi_objective (unsigned n, const double *x, double *grad, void *my_func_data)
 Objective (energy) function for the Stoner-Wohlfarth phi minimisation.
 
static double get_phi_at_energy_min (double theta, double h, double phi0, double ani_param, double tau0_inv, double dt, double const &noise)
 Find the in-plane angle phi corresponding to the correct energy minimum for the thermal Stoner-Wohlfarth particles.
 
static auto get_external_field ()
 Collect external homogeneous magnetic field from active constraints.
 
void stoner_wohlfarth_no_field (Particle &p, Utils::Vector3d const &e_k, double const kT, double const noise)
 Simplified Stoner-Wohlfarth update in field-free case.
 
static void stoner_wohlfarth_main (Particle &p, Utils::Vector3d const &e_k, Utils::Vector3d const &ext_fld_dpl, double const kT, double const noise)
 Update virtual site dipole moment according to the full in-field (incl.
 
void run_magnetodynamics (CellStructure &cell_structure, Thermostat::Thermostat const &thermostat)
 Run magnetodynamics update for local virtual particles.
 

Variables

static constexpr double eps_phi = 1e-3
 
static constexpr double eps_abs = 1e-15
 
static constexpr double eps_rel = 1e-15
 

Function Documentation

◆ get_external_field()

static auto get_external_field ( )
static

Collect external homogeneous magnetic field from active constraints.

Iterate over constraints and sum the homogeneous magnetic field vectors provided by Constraints::HomogeneousMagneticField objects.

Returns
The total external homogeneous magnetic field.

Definition at line 156 of file stoner_wohlfarth_thermal.cpp.

References System::get_system(), and stream.

Referenced by run_magnetodynamics().

◆ get_phi_at_energy_min()

static double get_phi_at_energy_min ( double  theta,
double  h,
double  phi0,
double  ani_param,
double  tau0_inv,
double  dt,
double const noise 
)
static

Find the in-plane angle phi corresponding to the correct energy minimum for the thermal Stoner-Wohlfarth particles.

Parameters
thetaAngle between anisotropy director and external field (rad).
hReduced field (external + dipolar) normalised by H_k.
phi0Initial in-plane angle guess (rad).
ani_paramInverse thermal energy factor ( \(1/(k_B T V)\) scaled).
tau0_invAttempt frequency inverse (1/tau0).
dtTime increment for switching probability.
noiseUniform random number in (0,1) used for the kinetic MC step.
Returns
In-plane angle phi in range \( [0,2\pi) \).

Definition at line 91 of file stoner_wohlfarth_thermal.cpp.

References eps_abs, eps_phi, eps_rel, params, phi_objective(), and stream.

Referenced by stoner_wohlfarth_main().

◆ phi_objective()

static double phi_objective ( unsigned  n,
const double x,
double grad,
void my_func_data 
)
static

Objective (energy) function for the Stoner-Wohlfarth phi minimisation.

Evaluate the magnetic energy (normalized by the anisotropy field) for a given in-plane angle phi according to Eq. 5 in [32]. Assumes minima lie in the plane phi = zeta and uses trig identities to reduce the expression.

Parameters
nNumber of optimization variables (should be 1: phi).
xPointer to variables; x[0] is the angle phi.
gradIf non-null, gradient is written to grad[0].
my_func_dataPointer to a double[2] array with {theta, h}.
Returns
Energy value for the given phi.

Definition at line 66 of file stoner_wohlfarth_thermal.cpp.

References params, and stream.

Referenced by get_phi_at_energy_min().

◆ run_magnetodynamics()

void run_magnetodynamics ( CellStructure cell_structure,
Thermostat::Thermostat const thermostat 
)

Run magnetodynamics update for local virtual particles.

Iterate over local particles and update the dipole moment of virtual particles according to the thermal Stoner-Wohlfarth model. Collect active homogeneous external magnetic fields from constraints and add the per-particle dipolar contribution before performing either the simplified no-field update or the full thermal Stoner-Wohlfarth update.

Parameters
cell_structureCellStructure providing access to local particles.
thermostatthermostat used to access Philox RNG state and seeds.

Definition at line 258 of file stoner_wohlfarth_thermal.cpp.

References Particle::dip_fld(), CellStructure::for_each_local_particle(), get_external_field(), get_reference_particle(), Particle::id(), Particle::is_virtual(), Thermostat::Thermostat::kT, Thermostat::Thermostat::langevin, Particle::stoner_wohlfarth_is_enabled(), stoner_wohlfarth_main(), stoner_wohlfarth_no_field(), stream, THERMO_LANGEVIN, Thermostat::Thermostat::thermo_switch, and Utils::uniform().

Referenced by System::System::integrate().

◆ stoner_wohlfarth_main()

static void stoner_wohlfarth_main ( Particle p,
Utils::Vector3d const e_k,
Utils::Vector3d const ext_fld_dpl,
double const  kT,
double const  noise 
)
static

Update virtual site dipole moment according to the full in-field (incl.

dipole field) thermal Stoner-Wohlfarth model (incl. the kinetic MC step)

Parameters
[in,out]pVirtual particle to update (modified).
e_kAnisotropy director of the reference particle.
ext_fld_dplExternal homogeneous magnetic field + total dipolar field acting on the particle.
kTThermal energy from thermostat.
noiseUniform random number in (0,1) used for the kinetic MC step.

Definition at line 216 of file stoner_wohlfarth_thermal.cpp.

References convert_dip_to_quat(), Particle::dipm(), get_phi_at_energy_min(), Particle::magnetic_anisotropy_energy(), Particle::magnetic_anisotropy_field_inv(), Particle::quat(), Particle::saturation_magnetization(), Particle::stoner_wohlfarth_dt_incr(), Particle::stoner_wohlfarth_phi_0(), Particle::stoner_wohlfarth_tau0_inv(), stream, and vector_product().

Referenced by run_magnetodynamics().

◆ stoner_wohlfarth_no_field()

void stoner_wohlfarth_no_field ( Particle p,
Utils::Vector3d const e_k,
double const  kT,
double const  noise 
)

Simplified Stoner-Wohlfarth update in field-free case.

Parameters
[in,out]pVirtual particle to update.
e_kAnisotropy director of the reference particle.
kTThermal energy from thermostat.
noiseUniform random number in (0,1) used for the kinetic MC step.

Definition at line 177 of file stoner_wohlfarth_thermal.cpp.

References convert_dip_to_quat(), Particle::dipm(), Particle::magnetic_anisotropy_energy(), Particle::quat(), Particle::saturation_magnetization(), Particle::stoner_wohlfarth_dt_incr(), Particle::stoner_wohlfarth_phi_0(), Particle::stoner_wohlfarth_tau0_inv(), and stream.

Referenced by run_magnetodynamics().

Variable Documentation

◆ eps_abs

constexpr double eps_abs = 1e-15
staticconstexpr

Definition at line 48 of file stoner_wohlfarth_thermal.cpp.

Referenced by get_phi_at_energy_min().

◆ eps_phi

constexpr double eps_phi = 1e-3
staticconstexpr

Definition at line 46 of file stoner_wohlfarth_thermal.cpp.

Referenced by get_phi_at_energy_min().

◆ eps_rel

constexpr double eps_rel = 1e-15
staticconstexpr

Definition at line 50 of file stoner_wohlfarth_thermal.cpp.

Referenced by get_phi_at_energy_min().