Skip to main content

Python lib to calculate the magnetization of grains using the dipole cuboids model

Project description

DOI License: MIT Documentation Status

MMT Numerical Libraries: Dipole Cuboid Inversion

Python library for the calculation of magnetizations of magnetic grain sources, which are modelled as homogeneously magnetized particles, using an aggregation of cuboids. The method requires both the position of grains and magnetic surface data from the Micromagnetic Tomography project. This is achieved by:

  • Modelling the grains as aggregation of cuboids. This data is input into this library's main class called DipoleCuboidInversion.

  • Creating a forward matrix, which is also known as Green's matrix, that is obtained from the analytical formulation of the demagnetizing field of the cuboids. This matrix is multiplied by the degrees of freedom of the system which are the magnetizations of all the grains in the sample. The multiplication results into the magnetic field signal imprinted into the scan surface. The DipoleCuboidInversion class accepts the scan surface data as a text input file or Numpy matrix and has methods to calculate the Green's matrix.

  • Numerically inverting the scan surface data into the grains to obtain their individual magnetizations. The inversion is obtained by calculating the pseudo-inverse of the Green's matrix using Numpy or Scipy.

The mmt_dipole_cuboid_inversion library is optimized to populate the Green's matrix using either: Numba (compiled function), C parallelized with OpenMP (parallelization in the number of particles) or NVidia CUDA (high performance parallelization via the number of sensors in the scan surface).

Installation

Via PyPI and pip (note PyPI names use - instead of _)

pip install mmt-dipole-cuboid-inversion

Or you can use Poetry (recommended for development and CUDA, see below)

poetry install

Documentation

Please visit the official Documentation

CUDA

To build the code with the cuda option to populate the Green's matrix, it is necessary to define the CUDAHOME variable pointing to the cuda folder (assuming you have a functional cuda installation), e.g.

export CUDAHOME=/usr/local/cuda-11.5/

Then you can compile the code using poetry install.

Poetry

This library is built using the poetry library. After cloning the repository a virtualenv will be created automatically when running poetry install, unless you are already in a virtualenv, for example, creating one via conda. Within this environment it is possible to run and test the code using poetry run:

git clone https://github.com/Micromagnetic-Tomography/mmt_dipole_cuboid_inversion
cd mmt_dipole_cuboid_inversion
poetry install
poetry run python test/generate_single_dipole.py

For more information see this link. If the package requires to be built for publication (in the PyPI repository for example) or to be installed via pip, you can run

poetry build

This will produce a dist folder containing a tar.gz file and a wheel file. These files can be installed via pip.

PyPI

Install from PyPI. Only Linux and Windows builds are currently available.

pip install mmt-dipole-cuboid-inversion

How to use

You can call the class by doing:

import mmt_dipole_cuboid_inversion as dci

data = dci.DipoleCuboidInversion(...)
...

An Example notebook file with example data is included.

Cite

