File field.hpp

namespace field

Contains functions for computing magnetic fields.

Functions for computing effective fields from anistoropy and a range of time-varying applied fields.

Author
Oliver Laslett
Date
2017

Enums

enum options

Values:

SINE
SQUARE
CONSTANT

Functions

template <typename… T>
std::function<double(double)> bind_field_function(std::function<double(double, T...)> func, T... bind_args, )

Bind field parameters into a field function.

Field functions are of the form std::function(double<double>) This function allows additional arguments to be bound to functions and returns the function as a field function.

Return
field function
Parameters
  • func: function to bind
  • bind_args: arguments to bind

double constant(const double t, const double h)

A constant applied field.

A simple placeholder function representing a constant field. Always returns the same value.

Return
the constant field amplitude at all values of time
Parameters
  • t: time (parameter has no effect)
  • h: applied field amplitude

double sinusoidal(const double t, const double h, const double f)

A sinusoidal alternating applied field.

Returns the value of a sinusoidally varying field at any given time.

Return
the value of the varying applied field at time t
Parameters
  • t: time
  • h: applied field amplitude
  • f: applied field frequency

double square(const double t, const double h, const double f)

A square wave switching applied field.

An alternating applied field with a square shape centred around zero. i.e. it alternates between values -h and h

Return
the value of the square wave applied field at time t
Parameters
  • t: time
  • h: applied field amplitude
  • f: applied field frequency

double square_fourier(const double t, const double h, const double f, const size_t n_compononents)

A square wave applied field of finite Fourier components.

An approximate square wave is computed from a finite number of Fourier components. The square wave alternates between -h and h.

Return
the value of the square wave applied field at time t
Parameters
  • t: time
  • h: applied field amplitude
  • f: applied field frequency
  • n_components: number of Fourier components to compute

void multi_add_applied_Z_field_function(double *heff, const std::function<double(const double)> &hfunc, const double t, const size_t N, )

Add the applied field in the z direction.

void uniaxial_anisotropy(double *h_anis, const double *magnetisation, const double *anis_axis)

Effective field contribution from uniaxial anisotropy.

The effective field experienced by a single particle with a uniaxial anisotropy.

Parameters
  • h_anis: effective field [length 3]
  • mag: the magnetisation of the particle of [length 3]
  • axis: the anisotropy axis of the particle [length 3]

void multi_add_uniaxial_anisotropy(double *h, const double *states, const double *axes, const double *k_reduced, const size_t N)

Add the uniaxial anisotropy term term to the field of N particles.

Parameters
  • h: effective field incremented with the anisotropy term
  • states: magnetic state of the particles (length 3N)
  • axes: anisotropy axis of each particle (length 3N)
  • k_reduced: the reduced anisotropy constant for each particle (length N)
  • N: number of particles

void uniaxial_anisotropy_jacobian(double *jac, const double *axis)

Jacobian of the uniaxial anisotropy effective field term.

The Jacobian of a particle’s uniaxial anisotropy with respect to it’s magnetisation value. \(J_h(m) = \frac{\partial h(m)}{\partial m}\)

Parameters
  • jac: the jacobian of the effective field [length 3x3]
  • axis: the anisotropy axis of the particle [length 3]

void multi_add_uniaxial_anisotropy_jacobian(double *jac, const double *axes, const double *anis, const size_t N)

Jacobian of the uniaxial anisotropy effective field term for many particles.

The Jacobian of a particle’s uniaxial anisotropy with respect to it’s magnetisation value. \(J_h(m) = \frac{\partial h(m)}{\partial m}\)

Parameters
  • jac: the jacobian of the effective field [length 3Nx3N]
  • axis: the anisotropy axis of the particle [length 3N]
  • N: number of particles

void multi_add_dipolar(double *field, const double ms, const double k_av, const double *v_reduced, const double *mag, const double *dists, const double *dist_cubes, const size_t N)

field is Nx3 and is the effective field on each particle ms is the same for all particles k_av is the average anisotropy constant for all particles v_reduced is the reduced volume of each particle v_av is the average volume for all particles mag is Nx3 long and is the magnetic state of each of the N particles dists is NxNx3 long and is the distance between each pair of particles N is the number of particles dist_cubes is NxN and is the reduced cubed distance between each pair

double dipolar_prefactor(const double ms, const double k_av)

Prefactor term (helper for field::dipolar)

prefactor is \(\frac{\mu0 M_s^2}{8\pi\bar{K}}\)

Return
prefactor term
Parameters
  • ms: saturation magnetisation
  • k_av: average anisotropy constant for system

void dipolar_add_p2p_term(double *out, const double vj, const double rij3, const double *mj, const double *dist, const double prefactor)
void zero_all_field_terms(double *h, const size_t N)

Set all N values of the field to zero.

Parameters
  • h: pointer to array of N doubles will all be set to zero
  • N: number of elements in array