Currents#
Common Interface#
All current types in PyMagba share a common interface for computing magnetic fields and geometric properties.
- property position: ArrayLike3
Position of the object [x, y, z] in meters.
- property orientation: scipy.spatial.transform.Rotation
Orientation as a scipy.spatial.transform.Rotation object.
- translate(translation)
Translate the object by a displacement vector.
- Parameters:
translation (ArrayLike3) – Displacement [dx, dy, dz] in meters.
- rotate(rot)
Rotate the object about its own origin.
- Parameters:
rot (Rotation | ArrayLike4) – Rotation to apply. Can be a scipy.spatial.transform.Rotation object or a unit quaternion as a list.
- rotate_anchor(rot, anchor)
Rotate the object about an arbitrary anchor point.
- Parameters:
rot (Rotation | ArrayLike4) – Rotation to apply.
anchor (ArrayLike3) – Anchor point [x, y, z] in meters about which to rotate.
- compute_B(points)
Compute the magnetic flux density B at a batch of observer points.
- Parameters:
points (numpy.ndarray) – Array of shape (N, 3) containing the observer positions [x, y, z] in meters.
- Returns:
Array of shape (N, 3) with the [Bx, By, Bz] field vectors in Tesla at each observer point.
- Return type:
numpy.ndarray
Available Currents#
CircularCurrent#
- class pymagba.currents.CircularCurrent(position=None, orientation=None, diameter=1.0, current=1.0)[source]#
Physical representation of a circular current loop.
- Parameters:
position (
array_like, optional) – Center of the loop [x, y, z] in meters. Defaults to [0, 0, 0].orientation (
Rotation, optional) – Orientation of the loop. Defaults to identity.diameter (
float, optional) – Diameter of the loop in meters. Defaults to 1.0.current (
float, optional) – Current in the loop in Amperes. Defaults to 1.0.
PathCurrent#
- class pymagba.currents.PathCurrent(position=None, orientation=None, current=1.0, vertices=None)[source]#
A current path modeling a sequence of straight current-carrying wire segments.
- Parameters:
position (
array_like, optional) – Base position of the path [x, y, z] in meters. Defaults to [0, 0, 0].orientation (
Rotation, optional) – Orientation of the path. Defaults to identity.current (
float, optional) – Current in the path in Amperes. Defaults to 1.0.vertices (
array_like, optional) – The vertices of the path as an Nx3 array. Defaults to an empty list.
TriangleCurrent#
- class pymagba.currents.TriangleCurrent(position=None, orientation=None, current_density=None, vertices=None)[source]#
A single triangular current sheet with homogeneous surface current density.
- Parameters:
position (
array_like, optional) – Base position of the triangle [x, y, z] in meters. Defaults to [0, 0, 0].orientation (
Rotation, optional) – Orientation of the triangle. Defaults to identity.current_density (
array_like, optional) – Current density vector [Jx, Jy, Jz] in A/m. Defaults to [0, 0, 0].vertices (
array_like, optional) – The 3 vertices of the triangle as a 3x3 array. Defaults to [[1, 0, 0], [0, 1, 0], [0, 0, 0]].
SheetCurrent#
- class pymagba.currents.SheetCurrent(position=None, orientation=None, current_densities=None, vertices=None, faces=None)[source]#
A meshed current sheet.
- Parameters:
position (
array_like, optional) – Base position of the mesh [x, y, z] in meters. Defaults to [0, 0, 0].orientation (
Rotation, optional) – Orientation of the mesh. Defaults to identity.current_densities (
array_like, optional) – Current densities vectors for each face, provided as an Mx3 array where M is the number of faces. Defaults to empty.vertices (
array_like, optional) – The vertices of the mesh as an Nx3 array. Defaults to empty.faces (
array_like, optional) – The faces of the mesh as an Mx3 array of indices. Defaults to empty.
- classmethod from_stl(path, position=None, orientation=None, current_densities=None)[source]#
Creates a SheetCurrent from an STL file.
- Parameters:
path (
str) – The path to the STL file.position (
array_like, optional) – Base position of the mesh [x, y, z] in meters. Defaults to [0, 0, 0].orientation (
Rotation, optional) – Orientation of the mesh. Defaults to identity.current_densities (
array_like, optional) – Current densities vectors for each face, provided as an Mx3 array where M is the number of faces in the STL. Defaults to empty.
- Returns:
A new SheetCurrent instance.
- Return type: