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 :rocket:

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
    

Download files

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

Source Distribution

cmtj-1.14.0.tar.gz (11.9 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cmtj-1.14.0-cp313-cp313-win_amd64.whl (552.6 kB view details)

Uploaded CPython 3.13Windows x86-64

cmtj-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

cmtj-1.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (478.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cmtj-1.14.0-cp313-cp313-macosx_11_0_arm64.whl (469.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cmtj-1.14.0-cp312-cp312-win_amd64.whl (552.6 kB view details)

Uploaded CPython 3.12Windows x86-64

cmtj-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

cmtj-1.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (477.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cmtj-1.14.0-cp312-cp312-macosx_11_0_arm64.whl (468.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cmtj-1.14.0-cp311-cp311-win_amd64.whl (551.5 kB view details)

Uploaded CPython 3.11Windows x86-64

cmtj-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

cmtj-1.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (482.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cmtj-1.14.0-cp311-cp311-macosx_11_0_arm64.whl (468.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file cmtj-1.14.0.tar.gz.

File metadata

  • Download URL: cmtj-1.14.0.tar.gz
  • Upload date:
  • Size: 11.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cmtj-1.14.0.tar.gz
Algorithm Hash digest
SHA256 4ee5dfebc842056ca254a2267cf017529146f8205e70b7b968002c87c91f89eb
MD5 89ecf2b76fde460e5f06ae78f52dfaff
BLAKE2b-256 89727987ddd4d60838fd40b360fc59c63a68c21187f1112c5399ffa0968e2e31

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: cmtj-1.14.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 552.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cmtj-1.14.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dfeea8ec6b79b9838364cbebbfcbcf484fc27db91e62d80924dfa418928c37d3
MD5 fafbb94cf5e081943d3d6e311578b1da
BLAKE2b-256 4fb634f8fcd43b0c0efed3a54a1137ab2138e563962a999a9c250e9812fa5550

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 20b6bfcbdd16896fe7ba0f46fbfc6c303c895038a55fff50f97e7a1d20e7d6de
MD5 e678b2fc45b338e9ffe66fe271a47740
BLAKE2b-256 da9879f5fa36492a9f727ec9af754b1e7a34ee18c2f82353c1f161fdf7c82a95

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eab7591c865a67c93876525399f3bba9d7c97248a283d27795e4317c3dfbfb22
MD5 85660dcd65b1dfec0ee02b71c2de294f
BLAKE2b-256 2a8ae1f1d1255ee33d620fdb3cd4c07b8bd4998c54c9876335dcb6e162d59d4d

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28fdbd47829e1b4e37e5909769c9ead3b18cb2e8e685b23d39b840df608985bd
MD5 61b8a8739d3ecd5c2821dbf967529e95
BLAKE2b-256 83eac49853c613e49a357e2a789776d85a8642a2c94ae714515fe0d927225281

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: cmtj-1.14.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 552.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cmtj-1.14.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a403203f74bcd4b31c46c54c81b106138fbcf9d11706162cc3133858aa3eeedc
MD5 3610c77ad44f60bbabca86d42e650e73
BLAKE2b-256 937a7103d33781f753c1249a98af2f19417208cf13298569acbd10f79694f2fc

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 79dec48bbdfa6ba6b2c55503f1f1fc67cdb1b2f7375a052dd1725d60814c3cf0
MD5 d30cd154bac6e4e6af3b656aee2c047a
BLAKE2b-256 2dcf834c0a5ef6940026788fcdb189c0d8c76b72c83373b439fb91f899431397

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 93c1588cc1bd76c81f61c9ae0190c98dbb8326553ce327e9fc2294413297fbfa
MD5 f1f29e637ce992ffbbf0229e369bbd63
BLAKE2b-256 cdf0a129a47f9c173b807ff534306a67e570c11e04b68a8dc1487f2cbe89991e

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eded8c115f2a0bd6f1ff5b428d0f5a0c6b7ff46462b81fad025fb6ad211714a3
MD5 bfb93b1722e49180a23aa464b63cc890
BLAKE2b-256 8ab477996c81329cbea07e6de5e4ce7a65d7a3d2d007cdedbfd721bb5e3da40e

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: cmtj-1.14.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 551.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cmtj-1.14.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 870ae8f824b0c246a6dbd6bc4ec45ccd6a2114653c512182e30f1fc96598fc40
MD5 3f0151643aa7093134c10e5a15b75c33
BLAKE2b-256 29ba0d8b8ad15f58b9d0770852ef2b97a4fae90d2d78e9de87644905b4aaf5b9

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d1b3d866effa084dc8e544b24f61faf17961a367d6fd8273d08e24159fbf6bb5
MD5 581f84c670353d13d52ba5c3c87caeaf
BLAKE2b-256 20d346eaffcd85cd9e5024eb717203c75a25489e1e0a4aedd4f3ee221c8e2f0c

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 887aaa94a9a5e80a925c2984be38bf48d810265a506263d05a81ee9fc35a3b51
MD5 18c6d17c6c50f75598837078c717ff68
BLAKE2b-256 1db20063d8ddfff97285d8547d283b8913483fb56408bc66f6a5c8ae565d69ec

See more details on using hashes here.

File details

Details for the file cmtj-1.14.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cmtj-1.14.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 220de055e40171481389fc69b569475b7fe670ad5864ed7184ef41e9ef577b8a
MD5 86de7ec59cdc0e7994db8b05bb409dfe
BLAKE2b-256 3bcd8bb46ca0ac0946120821eb92b24c1eb889f4699bae584cac17297b9b3180

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.14.0 This release

13 files

1.13.0

13 files

1.12.0

13 files

1.11.0

13 files

1.10.0

13 files

1.9.1

21 files

1.9.0

12 files

1.8.0

12 files

1.7.0

12 files

1.6.6

12 files

1.6.4

10 files

1.6.3

10 files

1.6.1

14 files

1.6.0

14 files

1.5.4

14 files

1.5.3

14 files

1.5.2

14 files

1.5.0

14 files

1.4.1

16 files

1.4.0

17 files

1.3.1

18 files

1.3.0

18 files

1.2.0

14 files

1.1.4

12 files

1.1.3

12 files

1.1.2

12 files

1.1.1

12 files

1.1.0

12 files

1.0.0

10 files

0.0.post1

1 file

Supported by

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