bluemira.magnetostatics.baseclass

Base classes for use in magnetostatics.

Classes

CurrentSource

Abstract base class for a current source.

CrossSectionCurrentSource

Abstract class for a current source with a cross-section

SourceGroup

Abstract base class for multiple current sources.

Module Contents

class bluemira.magnetostatics.baseclass.CurrentSource

Bases: abc.ABC

Inheritance diagram of bluemira.magnetostatics.baseclass.CurrentSource

Abstract base class for a current source.

current: float
set_current(current: float)

Set the current inside each of the circuits.

Parameters:

current (float) – The current of each circuit [A]

abstract field(x: float | numpy.typing.NDArray[numpy.float64], y: float | numpy.typing.NDArray[numpy.float64], z: float | numpy.typing.NDArray[numpy.float64]) numpy.typing.NDArray[numpy.float64]

Calculate the magnetic field at a set of coordinates.

Parameters:
  • x (float | numpy.typing.NDArray[numpy.float64]) – The x coordinate(s) of the points at which to calculate the field

  • y (float | numpy.typing.NDArray[numpy.float64]) – The y coordinate(s) of the points at which to calculate the field

  • z (float | numpy.typing.NDArray[numpy.float64]) – The z coordinate(s) of the points at which to calculate the field

Returns:

The magnetic field vector {Bx, By, Bz} in [T]

Return type:

numpy.typing.NDArray[numpy.float64]

abstract plot(ax: matplotlib.pyplot.Axes | None, **kwargs)

Plot the CurrentSource.

Parameters:

ax (matplotlib.pyplot.Axes | None) – The matplotlib axes to plot on

abstract rotate(angle: float, axis: numpy.ndarray | str)

Rotate the CurrentSource about an axis.

Parameters:
  • angle (float) – The rotation degree [rad]

  • axis (numpy.ndarray | str) – The axis of rotation

copy()

Get a deepcopy of the CurrentSource.

Returns:

Deepcopy of current source.

class bluemira.magnetostatics.baseclass.CrossSectionCurrentSource

Bases: CurrentSource

Inheritance diagram of bluemira.magnetostatics.baseclass.CrossSectionCurrentSource

Abstract class for a current source with a cross-section

_origin: numpy.array
_dcm: numpy.array
_points: numpy.array
_rho: float
_area: float
set_current(current: float)

Set the current inside the source, adjusting current density.

Parameters:

current (float) – The current of the source [A]

rotate(angle: float, axis: numpy.ndarray | str)

Rotate the CurrentSource about an axis.

Parameters:
  • angle (float) – The rotation degree [degree]

  • axis (numpy.ndarray | str) – The axis of rotation

_local_to_global(points: numpy.typing.NDArray[numpy.float64]) numpy.typing.NDArray[numpy.float64]

Convert local x’, y’, z’ point coordinates to global x, y, z point coordinates.

Returns:

Converted array of points.

Parameters:

points (numpy.typing.NDArray[numpy.float64])

Return type:

numpy.typing.NDArray[numpy.float64]

_global_to_local(points: numpy.typing.NDArray[numpy.float64]) numpy.typing.NDArray[numpy.float64]

Convert global x, y, z point coordinates to local x’, y’, z’ point coordinates.

Returns:

Local coordinates

Parameters:

points (numpy.typing.NDArray[numpy.float64])

Return type:

numpy.typing.NDArray[numpy.float64]

plot(ax: matplotlib.pyplot.Axes | None = None, *, show_coord_sys: bool = False)

Plot the CurrentSource.

Parameters:
  • ax (Union[None, Axes]) – The matplotlib axes to plot on

  • show_coord_sys (bool) – Whether or not to plot the coordinate systems

class bluemira.magnetostatics.baseclass.SourceGroup(sources: list[CurrentSource])

Bases: abc.ABC

Inheritance diagram of bluemira.magnetostatics.baseclass.SourceGroup

Abstract base class for multiple current sources.

Parameters:

sources (list[CurrentSource])

sources: list[CurrentSource]
_points: numpy.array
set_current(current: float)

Set the current inside each of the circuits.

Parameters:

current (float) – The current of each circuit [A]

field(x: float | numpy.typing.NDArray[numpy.float64], y: float | numpy.typing.NDArray[numpy.float64], z: float | numpy.typing.NDArray[numpy.float64]) numpy.typing.NDArray[numpy.float64]

Calculate the magnetic field at a point.

Parameters:
  • x (float | numpy.typing.NDArray[numpy.float64]) – The x coordinate(s) of the points at which to calculate the field

  • y (float | numpy.typing.NDArray[numpy.float64]) – The y coordinate(s) of the points at which to calculate the field

  • z (float | numpy.typing.NDArray[numpy.float64]) – The z coordinate(s) of the points at which to calculate the field

Returns:

The magnetic field vector {Bx, By, Bz} in [T]

Return type:

numpy.typing.NDArray[numpy.float64]

rotate(angle: float, axis: numpy.ndarray | str)

Rotate the CurrentSource about an axis.

Parameters:
  • angle (float) – The rotation degree [rad]

  • axis (numpy.ndarray | str) – The axis of rotation

plot(ax: matplotlib.pyplot.Axes | None = None, *, show_coord_sys: bool = False)

Plot the MultiCurrentSource.

Parameters:
  • ax (matplotlib.pyplot.Axes | None) – The matplotlib axes to plot on

  • show_coord_sys (bool) – Whether or not to plot the coordinate systems

copy()

Get a deepcopy of the SourceGroup.

Returns:

Deepcopy of the SourceGroup.