Ejemplo n.º 1
0
# The user can supply either a python function (with 1 argument - normalised psi), a Function1D object or a numerical
# array holding the normalised psi and function values.

# In this example we create fake 2D and 3D "temperature" profiles from an array of data.
# The array is interpolated with cubic interpolation and then mapped onto the normalised psi grid.
temperature_2d = equilibrium.map2d([[0, 0.5, 0.9, 1.0], [5000, 4000, 2000, 0]])
temperature_3d = equilibrium.map3d([[0, 0.5, 0.9, 1.0], [5000, 4000, 2000, 0]])

# display 2D temperature
print("Plotting array based 2d temperature...")

rmin, rmax = equilibrium.r_range
zmin, zmax = equilibrium.z_range
nr = round((rmax - rmin) / 0.025)
nz = round((zmax - zmin) / 0.025)
r, z, temperature_grid = sample2d(temperature_2d, (rmin, rmax, nr),
                                  (zmin, zmax, nz))

plt.figure()
plt.axes(aspect='equal')
plt.pcolormesh(r, z, temperature_grid.transpose(), shading='gouraud')
plt.autoscale(tight=True)
plt.colorbar()
plt.title('2D Temperature (array)')

# display 3D temperature
print("Plotting array based 3d temperature...")

rmin, rmax = equilibrium.r_range
zmin, zmax = equilibrium.z_range
nr = round((rmax - rmin) / 0.025)
nz = round((zmax - zmin) / 0.025)
Ejemplo n.º 2
0
def plot_equilibrium(equilibrium, resolution=0.025):
    """
    Generates some overview plots of a given EFIT equilibrium.

    Generates plots of normalised psi,

    :param equilibrium: The input EFIT equilibrium object.
    :param float resolution: Spatial resolution for sampling.
    """

    eq = equilibrium

    # plot equilibrium
    rmin, rmax = eq.r_range
    zmin, zmax = eq.z_range

    # sample every 1 cm
    nr = round((rmax - rmin) / resolution)
    nz = round((zmax - zmin) / resolution)

    print("Sampling psi...")
    r, z, psi_sampled = sample2d(eq.psi_normalised, (rmin, rmax, nr),
                                 (zmin, zmax, nz))

    print("Sampling B-field...")
    _, _, b = samplevector2d(eq.b_field, (rmin, rmax, nr), (zmin, zmax, nz))

    print("Sampling LCFS interior...")
    _, _, inside = sample2d(eq.inside_lcfs, (rmin, rmax, nr), (zmin, zmax, nz))

    print("Calculating B-field magnitude...")
    bx = b[:, :, 0]
    by = b[:, :, 1]
    bz = b[:, :, 2]
    bmag = np.sqrt(bx**2 + by**2 + bz**2)

    print("Plotting...")
    plt.figure()
    plt.axes(aspect='equal')
    plt.pcolormesh(r,
                   z,
                   np.transpose(psi_sampled),
                   cmap='jet',
                   shading='gouraud')
    plt.autoscale(tight=True)
    plt.colorbar()
    plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
    plt.title('(Normalised Psi')

    plt.figure()
    plt.axes(aspect='equal')
    plt.pcolormesh(r, z, np.transpose(bx), cmap='gray', shading='gouraud')
    plt.autoscale(tight=True)
    plt.colorbar()
    plt.contour(r, z, np.transpose(bx), 25)
    plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
    plt.title('Magnetic Field: X Component')

    plt.figure()
    plt.axes(aspect='equal')
    plt.pcolormesh(r, z, np.transpose(by), cmap='gray', shading='gouraud')
    plt.autoscale(tight=True)
    plt.colorbar()
    plt.contour(r, z, np.transpose(by), 25)
    plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
    plt.title('Magnetic Field: Y Component')

    plt.figure()
    plt.axes(aspect='equal')
    plt.pcolormesh(r, z, np.transpose(bz), cmap='gray', shading='gouraud')
    plt.autoscale(tight=True)
    plt.colorbar()
    plt.contour(r, z, np.transpose(bz), 25)
    plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
    plt.title('Magnetic Field: Z Component')

    plt.figure()
    plt.axes(aspect='equal')
    plt.pcolormesh(r, z, np.transpose(bmag), cmap='gray', shading='gouraud')
    plt.autoscale(tight=True)
    plt.colorbar()
    plt.contour(r, z, np.transpose(bmag), 25)
    plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
    plt.title('Magnetic Field Magnitude')

    plt.figure()
    plt.axes(aspect='equal')
    plt.pcolormesh(r, z, np.transpose(inside), cmap='gray', shading='gouraud')
    plt.autoscale(tight=True)
    plt.colorbar()
    plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
    plt.title('Inside LCFS')

    plt.figure()
    plt.axes(aspect='equal')
    plt.quiver(r[::4],
               z[::4],
               np.transpose(bx[::4, ::4]),
               np.transpose(bz[::4, ::4]),
               angles='xy',
               scale_units='xy',
               pivot='middle')
    plt.autoscale(tight=True)
    plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
    plt.title('Poloidal Magnetic Field')

    p2r_psin, p2r_r = sample1d(eq.psin_to_r, (0, 1, 1000))

    plt.figure()
    plt.plot(p2r_psin, p2r_r)
    plt.title('Psi (Normalised) vs Outboard Major Radius')

    plt.show()
