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.

If you're interested in reinforcement learning control of spintronic devices (spin-torque oscillators, perpendicular switching, skyrmion control, VCMA sensors), see cmtj-rl -- Gym environments and training configs built on top of cmtj, using stable-baselines3.

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.15.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.15.0
File Size Uploaded Provenance
cmtj-1.15.0.tar.gz 11.9 MB Without provenance Details

Built distributions (wheels)

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

Total release size: 24.4 MB

Release files / cmtj-1.15.0.tar.gz

Download URL cmtj-1.15.0.tar.gz
Size 11.9 MB
Tags Source
SHA-256 checksum
How to use checksums
2fa5502812151f8986a90ef9410eb70013622eb8dc23a713a3f74e5f14251285
BLAKE2b-256 checksum
How to use checksums
7b8c9d11716dbd7261797a2e6889b8b4686b938ed3d894b5e40cd0c65c79e2ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / cmtj-1.15.0-cp314-cp314-win_amd64.whl

Download URL cmtj-1.15.0-cp314-cp314-win_amd64.whl
Size 592.4 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
15a9c654a9fca4b53b0fd7d6cac6a0186ba46098776e269589437865dce605da
BLAKE2b-256 checksum
How to use checksums
d47b3ca3894faf25d5909898ff9aa626e07d291e72f407be26e8e748a1a16f55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / cmtj-1.15.0-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL cmtj-1.15.0-cp314-cp314-musllinux_1_2_x86_64.whl
Size 1.6 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
8da181cea3cf4195e5aa797d5c5c013557f18da6763dcefeb944d3d8e00a20cd
BLAKE2b-256 checksum
How to use checksums
e11a59f7a914d84ef43d09ecd3874b580ad8c8950ec6bd74379436e85f79538d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / cmtj-1.15.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cmtj-1.15.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 505.3 kB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
445c4dcd14812391f16b072988f93d367d9afd05a2ee212bb8fa583c333fd66a
BLAKE2b-256 checksum
How to use checksums
5a1a8b1692061644a8e46fc777b6361fb60942243290f2e41e2adba301cd5211
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / cmtj-1.15.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL cmtj-1.15.0-cp314-cp314-macosx_11_0_arm64.whl
Size 487.7 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
410a26e2575ad645cb79864f33bc02262b2a5b9ad398de5a789b909f11e4cb78
BLAKE2b-256 checksum
How to use checksums
de1e0ece0c70565dbdd6e11eeed4d188bb623be8034364e4f1793e8c7fc08f0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

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

Download URL cmtj-1.15.0-cp313-cp313-win_amd64.whl
Size 575.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f46534d596ad198333c926e9e763015ab78866c877a2056d7d92fafc9859b2f8
BLAKE2b-256 checksum
How to use checksums
7065d421d40dd0e9ab31f5e2cef80ec6bab83d97da8a7fea65582febc13cf627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

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

Download URL cmtj-1.15.0-cp313-cp313-musllinux_1_2_x86_64.whl
Size 1.6 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
a6b915cce686273f5654babfe4ddfd7ff67a255e5b7c84bf856892d70e1a672c
BLAKE2b-256 checksum
How to use checksums
cfa109c23b05d235e9a0756ae9d50938ffd2e3ed6d808b9a0ec6ed3fd53e5ff6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

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

Download URL cmtj-1.15.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 505.3 kB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0a986244c13230210485431a24eababec96a331ac964d4aaaeaf8b62b7bdf92a
BLAKE2b-256 checksum
How to use checksums
4847c372a1ecb995a2049685e52e329d81fa24ea086f7e5aed644eea27168925
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

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

Download URL cmtj-1.15.0-cp313-cp313-macosx_11_0_arm64.whl
Size 487.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7314fa385414b5f801416e9dd2ab3efe237656020e70d030c66e18792755c158
BLAKE2b-256 checksum
How to use checksums
b2913626c021956c378676ad12e107d44a6135c14008573d4519175f25bb9e86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

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

Download URL cmtj-1.15.0-cp312-cp312-win_amd64.whl
Size 575.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d4ce6723e6f5a0ccaf9faa32dcd7f40390c9084b0be0dae328007e7b6dd2fdf4
BLAKE2b-256 checksum
How to use checksums
d9f2a87e888d66c60afb37a0703de1adffadc85098b98bfa51dfe2482f5f516e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

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

Download URL cmtj-1.15.0-cp312-cp312-musllinux_1_2_x86_64.whl
Size 1.6 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
ff68decfd90c76762f4cf98fc6084d14f622b19f5e6030d8adcb0862eb61ef47
BLAKE2b-256 checksum
How to use checksums
188c88e11e92e1ef2ad7b9950f1555307ddfe7cd46d21b0b400482cdc96b73a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

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

Download URL cmtj-1.15.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 504.7 kB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ec2061f1e90ab2d178219cfd54efd05818fa55b5af3f142238977ea9fc056bac
BLAKE2b-256 checksum
How to use checksums
c434a905cd2456c22f8539642d9564803e07267df191462b9c03a7966a08afab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

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

Download URL cmtj-1.15.0-cp312-cp312-macosx_11_0_arm64.whl
Size 487.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8e49c72d1e64a33ddffda149b8d82548c099f8503e63f8658576404f4e667497
BLAKE2b-256 checksum
How to use checksums
5222d2d9d37e67c5b80cc575d69b4359ab7867c259cf0688d540520efc650304
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

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

Download URL cmtj-1.15.0-cp311-cp311-win_amd64.whl
Size 574.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
e0977e5901456c3dcbe8d7203fb3031a77ebe1dad3f714060bad91fcfd437be2
BLAKE2b-256 checksum
How to use checksums
599639651e45b0beb508da265467e3a86450ba0f2c5756c240bf09473cea8620
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

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

Download URL cmtj-1.15.0-cp311-cp311-musllinux_1_2_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
80763511b3868eabe1fc53a4376e8a97a928abc6b2c88d1334ecdcd32a4fc893
BLAKE2b-256 checksum
How to use checksums
dfcfeb34aa2b607cd51e2590e5cfb02a013667fb615296887dcc7f090f46696a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

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

Download URL cmtj-1.15.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 510.6 kB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3441db82adb5ef9175d9c92cd17c14b6b1cca88a3a26e4f7c332801cdfb84ea8
BLAKE2b-256 checksum
How to use checksums
00ded5e8cdbb6b15104d3f57569ffd64a60ba4dabd55f783ca6a59e165373963
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

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

Download URL cmtj-1.15.0-cp311-cp311-macosx_11_0_arm64.whl
Size 486.4 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4a50fa636973cff98dacbb079ce5e1a47dec07490f2704a942886346c416b203
BLAKE2b-256 checksum
How to use checksums
881b80465d0340b14244f5c93aebda25e7ca9fed4d157b545603056dcb2fd53a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for cmtj 1.15.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.15.0 This release

17 release files No provenance

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