Skip to main content

CMTJ

PyPI pages-build-deployment Version License Streamlit PyPI Downloads

Table of contents

Short description

The cmtj name may be misleading -- the MTJ (Magnetic Tunnel Junctions) are not the only structures that may be simulated. The library allows for macromagnetic simulation of various multilayer spintronic structures. The package uses C++ implementation of (s)LLGS (stochastic Landau-Lifschitz-Gilbert-Slonczewski) equation with various field contributions included for instance: anisotropy, interlayer exchange coupling, demagnetisation, dipole fields etc. It is also possible to connect devices in parallel or in series to have electrically coupled arrays.

What can you simulate?

Below is a brief list of examples (it's not exhaustive! Check the docs for more).

Magnetic devices:

  • Magnetic Tunnel Junctions
    • Voltage-Driven Magnetic Tunnel Junctions
    • Spin-Torque Oscillators
    • VCMA sensors and devices
    • Magnetic Tunnel Junction Arrays
  • SOT devices
    • Current-Driven SOT
  • Advanced device coupling
  • Reservoirs (dipole coupling)
  • Electrically coupled MTJs
  • Base equations
    • Landau-Lifshitz-Gilbert-Slonczewski equation
    • Stochastic Landau-Lifshitz-Gilbert-Slonczewski equation
    • Landau-Lifshitz-Gilbert-Bloch equation
  • Domain wall motion

Experimental methods:

Some of the experimental methods available:

  • PIMM
  • Spin-Diode
  • CIMS
  • R(H), M(H)

Web GUI

Check out the streamlit hosted demo here. You can simulate:

  • PIMM spectra and Spin-Diode spectra
  • Try some optimization fitting
  • Fit multi-domain or multi-level M(H) or R(H) loops in Domain mode

Let us know if you have any issues with the demo.

Quickstart

Installation 🚀

The recommended way is to use the pip package manager and virtualenv (or conda). Installation is as easy as doing:

Recommendation Use the following flags when installing/compiling from start. They provide optimum performance, but even without them, cmtj is very fast.

export LDFLAGS="-O3"
export CXXFLAGS="-O3 -march=native -ffast-math"
  1. With virtualenv (recommended):
$(bash) python -m venv .my-venv
$(bash) source .my-venv/bin/activate
$(.my-venv) python -m pip install cmtj
  1. Straight from pip:
python3 -m pip install cmtj
  1. Straight from source:
python3 -m pip install git+https://github.com/LemurPwned/cmtj.git
  1. Clone the repository:
git clone --recurse-submodules https://github.com/LemurPwned/cmtj.git
python3 -m pip install .

if your git is older, you may need to use --recursive instead of --recurse-submodules.

Extra dependencies

The package requires (if utils subpackage is used):

- numpy
- scipy
- matplotlib

Documentation and examples

Documentation: https://lemurpwned.github.io/cmtj. There are many examples available, check out the examples section in the docs

Claude Code skill

This repo ships a Claude Code skill (skills/cmtj-simulation) that teaches it how to write correct CMTJ simulations (units, layer setup, drivers, solvers, reproducibility). Install it with the skills CLI:

npx skills add LemurPwned/cmtj --skill cmtj-simulation

Or, from a local checkout of this repo:

npx skills add . --skill cmtj-simulation

Add -g to install globally instead of just this project. See skills/cmtj-simulation/SKILL.md for what it covers.

Extensions

There's a GUI version available! If you wish to conduct a subset of simulations, mainly for experimental modelling, please see the PyMag project. It uses CMTJ as a backend for fast computation.

Citing

We would appreciate citing either of the listed work if you decide to use the project or using the cite button on the right hand side panel of the repository:

cmtj: Simulation package for analysis of multilayer spintronic devices

@article{mojsiejuk_cmtj_2023,
	title = {cmtj: Simulation package for analysis of multilayer spintronic devices},
	volume = {9},
	issn = {2057-3960},
	url = {https://www.nature.com/articles/s41524-023-01002-x},
	doi = {10.1038/s41524-023-01002-x},
	pages = {54},
	number = {1},
	journaltitle = {npj Comput Mater},
	author = {Mojsiejuk, Jakub and Ziętek, Sławomir and Grochot, Krzysztof and Skowroński, Witold and Stobiecki, Tomasz},
	date = {2023-04-06},
}

Development

Acknowledgements

Many thanks to professor Jack Sankey for his help with the development of thermal contributions, with inspiration from the macrospinmob project.

Contributions

All contributions are welcome, please leave an issue if you've encountered any trouble with setup or running the library.

Docker

In the docker directory there's a Dockerfile that can be used to build a docker image with the library installed. Dockerfile.app is used for streamlit development.

Precommit

There's a .pre-commit-config.yaml that does some basic python and cpp lints and checks. More static analysis to come in the future. This may be run with:

pre-commit run -v

or

pre-commit run -a (or --files core/* cmtj/*)

Documentation builds

Note For stub generation add __init__.py to the cmtj directory.

There are a couple of stages to building the documentation

  1. Build Doxygen documentation
    doxygen Doxyfile
    
    This is mostly for the C++ documentation. Future changes may couple C++ and Python docs.
  2. Build stubs The stubgen is pybind11-stubgen or mypy stubgen with the latter being preferred now. Before running the stubgen, make sure to install the package with:
    python3 -m pip install .
    
    avoid using -e flag as it may cause issues with the stubgen. Then to generate, for instance, Stack module stubs we can do:
    stubgen -m cmtj.stack -o target-stub-dir/
    
    or
    python3 -c "import mypy.stubgen; mypy.stubgen.main(['-p', 'cmtj.stack', '-o', 'target-stub-dir/'])"
    
    More info here: https://mypy.readthedocs.io/en/stable/stubgen.html.
  3. Parse stubs to Markdown. This stage is done by running: python3 docs/docgen.py The deployment of the documentation is done via:
    mkdocs gh-deploy
    
    But first, worth a check:
    mkdocs serve
    

Metadata

Release files for cmtj 1.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmtj 1.14.0
File Size Uploaded
cmtj-1.14.0.tar.gz 11.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for cmtj 1.14.0
File
cmtj-1.14.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
cmtj-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
cmtj-1.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
cmtj-1.14.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
cmtj-1.14.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
cmtj-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
cmtj-1.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
cmtj-1.14.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
cmtj-1.14.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
cmtj-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
cmtj-1.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
cmtj-1.14.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 21.0 MB

Release files / cmtj-1.14.0.tar.gz

Download URL cmtj-1.14.0.tar.gz
Size 11.9 MB
Tags Source
SHA-256 checksum
How to use checksums
4ee5dfebc842056ca254a2267cf017529146f8205e70b7b968002c87c91f89eb
BLAKE2b-256 checksum
How to use checksums
89727987ddd4d60838fd40b360fc59c63a68c21187f1112c5399ffa0968e2e31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cmtj-1.14.0-cp313-cp313-win_amd64.whl

Download URL cmtj-1.14.0-cp313-cp313-win_amd64.whl
Size 552.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
dfeea8ec6b79b9838364cbebbfcbcf484fc27db91e62d80924dfa418928c37d3
BLAKE2b-256 checksum
How to use checksums
4fb634f8fcd43b0c0efed3a54a1137ab2138e563962a999a9c250e9812fa5550
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / cmtj-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL cmtj-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
20b6bfcbdd16896fe7ba0f46fbfc6c303c895038a55fff50f97e7a1d20e7d6de
BLAKE2b-256 checksum
How to use checksums
da9879f5fa36492a9f727ec9af754b1e7a34ee18c2f82353c1f161fdf7c82a95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cmtj-1.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cmtj-1.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 478.0 kB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
eab7591c865a67c93876525399f3bba9d7c97248a283d27795e4317c3dfbfb22
BLAKE2b-256 checksum
How to use checksums
2a8ae1f1d1255ee33d620fdb3cd4c07b8bd4998c54c9876335dcb6e162d59d4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cmtj-1.14.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL cmtj-1.14.0-cp313-cp313-macosx_11_0_arm64.whl
Size 469.6 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
28fdbd47829e1b4e37e5909769c9ead3b18cb2e8e685b23d39b840df608985bd
BLAKE2b-256 checksum
How to use checksums
83eac49853c613e49a357e2a789776d85a8642a2c94ae714515fe0d927225281
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / cmtj-1.14.0-cp312-cp312-win_amd64.whl

Download URL cmtj-1.14.0-cp312-cp312-win_amd64.whl
Size 552.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a403203f74bcd4b31c46c54c81b106138fbcf9d11706162cc3133858aa3eeedc
BLAKE2b-256 checksum
How to use checksums
937a7103d33781f753c1249a98af2f19417208cf13298569acbd10f79694f2fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / cmtj-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL cmtj-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
79dec48bbdfa6ba6b2c55503f1f1fc67cdb1b2f7375a052dd1725d60814c3cf0
BLAKE2b-256 checksum
How to use checksums
2dcf834c0a5ef6940026788fcdb189c0d8c76b72c83373b439fb91f899431397
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cmtj-1.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cmtj-1.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 477.5 kB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
93c1588cc1bd76c81f61c9ae0190c98dbb8326553ce327e9fc2294413297fbfa
BLAKE2b-256 checksum
How to use checksums
cdf0a129a47f9c173b807ff534306a67e570c11e04b68a8dc1487f2cbe89991e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cmtj-1.14.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL cmtj-1.14.0-cp312-cp312-macosx_11_0_arm64.whl
Size 468.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
eded8c115f2a0bd6f1ff5b428d0f5a0c6b7ff46462b81fad025fb6ad211714a3
BLAKE2b-256 checksum
How to use checksums
8ab477996c81329cbea07e6de5e4ce7a65d7a3d2d007cdedbfd721bb5e3da40e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / cmtj-1.14.0-cp311-cp311-win_amd64.whl

Download URL cmtj-1.14.0-cp311-cp311-win_amd64.whl
Size 551.5 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
870ae8f824b0c246a6dbd6bc4ec45ccd6a2114653c512182e30f1fc96598fc40
BLAKE2b-256 checksum
How to use checksums
29ba0d8b8ad15f58b9d0770852ef2b97a4fae90d2d78e9de87644905b4aaf5b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / cmtj-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL cmtj-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
d1b3d866effa084dc8e544b24f61faf17961a367d6fd8273d08e24159fbf6bb5
BLAKE2b-256 checksum
How to use checksums
20d346eaffcd85cd9e5024eb717203c75a25489e1e0a4aedd4f3ee221c8e2f0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cmtj-1.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cmtj-1.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 482.8 kB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
887aaa94a9a5e80a925c2984be38bf48d810265a506263d05a81ee9fc35a3b51
BLAKE2b-256 checksum
How to use checksums
1db20063d8ddfff97285d8547d283b8913483fb56408bc66f6a5c8ae565d69ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cmtj-1.14.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL cmtj-1.14.0-cp311-cp311-macosx_11_0_arm64.whl
Size 468.3 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
220de055e40171481389fc69b569475b7fe670ad5864ed7184ef41e9ef577b8a
BLAKE2b-256 checksum
How to use checksums
3bcd8bb46ca0ac0946120821eb92b24c1eb889f4699bae584cac17297b9b3180
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page