McPy is a specialized package designed for conducting Monte Carlo (Metropolis-Hastings) simulations in micromagnetics for studying magnetic quasiparticles. This has been developed as part of my Master's thesis to study the thermal stability of Bloch Points, a magnetic quasiparticle pivotal for modern data storage solutions. The package has been developed to allow non-zero temperature simulations in micromagnetics using Metropolis-Hastings.
McPy seamlessly integrates as an extension of Ubermag, an established micromagnetic simulation framework. Ubermag encompasses a suite of independent Python packages suitable for diverse physics simulations, including Computational Fluid Dynamics. While Ubermag already contains well-maintained energy minimisation solvers, the goal of McPy is to extend the capabilities of Ubermag by adding a non-perturbative approach to energy minimisation that has not been implemented till now.
- Developed in Python: Simulation conditions can be easily modified and run using Jupyter Notebook.
- Numba Accelerated: Utilizes the Numba "Just-in-time" compiler for performance comparable to C.
- 3D Finite Difference Micromagnetic Model: Enables continuous magnetization.
- Comprehensive Energy Calculations: Supports:
- Zeeman energy
- Uniaxial anisotropy energy
- Exchange energy
- Dzyaloshinskii-Moriya (DMI) energy
Here are several papers validating the effectiveness of Monte Carlo in this field
- Simulating anti-skyrmions on a lattice
- The skyrmion lattice phase in three-dimensional chiral magnets from Monte Carlo simulations
- Python==3.10.11
- Ubermag with default oommfc driver: Follow the installation guide at [Ubermag Installation](https://ubermag.github.io/installation.html)
- NumPy==1.24.3
- Numba==0.57.0
- cupy-cuda12x==12.1.0
Installation of the above packages can be achieved by running the following command
conda env create -f environment.yml
The following example is from Stable and Manuplable Bloch Point. This paper produced results using the Landau–Lifshitz–Gilbert (LLG) equation at absolute zero using a finite element solver. However, we will recreate the results using finite difference Monte Carlo at elevated temperatures.
- Importing Packages
import discretisedfield as df
import micromagneticmodel as mm
import oommfc as oc
from mcpy.system import MCDriver
- Defining the System parameters
# Magnetisation
Ms = 3.84e5
# Exchange energy constant
A = 8.78e-12
# System geometry
d = 125e-9
hb = 20e-9
ht = 12.5e-9
# Cell discretisation
cell = (5e-9, 5e-9, 2.5e-9)
# Bilayer disk
D_bloch = {'r1': -1.58e-3, 'r2': 1.58e-3, "r1:r2": 1.58e-9}
subregions = {'r1': df.Region(p1=(-d/2, -d/2, -hb), p2=(d/2, d/2, 0)), 'r2': df.Region(p1=(-d/2, -d/2, 0), p2=(d/2, d/2, ht))}
p1 = (-d/2, -d/2, -hb)
p2 = (d/2, d/2, ht)
- Creating Mesh and assigning Energy terms
# Creating mesh
mesh = df.Mesh(p1=p1, p2=p2, cell=cell, subregions=subregions)
def Ms_fun(point):
x, y, z = point
if x**2 + y**2 < (d/2)**2:
return Ms
else:
return 0
system = mm.System(name='bloch_point')
system.energy = mm.Exchange(A=A) + mm.DMI(D=D_bloch, crystalclass='T')
system.m = df.Field(mesh, dim=3, value=(0, 0, 1), norm=Ms_fun)
- Visualising the system
system.m.plane('z').mpl()
system.m.plane('x').mpl()
- Monte Carlo Simulation
# Optinal argument for annealing schedule
schedule={'type': 'FC', 'start_temp': 60, 'end_temp': 0.001, 'steps': 20}
# Defining Monte Carlo driver object
mc = MCDriver(system, schedule_name='bloch_point', schedule=schedule)
# 10 million Monte Carlo iterations
mc.drive(N=10000000)
# Visualising the Bloch Point
system.m.plane('z').mpl()
system.m.plane('x').mpl()
# We can observe a "Head-to-Head" Bloch point at the middle of the disk
To run the automated tests
python -m unittest tests.py
mcpy
: The folder containing the main packagesystem.py
: MCDriver and Grid classes to initial the Monte Carlo driver object and Grid objectdriver.py
: Python function to run the Monte Carlo simulationsenergies
numpy_energies.py
: Numpy optimised energy calculationsnumba_energies.py
: Numba optimised energy calculations
tests.py
: UnittestsNotebooks
:Instructios.ipynb
: Instructions on how to use the moduleCurie_temperature.ipynb
: Curie temperature calculationsbloch_point.ipynb
: Bloch point simulation
You can find the documentation at docs/html/index.html
.
The full outcomes and analysis can be found in the
final report of this project in reports
.
The scripts and documentation in this project are released under the MIT License