{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Dynamics equation\n", "\n", "The dynamics of magnetisation field $\\mathbf{m}$, without external excitations (e.g. spin-polarised current) is governed by the Landau-Lifshitz-Gilbert (LLG) equation\n", "\n", "$$\\frac{d\\mathbf{m}}{dt} = \\underbrace{-\\gamma_{0}(\\mathbf{m} \\times \\mathbf{H}_\\text{eff})}_\\text{precession} + \\underbrace{\\alpha\\left(\\mathbf{m} \\times \\frac{d\\mathbf{m}}{dt}\\right)}_\\text{damping},$$\n", "\n", "where $\\gamma_{0} = \\mu_{0}\\gamma$ is the gyromagnetic ratio, $\\alpha$ is the Gilbert damping, and $\\mathbf{H}_\\text{eff} = -\\frac{1}{\\mu_{0}M_\\text{s}}\\frac{\\delta w(\\mathbf{m})}{\\delta \\mathbf{m}}$ is the effective field. It consists of two terms: precession and damping. In this tutorial, we will explore some basic properties of this equation to understand how to define it in simulations.\n", "\n", "## Macrospin\n", "\n", "We will study the simplest \"zero-dimensional\" case - macrospin. In the first step, after we import necessary modules and create the mesh which consists of a single discretisation cell." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import oommfc as mc\n", "import discretisedfield as df\n", "import micromagneticmodel as mm\n", "\n", "# Define a macrospin mesh (i.e. one discretisation cell).\n", "p1 = (0, 0, 0) # first point of the mesh domain (m)\n", "p2 = (1e-9, 1e-9, 1e-9) # second point of the mesh domain (m)\n", "n = (1, 1, 1) # discretisation cell size (m)\n", "\n", "region = df.Region(p1=p1, p2=p2)\n", "mesh = df.Mesh(region=region, n=n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, we can create a micromagnetic system object." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "system = mm.System(name=\"macrospin\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us assume we have a simple Hamiltonian which consists of only Zeeman energy term\n", "\n", "$$w = -\\mu_{0}M_\\text{s}\\mathbf{m}\\cdot\\mathbf{H},$$\n", "\n", "where $M_\\text{s}$ is the saturation magnetisation, $\\mu_{0}$ is the magnetic constant, and $\\mathbf{H}$ is the external magnetic field. We apply the external magnetic field with magnitude $H = 2 \\times 10^{6} \\,\\text{A}\\,\\text{m}^{-1}$ in the positive $z$ direction." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "H = (0, 0, 2e6) # external magnetic field (A/m)\n", "system.energy = mm.Zeeman(H=H)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Dynamics simulation\n", "\n", "In the next step we can define the system's dynamics. Let us assume we have $\\gamma_{0} = 2.211 \\times 10^{5} \\,\\text{m}\\,\\text{A}^{-1}\\,\\text{s}^{-1}$ and $\\alpha=0.1$." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "gamma0 = 2.211e5 # gyromagnetic ratio (m/As)\n", "alpha = 0.1 # Gilbert damping\n", "\n", "system.dynamics = mm.Precession(gamma0=gamma0) + mm.Damping(alpha=alpha)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To check what is our dynamics equation:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$-\\frac{\\gamma_{0}}{1 + \\alpha^{2}} \\mathbf{m} \\times \\mathbf{H}_\\text{eff}-\\frac{\\gamma_{0} \\alpha}{1 + \\alpha^{2}} \\mathbf{m} \\times (\\mathbf{m} \\times \\mathbf{H}_\\text{eff})$" ], "text/plain": [ "Precession(gamma0=221100.0) + Damping(alpha=0.1)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "system.dynamics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before we start running time evolution simulations, we need to initialise the magnetisation. In this case, our magnetisation is pointing in the positive $x$ direction with $M_\\text{s} = 8 \\times 10^{6} \\,\\text{A}\\,\\text{m}^{-1}$. The magnetisation is defined using `Field` class from the `discretisedfield` package we imported earlier." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "initial_m = (1, 0, 0) # vector in x direction\n", "Ms = 8e6 # magnetisation saturation (A/m)\n", "\n", "system.m = df.Field(mesh, nvdim=3, value=initial_m, norm=Ms)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, we can run the time evolution using `TimeDriver` for $t=0.1 \\,\\text{ns}$ and save the magnetisation configuration in $n=200$ steps." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running OOMMF (ExeOOMMFRunner)[2023/10/23 15:56]... (0.8 s)\n" ] } ], "source": [ "td = mc.TimeDriver()\n", "td.drive(system, t=0.1e-9, n=200)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulation results\n", "\n", "How different system parameters vary with time, we can inspect by showing the system's datatable." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | E | \n", "E_calc_count | \n", "max_dm/dt | \n", "dE/dt | \n", "delta_E | \n", "E_zeeman | \n", "iteration | \n", "stage_iteration | \n", "stage | \n", "mx | \n", "my | \n", "mz | \n", "last_time_step | \n", "t | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "-4.400762e-22 | \n", "37.0 | \n", "25204.415522 | \n", "-8.798712e-10 | \n", "-3.269612e-22 | \n", "-4.400762e-22 | \n", "6.0 | \n", "6.0 | \n", "0.0 | \n", "0.975901 | \n", "0.217115 | \n", "0.021888 | \n", "3.715017e-13 | \n", "5.000000e-13 | \n", "
1 | \n", "-8.797309e-22 | \n", "44.0 | \n", "25186.311578 | \n", "-8.786077e-10 | \n", "-4.396547e-22 | \n", "-8.797309e-22 | \n", "8.0 | \n", "1.0 | \n", "1.0 | \n", "0.904810 | \n", "0.423562 | \n", "0.043754 | \n", "5.000000e-13 | \n", "1.000000e-12 | \n", "
2 | \n", "-1.318544e-21 | \n", "51.0 | \n", "25156.186455 | \n", "-8.765071e-10 | \n", "-4.388134e-22 | \n", "-1.318544e-21 | \n", "10.0 | \n", "1.0 | \n", "2.0 | \n", "0.790286 | \n", "0.609218 | \n", "0.065579 | \n", "5.000000e-13 | \n", "1.500000e-12 | \n", "
3 | \n", "-1.756100e-21 | \n", "58.0 | \n", "25114.112032 | \n", "-8.735776e-10 | \n", "-4.375555e-22 | \n", "-1.756100e-21 | \n", "12.0 | \n", "1.0 | \n", "3.0 | \n", "0.638055 | \n", "0.765021 | \n", "0.087341 | \n", "5.000000e-13 | \n", "2.000000e-12 | \n", "
4 | \n", "-2.191985e-21 | \n", "65.0 | \n", "25060.188355 | \n", "-8.698302e-10 | \n", "-4.358857e-22 | \n", "-2.191985e-21 | \n", "14.0 | \n", "1.0 | \n", "4.0 | \n", "0.455710 | \n", "0.883427 | \n", "0.109020 | \n", "5.000000e-13 | \n", "2.500000e-12 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
195 | \n", "-2.009865e-20 | \n", "1402.0 | \n", "690.438568 | \n", "-6.602614e-13 | \n", "-3.374608e-25 | \n", "-2.009865e-20 | \n", "396.0 | \n", "1.0 | \n", "195.0 | \n", "0.013011 | \n", "-0.024099 | \n", "0.999625 | \n", "5.000000e-13 | \n", "9.800000e-11 | \n", "
196 | \n", "-2.009897e-20 | \n", "1409.0 | \n", "675.493807 | \n", "-6.319876e-13 | \n", "-3.230101e-25 | \n", "-2.009897e-20 | \n", "398.0 | \n", "1.0 | \n", "196.0 | \n", "0.017545 | \n", "-0.020251 | \n", "0.999641 | \n", "5.000000e-13 | \n", "9.850000e-11 | \n", "
197 | \n", "-2.009928e-20 | \n", "1416.0 | \n", "660.872303 | \n", "-6.049242e-13 | \n", "-3.091780e-25 | \n", "-2.009928e-20 | \n", "400.0 | \n", "1.0 | \n", "197.0 | \n", "0.021059 | \n", "-0.015612 | \n", "0.999656 | \n", "5.000000e-13 | \n", "9.900000e-11 | \n", "
198 | \n", "-2.009958e-20 | \n", "1423.0 | \n", "646.567078 | \n", "-5.790193e-13 | \n", "-2.959381e-25 | \n", "-2.009958e-20 | \n", "402.0 | \n", "1.0 | \n", "198.0 | \n", "0.023428 | \n", "-0.010435 | \n", "0.999671 | \n", "5.000000e-13 | \n", "9.950000e-11 | \n", "
199 | \n", "-2.009986e-20 | \n", "1430.0 | \n", "632.571305 | \n", "-5.542233e-13 | \n", "-2.832649e-25 | \n", "-2.009986e-20 | \n", "404.0 | \n", "1.0 | \n", "199.0 | \n", "0.024591 | \n", "-0.004988 | \n", "0.999685 | \n", "5.000000e-13 | \n", "1.000000e-10 | \n", "
200 rows × 14 columns
\n", "