geoana.em.static.CircularLoopWholeSpace.magnetic_field#
- CircularLoopWholeSpace.magnetic_field(xyz, coordinates='cartesian')#
Compute the magnetic field for the current loop in a wholespace.
This method computes the magnetic field for the cirular current loop at the set of gridded xyz locations provided. Where \(\mu\) is the magnetic permeability, \(I d\mathbf{s}\) represents an infinitessimal segment of current at location \(\mathbf{r_s}\) and \(\mathbf{r}\) is the location at which we want to evaluate the magnetic field \(\mathbf{H}\):
\[\mathbf{H}(\mathbf{r}) = - \frac{I}{4\pi} \oint \frac{(\mathbf{r}-\mathbf{r_s}) \times d\mathbf{s}}{|\mathbf{r} - \mathbf{r_0}|^3}\]- Parameters:
- xyz(n, 3) numpy.ndarray xyz
gridded locations at which we calculate the magnetic field
- coordinates: str {‘cartesian’, ‘cylindrical’}
coordinate system that the location (xyz) are provided. The solution is also returned in this coordinate system. Default: “cartesian”
- Returns:
- (n, 3) numpy.ndarray
The magnetic field at each observation location in the coordinate system specified in units A/m.
Examples
Here, we define a horizontal loop and plot the magnetic field on the xz-plane that intercepts at y=0.
>>> from geoana.em.static import CircularLoopWholeSpace >>> from geoana.utils import ndgrid >>> from geoana.plotting_utils import plot2Ddata >>> import numpy as np >>> import matplotlib.pyplot as plt
Let us begin by defining the loop.
>>> location = np.r_[0., 0., 0.] >>> orientation = np.r_[0., 0., 1.] >>> radius = 0.5 >>> simulation = CircularLoopWholeSpace( >>> location=location, orientation=orientation, radius=radius >>> )
Now we create a set of gridded locations and compute the magnetic field.
>>> xyz = ndgrid(np.linspace(-1, 1, 50), np.array([0]), np.linspace(-1, 1, 50)) >>> H = simulation.magnetic_field(xyz)
Finally, we plot the magnetic field on the plane.
>>> fig = plt.figure(figsize=(4, 4)) >>> ax = fig.add_axes([0.15, 0.15, 0.8, 0.8]) >>> plot2Ddata(xyz[:, 0::2], H[:, 0::2], ax=ax, vec=True, scale='log') >>> ax.set_xlabel('X') >>> ax.set_ylabel('Z') >>> ax.set_title('Magnetic field at y=0')
(
Source code
,png
,pdf
)