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.8.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.8.0
File Size Uploaded Provenance Actions
magpylib_material_response-0.8.0.tar.gz 2.5 MB With provenance Details for magpylib_material_response-0.8.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.8 MB

Release files / magpylib_material_response-0.8.0.tar.gz

Download URL magpylib_material_response-0.8.0.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
1fd8b40951203c011f22a420d6f365eec499e58f329e95526f0917f33503b0d1
BLAKE2b-256 checksum
How to use checksums
cf1813071e5b917ae41f9d83edf9b49ecb5adcab331f4787ad9abaf504ba20f5
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 Nov 1, 2026.

Transparency log

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

Download URL magpylib_material_response-0.8.0-py3-none-any.whl
Size 285.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a76f1e9c1e9abac563d57448fdd0c6fd73b272a82980f24feaac24d82d16e489
BLAKE2b-256 checksum
How to use checksums
b570c0c35cdcf124556b59ae280526b8c45190c16c87198a3382f1329656e0a9
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 Nov 1, 2026.

Transparency log

Security for magpylib-material-response 0.8.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.8.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 Nov 1, 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