Thermal fluctuations
A finite temperature is modelled by including a stochastic field in the effective field, i.e. by integrating the stochastic Landau-Lifshitz equation. The temperature is specified per cell, so a temperature gradient or a partially heated sample can be modelled.
Matlab |
Python |
Description |
|---|---|---|
|
|
Temperature of every cell in K. A scalar is expanded to all cells. The default is zero, i.e. no thermal field. |
|
|
Seed for the random number generator, see Reproducible random numbers. |
The thermal field is switched on automatically whenever the temperature is
non-zero anywhere in the mesh (the test is T > 1e-15 K), and the solver
reports Including thermal noise. Two things then change:
a Gaussian random field is added to \(\mathbf{H}_\mathrm{eff}\), redrawn once per step of the integration time grid;
the magnetization is renormalised to \(|\mathbf{m}| = 1\) after every step, which prevents the thermal kicks from slowly inflating or deflating the magnetization.
The stochastic field
Each Cartesian component of the thermal field in cell \(i\) is drawn from a normal distribution with zero mean and standard deviation
where \(V_i\) is the volume of the cell, \(\Delta t\) is the spacing of the integration time grid, \(k_B\) is Boltzmann’s constant and \(\alpha_\mathrm{G}\) is the dimensionless Gilbert damping, recovered from the Landau-Lifshitz damping constant \(\alpha\) as the root \(\alpha_\mathrm{G} \leq 1\) of \(\alpha_\mathrm{G}^2 - (\gamma/\alpha)\alpha_\mathrm{G} + 1 = 0\).
Two consequences of the \(1/\sqrt{\Delta t}\) factor are worth keeping in mind:
The prefactor assumes a uniform time grid. The step used is the total simulated time divided by the number of unique times in the integration grid, i.e. the union of the output times
tand the convergence-check timest_conv. Adding times throught_convtherefore changes the effective temperature unless those times are already int.Because the field scales as \(1/\sqrt{V_i}\), a coarser mesh gives smaller fluctuations per cell, as it should: each cell then represents a larger, more strongly averaged volume.
Note
The thermal field requires the dynamic solver. The explicit solver computes equilibrium states at a sequence of constant applied fields and has no time axis for the fluctuations to live on. The prefactor is still allocated for all solver types, so no error is raised, but a thermal run with the explicit solver is not meaningful.
Reproducible random numbers
rng_seed seeds the Fortran random number generator that both the thermal
field and the demagnetization-field noise (CV) draw from. Its three regimes
are:
Value |
Behaviour |
|---|---|
|
The compiler default sequence is used. It is identical in every process and keeps advancing between solves within one process, so runs are neither reproducible nor independent. This preserves the behaviour of earlier MagTense versions. |
|
The generator is seeded deterministically from this value. The same seed reproduces a run exactly; different seeds give independent runs. This is what a reproducible test needs. |
|
The generator is seeded from the system clock, i.e. a fresh realisation on every run. This is what independent Monte-Carlo samples need. |
Note
The seed is applied inside Fortran. Seeding NumPy in a Python script has no
effect on the thermal field - only on quantities that Python itself draws,
such as a randomly initialised m0.
Validation
The temperature_test example (available for both Matlab and Python) checks
the implementation against theory. It simulates a collection of
non-interacting cells with no anisotropy, initially all magnetised along z, and
compares the resulting angular distribution with the analytical solution of the
corresponding diffusion problem,
and it extracts the diffusion constant from \(\langle \cos\theta \rangle = e^{-2 D t}\). Since the cells are independent, the N cells are N samples of the same random walk, so the comparison is a Monte-Carlo one and its tolerances are set by sampling noise rather than by solver accuracy.