GithubHelp home page GithubHelp logo

lemurpwned / cmtj Goto Github PK

View Code? Open in Web Editor NEW
34.0 4.0 5.0 43.9 MB

A Python library for simulating multilayer magnetic structures.

Home Page: https://lemurpwned.github.io/cmtj/

License: GNU General Public License v2.0

Python 51.02% C++ 48.21% Dockerfile 0.13% Shell 0.06% CMake 0.54% Makefile 0.04%
macrospin magnetics python spintronics electronics condensed-phase-simulations mtj llg llgs stochastic-differential-equations

cmtj's Introduction

CMTJ

PyPI pages-build-deployment Version License Streamlit 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.

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:

  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 https://github.com/LemurPwned/cmtj.git
python3 -m pip install .

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

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

There are couple of stages to building the documentation

  1. Build Doxygen documentation
    doxygen Doxyfile
    
    This is mostly for the C++ documentation. Furture 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

cmtj's People

Contributors

dependabot[bot] avatar lemurpwned avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cmtj's Issues

Improve streamlit view

  • add frequency limiter
  • add ploty for interactive plots
  • fix optimizer
  • add the option to fix a parameter

Dipole junction coupling

Currently dipole coupling between two devices is possible if simulated as "one device".
An abstraction should be added to make this obvious -- for example by extension of the Stack e.g. DipoleCoupledStack.

Easier definition of the axial driver and a ScalarDriver

If we want to set a constant value for an Axial driver we need to do something like:

AxialDriver(ScalarDriver.getConstantDriver(H[0]),
            ScalarDriver.getConstantDriver(H[1]),
            ScalarDriver.getConstantDriver(H[2])))

instead, perhaps an easier way:

AxialDriver(*H)

Scalar Driver can also be assumed to be constant by default:

ScalarDriver(val) == ScalarDriver.getConstantDriver(val)

Add DMI interaction

There are use cases where DMI interaction is a good addition for the macrospin model.

Add some Colab examples

Sometimes, specifically for Windows builds, some users have issues installing and importing. Provide ready Colab examples to facilitate user adoption.

Custom Scalar Driver

Ability to define custom drivers in Python would be extremely useful for experimentation

Add relax function

A relax function would be useful.
It could either:

  1. Minimise the energy
  2. Minimise the torque

Dependency drivers

A set of drivers that depend on each other in a chain. E.g. a driver that changes its value based on a value of a chained/coupled driver.
Example: anisotropy driver that changes based on the value of the current driver.

Alias Driver functions

Driver functions should be aliased on both C++ and Python level for quicker reference and more reasonable naming convention.

Magnetisation perturbation

Implement perturbation in C++ for the magnetisation vector.

This is now implemented in procedures, but in Python. Should be repeated for C++.

Loose domains model

A model that's in-between macrospin and microspin -- where a set of coupled loose domains can be simulated as a set of macrospin vectors, adjusted for domain size.

HEBO optimisation

Integrate basic parallelism for HEBO optimisation in the optimisation submodule.

Add some tests

Test the following things:

  • Drivers.
  • Procedures.
  • Junction creation.

Using pytest and automatic tests for push is desirable.

Add AFM exchange coupling energy term to the SB model

$$E_\mathrm{AFM/FM} = -\mu_0M_st_\mathrm{FM}(H_\mathrm{EB} + H_\mathrm{w})\cos\phi_M$$
or from Meiklejohn-Bean model.

W. H. Meiklejohn and C. P. Bean. New Magnetic Anisotropy. Physical Review, 102(5):1413–1414, June
1956. Publisher: American Physical Society.

E. C. Stoner and E. P. Wohlfarth. Interpretation of High Coercivity in Ferromagnetic Materials. Na-
ture, 160(4071):650–651, November 1947. Number: 4071 Publisher: Nature Publishing Group.

CVector -- driver interaction

  • Passing a CVector to an axial driver automatically creates constant Driver.
  • CVectors should be subscriptable in Python as well.

Noise vector along an axis

Right now we sample noise in all directions -- allowing the user to specify just a single direction would be useful.

Scalar Driver to be defaulted

Override the scalar driver to be able to pass just a value and make it constant by default.
See if this can be propagated to the layer/junction api.

Code hints may not be visible

After pip installation the hints for the pyi.typed files may not be packaged properly and hence may not work properly.

Fix is to properly package typing hints with in the setup.cfg file.

Driver overhaul

Drivers need a smart-pointer overhaul to reduce complexity of adding a new scalar driver.

Swap the build system

Should switch to pyproject.toml if possible to avoid using ancient setup.py-based builds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.