Skip to main content

magpylib-material-response

Actions Status Documentation Status

PyPI version PyPI platforms

Coverage

Warning This package is experimental and in development phase, breaking API changes may happen at any time.

Magpylib-Material-Response adds the response of magnetic materials to Magpylib: the magnetization of soft-magnetic parts and the demagnetization of hard magnets. A solved model is a magpylib source like any other.

  • face_charge.apply_face_charge solves linear, uniform parts on their surface, with no volume mesh: cuboids, cylinders, cylinder segments, spheres and closed triangle meshes, such as CAD exports. It gets within 1 % of a finite-element reference faster than finite elements on every validation case where both get there.
  • demag.apply_demag cuts the parts into cells and solves for the polarization of every cell at once with the method of moments: for an anisotropic susceptibility, or one that varies inside a part. A dense direct solver, or matrix-free GMRES with FFT products on grids of identical cells; meshing helpers cut cuboids, cylinders and, through TetGen, any closed triangular surface into cells.
  • fem.fem_solve (the fem extra, NGSolve) solves the same model by finite elements, to check the other two; convergence.mesh_study, fem_study and compare give error bars by refining the mesh or the element order.

Installation

pip install magpylib-material-response

Tetrahedral meshing of TriangularMesh magnets needs the optional TetGen, finite elements NGSolve:

pip install "magpylib-material-response[tetgen]"
pip install "magpylib-material-response[fem]"

Minimal examples

import magpylib as magpy
from magpylib_material_response.face_charge import apply_face_charge

# a magnet on an iron plate, SI units (m, T)
magnet = magpy.magnet.Cuboid(polarization=(0, 0, 1.2), dimension=(0.01, 0.01, 0.005))
magnet.position = (0, 0, 0.0055)
plate = magpy.magnet.Cuboid(polarization=(0, 0, 0), dimension=(0.04, 0.04, 0.006))
plate.susceptibility = 1000  # soft iron; the magnet, with none, keeps its polarization

solved = apply_face_charge(magpy.Collection(magnet, plate))
print(
    magpy.getB(solved, (0, 0, 0.012))
)  # 205 mT above the magnet, 160 without the plate
import magpylib as magpy
from magpylib_material_response.demag import apply_demag
from magpylib_material_response.meshing import mesh_Cuboid

# a magnet with finite susceptibility, demagnetizing itself
magnet = magpy.magnet.Cuboid(polarization=(0, 0, 1), dimension=(1e-3, 1e-3, 1e-3))
magnet.susceptibility = 0.3  # µr = 1.3

mesh_demag = apply_demag(mesh_Cuboid(magnet, target_elems=125))
print(magpy.getB(mesh_demag, (0, 0, 1.5e-3)))

See the documentation for a quickstart, worked examples, and the method description.

Metadata

Release files for magpylib-material-response 0.7.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 magpylib-material-response 0.7.0
File Size Uploaded Provenance Actions
magpylib_material_response-0.7.0.tar.gz 2.3 MB With provenance Details for magpylib_material_response-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for magpylib-material-response 0.7.0
File Interpreter ABI Platform Actions
magpylib_material_response-0.7.0-py3-none-any.whl Python 3 none any Details for magpylib_material_response-0.7.0-py3-none-any.whl

Total release size: 2.6 MB

Release files / magpylib_material_response-0.7.0.tar.gz

Download URL magpylib_material_response-0.7.0.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
88e189fe36d0cf8dac31d49ba276f57eea64b4d4a0a27a77f91657cd5aa5b12c
BLAKE2b-256 checksum
How to use checksums
8bf20b42888a268f51b419fff1daed002d18d191797cd93be4de832d0e762369
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / magpylib_material_response-0.7.0-py3-none-any.whl

Download URL magpylib_material_response-0.7.0-py3-none-any.whl
Size 277.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
634b85affc066d7cbd27eed592cf985dffe2691340e2eed494f43b9b5aebdadb
BLAKE2b-256 checksum
How to use checksums
a3f9df2b61bb3df6d4b4514261d45755a5a5dfde9227738a6d7a125dcb783ba9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for magpylib-material-response 0.7.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for magpylib_material_response-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

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.

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