Magpylib-Force
This package provides force and torque computation for Magpylib objects. It is work in progress and will finally be integrated into the Magpylib package.
This work is supported by a NUMFOCUS grant: SDG 2024 round 1
Warning:
- relies on magpylib version>=5.0.1
- does not work with paths
- limited target types available
Installation
pip install magpylib-force
Documentation and Examples
The API documentation is integrated into the Magpylib docs.
Some examples are also part of the Magpylib webpage.
Example code:
import numpy as np
import magpylib as magpy
from magpylib_force import getFT
# Note: All inputs and outputs are in SI units.
# SOURCES: Magpylib source objects that generates the field
s1 = magpy.magnet.Sphere(diameter=1, polarization=(1,2,3))
s2 = magpy.magnet.Cuboid(dimension=(1,1,1), polarization=(1,2,3))
# TARGETS: targets that experience a force in the field of all sources
cube = magpy.magnet.Cuboid(
dimension=(1,1,1),
polarization=(0,0,1),
position=(1,2,3),
)
cube.meshing = (5,5,5) # regular rectangular mesh in Cuboid
line = magpy.current.Line(
vertices=((2,2,2), (3,3,3), (3,2,-3), (2,2,2)),
current=1,
)
line.meshing = 15 # number of cells in each segment
# Note: use only closed current loops or be prepared to violate physics
sphere = magpy.magnet.Sphere(
diameter=(6/np.pi)**(1/3),
polarization=(0,0,1),
position=(2,2,2),
)
sphere.meshing = 5 # grid finesse - the higher the finer
# COMPUTE FORCE AND TORQUE
FT = getFT([s1,s2], [cube, line, sphere], anchor=(0,0,0))
# Note: output shape is (3,2,3) from (targets, FT, xyz)
print(FT)
# Note: The magnet-numbers are large because the magnets are large :)
Metadata
Release files for magpylib-force 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| magpylib_force-0.3.1.tar.gz | 20.2 kB | With provenance | Details for magpylib_force-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| magpylib_force-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for magpylib_force-0.3.1-py3-none-any.whl |
Total release size: 42.4 kB
Release files / magpylib_force-0.3.1.tar.gz
| Download URL | magpylib_force-0.3.1.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3606463f37511d8b06c369591a8080dbad228379db851802d585676d93ec8513
|
|
BLAKE2b-256 checksum How to use checksums |
23612503728162646c66ec9d6ae7b12e673ba68b47ab909a99eb53e9db72e11a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
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 30, 2024.
Transparency logRelease files / magpylib_force-0.3.1-py3-none-any.whl
| Download URL | magpylib_force-0.3.1-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3972a2f8d167a6228407b8a611cd42bebcc98cff485a38c1507bdaa5f1929d3d
|
|
BLAKE2b-256 checksum How to use checksums |
139fe9d7a78e4f1fdb5bdceeb23c28360bd173b767332a16c3c74a38736183f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
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 30, 2024.
Transparency logSecurity for magpylib-force 0.3.1
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.
Attestation for magpylib_force-0.3.1.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 30, 2024.
Transparency logA 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.