Skip to content

MicroMagnetic.jl

A Julia package for classical spin dynamics and micromagnetic simulations with GPU support.

MicroMagnetic

Features

  • Supports classical spin dynamics and micromagnetic simulations.
  • Compatible with CPU and multiple GPU platforms, including NVIDIA, AMD, Intel, and Apple GPUs.
  • Supports both double and single precision.
  • Supports Monte Carlo simulations for atomistic models.
  • Implements the Nudged-Elastic-Band method for energy barrier computations.
  • Supports Spin-transfer torques, including Zhang-Li and Slonczewski models.
  • Incorporates various energy terms and thermal fluctuations.
  • Supports constructive solid geometry.
  • Supports periodic boundary conditions.
  • Easily extensible to add new features.

Quick start

Assuming we have a cylindrical FeG sample with a diameter of 100 nm and a height of 40 nm, we want to know its magnetization distribution and the stray field around it. We can use the following script:
julia
using MicroMagnetic
@using_gpu() # Import available GPU packages such as CUDA, AMDGPU, oneAPI, or Metal

# Define simulation parameters
args = (
    task = "Relax", # Specify the type of simulation task (e.g., relaxation)
    mesh = FDMesh(nx=80, ny=80, nz=30, dx=2e-9, dy=2e-9, dz=2e-9), # Define the mesh grid for the simulation with 80x80x30 cells and 2 nm cell size
    shape = Cylinder(radius=50e-9, height=40e-9), # Define the shape of the magnetic structure as a cylinder with 50 nm radius and 40 nm height
    Ms = 3.87e5, # Set the saturation magnetization (A/m)
    A = 8.78e-12, # Set the exchange stiffness constant (J/m)
    D = 1.58e-3, # Set the Dzyaloshinskii-Moriya interaction constant (J/m^2)
    demag = true, # Enable demagnetization effects in the simulation
    m0 = (1,1,1), # Set the initial magnetization direction
    stopping_dmdt = 0.1 # Set the stopping criterion for the simulation based on the rate of change of magnetization dynamics
);

# Run the simulation with the specified parameters
sim = sim_with(args); 

# Save the magnetization and the stray field into vtk.
save_vtk(sim, "m_demag", fields=["demag"])

The magnetization and the stray field around the cylindrical sample are stored in m_demag.vts, which can be opened using Paraview.

Structure of MicroMagnetic.jl