If you find this library useful please cite us (you might need LaTeX's url package). Check Github's Citation in the About menu, or the following Bibtex entries:

@Misc{Out2023,
  author       = {Out, Frenk and Cortés-Ortuño, David and Kosters, Martha and Fabian, Karl and de Groot, Lennart V.},
  title        = {{MMT Numerical Libraries: Dipole Cuboid Inversion}},
  publisher    = {Zenodo},
  note         = {Github: \url{https://github.com/Micromagnetic-Tomography/mmt_dipole_cuboid_inversion}},
  year         = {2023},
  doi          = {10.5281/zenodo.7823450},
  url          = {https://doi.org/10.5281/zenodo.7823450},
}

If you have a new version of biblatex you can also use @Software instead of @Misc, and add a version={} entry. You can also cite the paper with the theoretical framework of this library:

@article{Out2023,
...
}

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

mmt_dipole_cuboid_inversion-1.0.tar.gz (141.8 kB view details)

Uploaded Source

Built Distributions

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

mmt_dipole_cuboid_inversion-1.0-cp310-cp310-win_amd64.whl (205.5 kB view details)

Uploaded CPython 3.10Windows x86-64

mmt_dipole_cuboid_inversion-1.0-cp310-cp310-manylinux_2_35_x86_64.whl (527.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

mmt_dipole_cuboid_inversion-1.0-cp39-cp39-win_amd64.whl (206.4 kB view details)

Uploaded CPython 3.9Windows x86-64

mmt_dipole_cuboid_inversion-1.0-cp39-cp39-manylinux_2_35_x86_64.whl (531.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.35+ x86-64

mmt_dipole_cuboid_inversion-1.0-cp38-cp38-win_amd64.whl (206.4 kB view details)

Uploaded CPython 3.8Windows x86-64

mmt_dipole_cuboid_inversion-1.0-cp38-cp38-manylinux_2_35_x86_64.whl (531.7 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.35+ x86-64

File details

Details for the file mmt_dipole_cuboid_inversion-1.0.tar.gz.

File metadata

File hashes

Hashes for mmt_dipole_cuboid_inversion-1.0.tar.gz
Algorithm Hash digest
SHA256 c568ecacaf5cc6dbe89bb69dfca287bcd32dc98b9b09179fe77d6a4c1333964a
MD5 7aca58acd3fa617dc870fb6fc4dd2722
BLAKE2b-256 03467f90f27139e028d648ee9f98ac6cc408d7de7077cd4edf0af54117e7b69a

See more details on using hashes here.

File details

Details for the file mmt_dipole_cuboid_inversion-1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for mmt_dipole_cuboid_inversion-1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9db1bc7e9cf85102a91ec74e22cecf051e65c31f5931bdb6431ae5e333d3885c
MD5 eb5d2398a18e09bd031ad47b070cb975
BLAKE2b-256 8e25801e82f16f8e729af27e1ff41527d2fc5fa54a924a1e0fb258d7b2ec605c

See more details on using hashes here.

File details

Details for the file mmt_dipole_cuboid_inversion-1.0-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for mmt_dipole_cuboid_inversion-1.0-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 c78e00e006a133a666cddf69abc7d0d0d11e9a236bcc7f9e41dc18ff885086de
MD5 27e9e048c8ca76567dd46b50440cfb36
BLAKE2b-256 e77c9ebc2702df828134a201ca376ae428aee98babccc24aef948853cc038d46

See more details on using hashes here.

File details

Details for the file mmt_dipole_cuboid_inversion-1.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for mmt_dipole_cuboid_inversion-1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 af10edf0b2e2badaff19ed430036a866f0e141a19cad4ed298d118e36e3b8237
MD5 7a6ac9adebdda57afc15f34da7d1156e
BLAKE2b-256 5750256b05a80ccbf3929a2b414b3663b29439abcc8d4ba3e85f9b9bf540d10e

See more details on using hashes here.

File details

Details for the file mmt_dipole_cuboid_inversion-1.0-cp39-cp39-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for mmt_dipole_cuboid_inversion-1.0-cp39-cp39-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7bd1ecefd4b0db2fa388c4d76a5700c3b47446495045d208d3e47f2979326d2d
MD5 2b9f5eff3374b36d91a0f9e6536f5901
BLAKE2b-256 aadad7003280bf1dd04d3e88bfcadce3ea545835db6a0cf09009090b07c910fa

See more details on using hashes here.

File details

Details for the file mmt_dipole_cuboid_inversion-1.0-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for mmt_dipole_cuboid_inversion-1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 359b63f3d4fecceb93ab26ec2eba2f41590672c69139afe5883e00505263b245
MD5 4ecf0837d639e148814c38fb77a775b0
BLAKE2b-256 b083bad35fefb5522af164bf6ff90adbf011f824d0435c1a030a0afeadcae27c

See more details on using hashes here.

File details

Details for the file mmt_dipole_cuboid_inversion-1.0-cp38-cp38-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for mmt_dipole_cuboid_inversion-1.0-cp38-cp38-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 5066abc04e1f623b03089b85d1d3c0a88f1ffa0b3580d628aebb64cd0afcb8d4
MD5 ab3ff3a1c5a4e078f51541bfce9f254a
BLAKE2b-256 987a36466fb748aae70a0fdf618a6b7969aa18bc55385b2ea569531276e9d830

See more details on using hashes here.

Supported by

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