22#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
27#include "constraints/Constraints.hpp"
28#include "constraints/HomogeneousMagneticField.hpp"
32#include "system/System.hpp"
33#include "thermostat.hpp"
71 auto const phi = x[0];
72 auto const *params =
reinterpret_cast<double const *
>(
my_func_data);
73 auto const theta = params[0];
74 auto const h = params[1];
78 return -0.5 - 0.5 * std::cos(2. * (
phi -
theta)) - 2. *
h * std::cos(
phi);
96 double dt,
double const &
noise) {
98 auto constexpr pi = std::numbers::pi_v<double>;
103 auto const h_crit = std::pow(std::pow(std::sin(
theta), 2. / 3.) +
104 std::pow(std::cos(
theta), 2. / 3.),
106 nlopt::opt
opt(nlopt::LD_MMA, 1);
107 double params[] = {
theta,
h};
112 std::vector<double>
phi(1);
132 auto const b_min = (b1 < b2) ? b1 : b2;
162 for (
auto const &constraint : constraints) {
163 auto ptr = std::dynamic_pointer_cast<HomogeneousMagneticField>(constraint);
180 double const kT,
double const noise) {
181 auto constexpr pi = std::numbers::pi_v<double>;
185 auto const kernel = [&](
bool flip) {
220 double const kT,
double const noise) {
222 auto constexpr pi = std::numbers::pi_v<double>;
242 auto const [quat, dipm] =
260 auto const kT = thermostat->kT;
261 cell_structure->for_each_local_particle([&](
Particle &p) {
270 auto const &langevin = *thermostat->langevin;
271 auto const e_k =
p_ref->calc_director();
274 Random::philox_4_uint64s<RNGSalt::THERMAL_STONER_WOHLFARTH>(
275 langevin.rng_counter(), langevin.rng_seed(), p.
id());
Vector implementation and trait types for boost qvm interoperability.
This file contains everything related to the global cell structure / cell system.
void integrate_magnetodynamics()
Run magnetodynamics update for local virtual particles.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
__device__ void vector_product(float const *a, float const *b, float *out)
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
constexpr double uniform(uint64_t in)
Uniformly map unsigned integer to double.
Random number generation using Philox.
Particle * get_reference_particle(CellStructure &cell_structure, Particle const &p)
Get real particle tracked by a virtual site.
This file contains all subroutines required to process rotational motion.
std::pair< Utils::Quaternion< double >, double > convert_dip_to_quat(const Utils::Vector3d &dip)
convert a dipole moment to quaternions and dipolar strength
static double phi_objective(unsigned n, const double *x, double *grad, void *my_func_data)
Objective (energy) function for the Stoner-Wohlfarth phi minimisation.
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 constexpr double eps_abs
static constexpr double eps_rel
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-Wohlfa...
static auto get_external_field(Constraints::Constraints const &constraints)
Collect external homogeneous magnetic field from active constraints.
static constexpr double eps_phi
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.
Struct holding all information for one particle.
auto const & dip_fld() const
auto const & magnetic_anisotropy_energy() const
auto const & stoner_wohlfarth_phi_0() const
auto const & magnetic_anisotropy_field_inv() const
auto const & quat() const
auto const & stoner_wohlfarth_tau0_inv() const
auto const & saturation_magnetization() const
auto const & stoner_wohlfarth_dt_incr() const
auto const & stoner_wohlfarth_is_enabled() const
auto const & dipm() const