Ejemplo n.º 3
0
 for shotidx, (shot, t0,
               col) in enumerate(zip(shotList, tList, colorList)):
     Eq = JETEquilibrium(shot, user="******", dda="EFTP")
     EqA = Eq.time(t0)
     limiter = np.append(EqA.limiter_polygon,
                         [EqA.limiter_polygon[0, :]],
                         axis=0)
     if shotidx == 0:
         ax[0].plot(limiter[:, 0], limiter[:, 1], "k", lw=2)
     #
     rmin, rmax = EqA.r_range
     zmin, zmax = EqA.z_range
     resolution = 0.01
     nr = round((rmax - rmin) / resolution)
     nz = round((zmax - zmin) / resolution)
     r, z, psi_sampled = sample2d(EqA.psi_normalised, (rmin, rmax, nr),
                                  (zmin, zmax, nz))
     ax[0].contour(
         r,
         z,
         psi_sampled.transpose(),
         levels=interior_levels,
         colors=col,
         linewidths=0.6,
         linestyles="-",
     )
     ax[0].contour(
         r,
         z,
         psi_sampled.transpose(),
         levels=exterior_levels,
         colors=col,
Ejemplo n.º 4
0
Archivo: plot.py Proyecto: cherab/core
def plot_equilibrium(equilibrium, detail=False, resolution=0.025):
    """
    Generates some overview plots of a given EFIT equilibrium.

    :param equilibrium: The input EFIT equilibrium object.
    :param detail: If true, prints additional information about the equilibrium.
    :param float resolution: Spatial resolution for sampling (default=0.025).

    .. code-block:: pycon

       >>> from cherab.tools.equilibrium import example_equilibrium, plot_equilibrium
       >>>
       >>> equilibrium = example_equilibrium()
       >>> plot_equilibrium(equilibrium, detail=False, resolution=0.001)
    """

    eq = equilibrium

    # plot equilibrium
    rmin, rmax = eq.r_range
    zmin, zmax = eq.z_range

    # sample every 1 cm
    nr = round((rmax - rmin) / resolution)
    nz = round((zmax - zmin) / resolution)

    print("Sampling psi...")
    r, z, psi_sampled = sample2d(eq.psi_normalised, (rmin, rmax, nr),
                                 (zmin, zmax, nz))

    print("Plotting summary...")
    _plot_summary(r, z, psi_sampled, eq.magnetic_axis, eq.limiter_polygon,
                  eq.time)

    if detail:

        print("Sampling B-field...")
        _, _, b = samplevector2d(eq.b_field, (rmin, rmax, nr),
                                 (zmin, zmax, nz))

        print("Sampling LCFS interior...")
        _, _, inside_lcfs = sample2d(eq.inside_lcfs, (rmin, rmax, nr),
                                     (zmin, zmax, nz))

        if eq.inside_limiter:
            print("Sampling Limiter interior...")
            _, _, inside_limiter = sample2d(eq.inside_limiter,
                                            (rmin, rmax, nr), (zmin, zmax, nz))

        print("Calculating B-field magnitude...")
        bx = b[:, :, 0]
        by = b[:, :, 1]
        bz = b[:, :, 2]
        bmag = np.sqrt(bx**2 + by**2 + bz**2)

        print("Sampling q...")
        psin, q = sample1d(eq.q, (0, 1, 100))

        print("Plotting details...")

        plt.figure()
        plt.axes(aspect='equal')
        plt.pcolormesh(r, z, np.transpose(psi_sampled), shading='gouraud')
        plt.autoscale(tight=True)
        plt.colorbar()
        plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
        plt.title('Normalised Psi')
        plt.xlabel("R (meters)")
        plt.ylabel("Z (meters)")

        plt.figure()
        plt.axes(aspect='equal')
        plt.pcolormesh(r, z, np.transpose(bx), cmap='gray', shading='gouraud')
        plt.autoscale(tight=True)
        plt.colorbar()
        plt.contour(r, z, np.transpose(bx), 25)
        plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
        plt.title('Magnetic Field: X Component')
        plt.xlabel("R (meters)")
        plt.ylabel("Z (meters)")

        plt.figure()
        plt.axes(aspect='equal')
        plt.pcolormesh(r, z, np.transpose(by), cmap='gray', shading='gouraud')
        plt.autoscale(tight=True)
        plt.colorbar()
        plt.contour(r, z, np.transpose(by), 25)
        plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
        plt.title('Magnetic Field: Y Component')
        plt.xlabel("R (meters)")
        plt.ylabel("Z (meters)")

        plt.figure()
        plt.axes(aspect='equal')
        plt.pcolormesh(r, z, np.transpose(bz), cmap='gray', shading='gouraud')
        plt.autoscale(tight=True)
        plt.colorbar()
        plt.contour(r, z, np.transpose(bz), 25)
        plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
        plt.title('Magnetic Field: Z Component')
        plt.xlabel("R (meters)")
        plt.ylabel("Z (meters)")

        plt.figure()
        plt.axes(aspect='equal')
        plt.pcolormesh(r,
                       z,
                       np.transpose(bmag),
                       cmap='gray',
                       shading='gouraud')
        plt.autoscale(tight=True)
        plt.colorbar()
        plt.contour(r, z, np.transpose(bmag), 25)
        plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
        plt.title('Magnetic Field Magnitude')
        plt.xlabel("R (meters)")
        plt.ylabel("Z (meters)")

        plt.figure()
        plt.axes(aspect='equal')
        plt.pcolormesh(r,
                       z,
                       np.transpose(inside_lcfs),
                       cmap='gray',
                       shading='gouraud')
        plt.autoscale(tight=True)
        plt.colorbar()
        plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
        plt.title('Inside LCFS')
        plt.xlabel("R (meters)")
        plt.ylabel("Z (meters)")

        if eq.inside_limiter:
            plt.figure()
            plt.axes(aspect='equal')
            plt.pcolormesh(r,
                           z,
                           np.transpose(inside_limiter),
                           cmap='gray',
                           shading='gouraud')
            plt.autoscale(tight=True)
            plt.colorbar()
            plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
            plt.title('Inside Limiter')
            plt.xlabel("R (meters)")
            plt.ylabel("Z (meters)")

        plt.figure()
        plt.axes(aspect='equal')
        plt.quiver(r[::4],
                   z[::4],
                   np.transpose(bx[::4, ::4]),
                   np.transpose(bz[::4, ::4]),
                   angles='xy',
                   scale_units='xy',
                   pivot='middle')
        plt.autoscale(tight=True)
        plt.contour(r, z, np.transpose(psi_sampled), levels=[1.0])
        plt.title('Poloidal Magnetic Field')
        plt.xlabel("R (meters)")
        plt.ylabel("Z (meters)")

        if eq.psin_to_r is not None:  # Only if psin is monotonic
            p2r_psin, p2r_r = sample1d(eq.psin_to_r, (0, 1, 1000))

            plt.figure()
            plt.plot(p2r_psin, p2r_r)
            plt.title('Psi Normalised vs Outboard Major Radius')
            plt.xlabel("a.u.")
            plt.ylabel("R (meters)")

        plt.figure()
        plt.plot(psin, q)
        plt.title('Safety Factor (q) vs Psi Normalised')
        plt.xlabel("Psi Normalised")
        plt.ylabel("a.u.")

    plt.show()
Ejemplo n.º 5
0
wall_mesh = axisymmetric_mesh_from_polygon(wall_polygon)
wall_mesh.parent = world
wall_mesh.material = AbsorbingSurface()

###################################################
# make detectors wrapping a slice of wall surface #

# toroidal width of the detectors
X_WIDTH = 0.01

# intialization of the initial angle
d_angle = (2 * np.pi) / n_poloidal

# visualise emission adn detectors
plt.figure()
r, z, t_samples = sample2d(rad_function, (0, 4, 200), (-2, 2, 200))
plt.imshow(np.transpose(np.squeeze(t_samples)), extent=[0, 4, -2, 2])
plt.colorbar()
plt.axis('equal')
plt.xlabel('r axis')
plt.ylabel('z axis')
plt.title("Radiation profile in r-z plane")

wall_detectors = []
for index in range(1, n_poloidal + 1):

    p1x = PLASMA_AXIS.x + DETECTOR_RADIUS * np.sin(d_angle * index)
    p1y = PLASMA_AXIS.y + DETECTOR_RADIUS * np.cos(d_angle * index)
    p1 = Point3D(p1x, 0, p1y)

    p2x = PLASMA_AXIS.x + DETECTOR_RADIUS * np.sin(d_angle * (index + 1))