Package: mmt-dipole-cuboid-inversion
MMT Numerical Libraries: Dipole Cuboid InversionPython 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 calledDipoleCuboidInversion.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. TheDipoleCuboidInversionclass 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.Themmt_dipole_cuboid_inversionlibrary 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).InstallationVia PyPI andpip(note PyPI names use-instead of_)pip install mmt-dipole-cuboid-inversionOr you can use Poetry (recommended for development and CUDA, see below)poetry installDocumentationPlease visit the officialCUDATo build the code with thecudaoption to populate the Green's matrix, it is
necessary to define theCUDAHOMEvariable pointing to thecudafolder
(assuming you have a functionalcudainstallation), e.g.export CUDAHOME=/usr/local/cuda-11.5/Then you can compile the code usingpoetry install.PoetryThis library is built using thepoetrylibrary. After cloning the repository
avirtualenvwill be created automatically when runningpoetry install,
unless you are already in avirtualenv, for example, creating one viaconda. Within this environment it is possible to run and test the code usingpoetry 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.pyFor more information see this. If the package
requires to be built for publication (in the PyPI repository for example) or to
be installed viapip, you can runpoetry buildThis will produce adistfolder containing atar.gzfile and awheelfile. These files can be installed viapip.PyPIInstall from PyPI. Only Linux and Windows builds are currently available.pip install mmt-dipole-cuboid-inversionHow to useYou 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.CiteIf you find this library useful please cite us (you might need LaTeX'surlpackage). 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 ofbiblatexyou can also use@Softwareinstead of@Misc, and add aversion={}entry. You can also cite the paper with the
theoretical framework of this library:@article{Out2023,
...
}