API Reference
This document provides a detailed API reference for the classes and methods in the em-app package.
solvers.py
This module contains functions for calculating the magnetic field using the Biot-Savart law.
Function |
Description |
Arguments |
Returns |
|---|---|---|---|
|
Serial Biot-Savart calculation with element inputs. |
|
|
|
Parallel Biot-Savart calculation using mpi4py. |
|
|
|
NumPy vectorized Biot-Savart calculation. |
|
|
|
Calculates the magnetic field generated by a coil. |
|
|
sources.py
This module defines classes for representing different current-carrying coil geometries.
Coil Class
Base class for a current-carrying coil.
Attributes
Attribute |
Type |
Description |
|---|---|---|
|
|
The current flowing through the coil. |
|
|
Whether to use MTF for representing the coil segments. |
|
|
The thickness of the wire in meters. |
|
|
Array of the center points of the coil segments. |
|
|
Array of the lengths of the coil segments. |
|
|
Array of the direction vectors of the coil segments. |
Methods
Method |
Description |
Returns |
|---|---|---|
|
Returns the discretized segments of the coil. |
|
|
Calculates the maximum extent of the coil. |
|
|
Calculates the approximate center point of the coil. |
|
|
Plots the coil segments in 3D. (Requires matplotlib) |
|
RingCoil Class
Represents a circular current-carrying coil. Inherits from Coil.
Attributes
Attribute |
Type |
Description |
|---|---|---|
|
|
Radius of the coil. |
|
|
Number of segments for discretization. |
|
|
(3,) array for the center coordinates. |
|
|
(3,) array for the axis direction. |
RectangularCoil Class
Represents a rectangular current-carrying coil. Inherits from Coil.
StraightWire Class
Represents a single straight current-carrying wire. Inherits from Coil.
Attributes
Attribute |
Type |
Description |
|---|---|---|
|
|
The starting point of the wire. |
|
|
The ending point of the wire. |
plotting.py
This module contains functions for plotting magnetic field data.
Function |
Description |
Key Arguments |
|---|---|---|
|
Plots a magnetic field component along a 1D line. |
|
|
Plots a magnetic field on a 2D plane. |
|
|
Generates a 3D quiver plot of the magnetic field vectors. |
|
vector_fields.py
This module defines classes for representing and manipulating vector field data.
Vector Class
A generic class to represent a 3D vector.
Methods
Method |
Description |
Returns |
|---|---|---|
|
Calculates the dot product with another Vector. |
|
|
Calculates the cross product with another Vector. |
|
|
Calculates the magnitude (L2-norm) of the vector. |
|
|
Converts the vector to a NumPy array. |
|
Bvec Class
Represents the magnetic field vector at a point. Inherits from Vector.
Methods
Method |
Description |
Returns |
|---|---|---|
|
Calculates the curl of the B-field vector. |
|
|
Calculates the divergence of the B-field. |
|
|
Calculates the Jacobian matrix of the B-field vector. |
|
VectorField Class
A class to store a collection of vectors at different points in space.
Attributes
Attribute |
Type |
Description |
|---|---|---|
|
|
A NumPy array of |
|
|
A corresponding (N, 3) NumPy array of points. |
Methods
Method |
Description |
Returns |
|---|---|---|
|
Calculates the magnitude of each vector. |
|
|
Exports the field to a pandas DataFrame. |
|