Exemple #1
0
def test_Plasma3D_add_magnetostatics():
    r"""Function to test add_magnetostatic function
    """
    dipole = magnetostatics.MagneticDipole(
        np.array([0, 0, 1]) * u.A * u.m * u.m,
        np.array([0, 0, 0]) * u.m)
    cw = magnetostatics.CircularWire(np.array([0, 0, 1]),
                                     np.array([0, 0, 0]) * u.m, 1 * u.m,
                                     1 * u.A)
    gw_cw = cw.to_GeneralWire()
    iw = magnetostatics.InfiniteStraightWire(np.array([0, 1, 0]),
                                             np.array([0, 0, 0]) * u.m,
                                             1 * u.A)
    plasma = plasma3d.Plasma3D(domain_x=np.linspace(-2, 2, 30) * u.m,
                               domain_y=np.linspace(0, 0, 1) * u.m,
                               domain_z=np.linspace(-2, 2, 20) * u.m)

    plasma.add_magnetostatic(dipole, cw, gw_cw, iw)
Exemple #2
0
                          0, :].value.T  # because grid uses 'ij' indexing

############################################################
plt.figure()
plt.axis('square')
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.title(
    'Dipole field in x-z plane, generated by a dipole pointing in the z direction'
)
plt.streamplot(plasma.x.value, plasma.z.value, U, W)

############################################################
# A circular current-carring wire

cw = magnetostatics.CircularWire(np.array([0, 0, 1]),
                                 np.array([0, 0, 0]) * u.m, 1 * u.m, 1 * u.A)
print(cw)

############################################################
# initialize a a plasma, where the magnetic field will be calculated on
plasma = Plasma3D(domain_x=np.linspace(-2, 2, 30) * u.m,
                  domain_y=np.linspace(0, 0, 1) * u.m,
                  domain_z=np.linspace(-2, 2, 20) * u.m)

############################################################
# add the circular coil field to it
plasma.add_magnetostatic(cw)

X, Z = plasma.grid[0, :, 0, :], plasma.grid[2, :, 0, :]
U = plasma.magnetic_field[0, :,
                          0, :].value.T  # because grid uses 'ij' indexing