EM: Magnetic Dipole in a Whole-SpaceΒΆ

Here we plot the magnetic flux density from a harmonic dipole in a wholespace.

(Source code, png, hires.png, pdf)

../../_images/EM_FDEM_Analytic_MagDipoleWholespace-1.png
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import numpy as np
from SimPEG import Utils
import SimPEG.EM as EM
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm


def run(XYZ=None, loc=np.r_[0., 0., 0.], sig=1.0, freq=1.0, orientation='Z',
        plotIt=True):

    """
        EM: Magnetic Dipole in a Whole-Space
        ====================================

        Here we plot the magnetic flux density from a harmonic dipole in a
        wholespace.

    """

    if XYZ is None:
        # avoid putting measurement points where source is
        x = np.arange(-100.5, 100.5, step=1.)
        y = np.r_[0]
        z = x
        XYZ = Utils.ndgrid(x, y, z)

    Bx, By, Bz = EM.Analytics.FDEM.MagneticDipoleWholeSpace(
        XYZ,
        loc,
        sig,
        freq,
        orientation=orientation
    )
    absB = np.sqrt(Bx*Bx.conj()+By*By.conj()+Bz*Bz.conj()).real

    if plotIt:
        fig, ax = plt.subplots(1, 1, figsize=(6, 5))
        bxplt = Bx.reshape(x.size, z.size)
        bzplt = Bz.reshape(x.size, z.size)
        pc = ax.pcolor(x, z, absB.reshape(x.size, z.size), norm=LogNorm())
        ax.streamplot(x, z, bxplt.real, bzplt.real, color='k', density=1)
        ax.set_xlim([x.min(), x.max()])
        ax.set_ylim([z.min(), z.max()])
        ax.set_xlabel('x')
        ax.set_ylabel('z')
        cb = plt.colorbar(pc, ax=ax)
        cb.set_label('|B| (T)')


        return fig, ax

if __name__ == '__main__':
    run()
    plt.show()