Skip to main content

magnum.np finite-difference package for the solution of micromagnetic problems

Project description

magnum.np

Documentation Status

magnum.np is a Python library for the solution of micromagnetic problems with the finite-difference method. It implements state-of-the-art algorithms and is based on pytorch, which allows to seamlessly run code either on GPU or on CPU. Simulation scripts are written in Python which leads to very readable yet flexible code. Due to pytorch integration, extensive postprocessing can be done directly in the simulations scripts. Furthermore pytorch's autograd feature makes it possible to solve inverse problems without significant modifications of the code. This manual is meant to give you both a quick start and a reference to magnum.np.

Features

  • Explicit / Implicit time-integration of the Landau-Lifshitz-Gilbert Equation
  • Fast FFT Demagnetization-field computation optimized for small memory footprint
  • Fast FFT Oersted-field optimized for small memory footprint
  • Arbitrary Material Parameters variing in space and time
  • Spin-torque model by Zhang and Li, Slonczewski
  • Antiferromagnetic coupling layers (RKKY)
  • Dzyaloshinskii-Moriya interaction (interface, bulk, D2d)
  • String method for energy barrier computations
  • Sophisticated domain handling, e.g. for spatially varying material parameters
  • Seemingless VTK import / export via pyvista
  • Inverse Problems via pytorch's autograd feature

Example

The following demo code shows the solution of the MuMag Standard Problem #5 and can be found in the demos directory:

from magnumnp import *
import torch

Timer.enable()

# initialize state
n  = (40, 40, 1)
dx = (2.5e-9, 2.5e-9, 10e-9)
mesh = Mesh(n, dx)

state = State(mesh)
state.material = {
    "Ms": 8e5,
    "A": 1.3e-11,
    "alpha": 0.1,
    "xi": 0.05,
    "b": 72.17e-12
    }

# initialize magnetization that relaxes into s-state
state.m = state.Constant([0,0,0])
state.m[:20,:,:,1] = -1.
state.m[20:,:,:,1] = 1.
state.m[20,20,:,1] = 0.
state.m[20,20,:,2] = 1.

state.j = state.Tensor([1e12, 0, 0])

# initialize field terms
demag    = DemagField()
exchange = ExchangeField()
torque   = SpinTorqueZhangLi()

# initialize sstate
llg = LLGSolver([demag, exchange])
llg.relax(state)
write_vti(state.m, "data/m0.vti", state)

# perform integration with spin torque
llg = LLGSolver([demag, exchange, torque])
logger = ScalarLogger("data/m.dat", ['t', 'm'])
while state.t < 5e-9:
    llg.step(state, 1e-10)
    logger << state

Timer.print_report()

Documentation

The documentation is located in the doc directory and can be built using sphinx. For example the following commands build an HTML documentation of the actual source code.

cd doc
make html

Alternatively, the latest version of the documentation is always available on https://magnumnp-magnumnp.readthedocs-hosted.com/en/latest/

Citation

If you use magnum.np in your work or publication, please cite the following reference:

[1] Bruckner, Florian, et al. "magnum.np -- A pytorch based GPU enhanced Finite Difference Micromagnetic Simulation Framework for High Level Development and Inverse Design", to be published (2023).

Contributing

Contributions are gratefully accepted. The source code is hosted on www.gitlab.com/magnum.np/magnum.np. If you have any issues or question, just open an issue via gitlab.com. To contribute code, fork our repository on gitlab.com and create a corresponding merge request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magnumnp-1.0.4.tar.gz (53.1 kB view details)

Uploaded Source

Built Distribution

magnumnp-1.0.4-py3-none-any.whl (75.1 kB view details)

Uploaded Python 3

File details

Details for the file magnumnp-1.0.4.tar.gz.

File metadata

  • Download URL: magnumnp-1.0.4.tar.gz
  • Upload date:
  • Size: 53.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for magnumnp-1.0.4.tar.gz
Algorithm Hash digest
SHA256 91b47377b75b8d2ad62305a4cc374ab3f8dab81961f604427ca9177a8a4c506e
MD5 ad644c3c1a753d1092102d94cfef554e
BLAKE2b-256 fde1e81659a0f0eec1b2994a4c83f4fafb55b310747ba36a9f4309babf5a36ab

See more details on using hashes here.

File details

Details for the file magnumnp-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: magnumnp-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 75.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for magnumnp-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a16712f8853a59395f5bc80124e6723d5ae01b9d1b695929148440697223c01f
MD5 df16ed431c9c92ee5ab09a7d26a583a5
BLAKE2b-256 95ca970cee31ebf348ec5db222603ebb15e46350524ca1dd99e2b23da47de5f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page