An extension to the Magpylib library, providing force computation
Project description
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 :)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file magpylib_force-0.3.1.tar.gz.
File metadata
- Download URL: magpylib_force-0.3.1.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3606463f37511d8b06c369591a8080dbad228379db851802d585676d93ec8513
|
|
| MD5 |
2f0ca80536635b9dac7bd004855aca5d
|
|
| BLAKE2b-256 |
23612503728162646c66ec9d6ae7b12e673ba68b47ab909a99eb53e9db72e11a
|
Provenance
The following attestation bundles were made for magpylib_force-0.3.1.tar.gz:
Publisher:
publish.yml on magpylib/magpylib-force
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
magpylib_force-0.3.1.tar.gz -
Subject digest:
3606463f37511d8b06c369591a8080dbad228379db851802d585676d93ec8513 - Sigstore transparency entry: 145052365
- Sigstore integration time:
-
Permalink:
magpylib/magpylib-force@9f8cc41c885d292683e85557367d1c4da0f60e27 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/magpylib
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f8cc41c885d292683e85557367d1c4da0f60e27 -
Trigger Event:
release
-
Statement type:
File details
Details for the file magpylib_force-0.3.1-py3-none-any.whl.
File metadata
- Download URL: magpylib_force-0.3.1-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3972a2f8d167a6228407b8a611cd42bebcc98cff485a38c1507bdaa5f1929d3d
|
|
| MD5 |
45fd375eb8aab26f094620c3371d383c
|
|
| BLAKE2b-256 |
139fe9d7a78e4f1fdb5bdceeb23c28360bd173b767332a16c3c74a38736183f7
|
Provenance
The following attestation bundles were made for magpylib_force-0.3.1-py3-none-any.whl:
Publisher:
publish.yml on magpylib/magpylib-force
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
magpylib_force-0.3.1-py3-none-any.whl -
Subject digest:
3972a2f8d167a6228407b8a611cd42bebcc98cff485a38c1507bdaa5f1929d3d - Sigstore transparency entry: 145052366
- Sigstore integration time:
-
Permalink:
magpylib/magpylib-force@9f8cc41c885d292683e85557367d1c4da0f60e27 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/magpylib
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f8cc41c885d292683e85557367d1c4da0f60e27 -
Trigger Event:
release
-
Statement type: