Beispiel #1
0
    def poloidal_trajectory_plot(self,
                                 field_tracer,
                                 world,
                                 equilibrium,
                                 num_of_fieldlines=5,
                                 max_tracing_length=15):

        if not (isinstance(num_of_fieldlines, int) and num_of_fieldlines > 0):
            raise TypeError(
                "The number of fieldlines to trace must be an integer > 0.")

        point_a = Point3D(self._point_a.x, 0, self._point_a.y)
        point_b = Point3D(self._point_b.x, 0, self._point_b.y)
        interface_vector = point_a.vector_to(point_b)

        plot_equilibrium(equilibrium, detail=False)

        for i in range(num_of_fieldlines):

            sample_point = point_a + interface_vector * i / num_of_fieldlines

            _, _, trajectory = field_tracer.trace(
                world,
                sample_point,
                max_length=max_tracing_length,
                save_trajectory=True)

            rz_trajectory = np.zeros((trajectory.shape[0], 2))
            for i in range(trajectory.shape[0]):
                r = sqrt(trajectory[i, 0]**2 + trajectory[i, 1]**2)
                z = trajectory[i, 2]
                rz_trajectory[i, :] = r, z

            plt.plot(rz_trajectory[:, 0], rz_trajectory[:, 1], 'g')
Beispiel #2
0
    def plot(self, equilibrium):
        """
        Plot the interface surface line across the equilibrium.

        :param EFITEquilibrium equilibrium: the equilibrium to plot.
        """

        sample_points = []
        num_samples = self._power_profile.shape[0]
        point_a = self._point_a
        point_b = self._point_b
        interface_vector = point_a.vector_to(point_b)
        for i in range(num_samples):
            seed_point = point_a + interface_vector * i / num_samples
            sample_points.append([seed_point.x, seed_point.y])

        interface_distance = point_a.distance_to(point_b)
        sample_distances = np.linspace(0, interface_distance, num=num_samples)

        sample_points = np.array(sample_points)
        plot_equilibrium(equilibrium, detail=False)
        plt.plot(sample_points[:, 0], sample_points[:, 1])

        plt.figure()
        plt.plot(sample_distances, self._power_profile)
Beispiel #3
0
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 (function)')

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

rmin, rmax = equilibrium.r_range
zmin, zmax = equilibrium.z_range
nr = round((rmax - rmin) / 0.01)
nz = round((zmax - zmin) / 0.01)
temperature_slice = Slice3D(temperature_3d, axis='z', value=0.0)
x, y, temperature_grid = sample2d(temperature_slice, (-rmax, rmax, nr),
                                  (-rmax, rmax, nr))

plt.figure()
plt.axes(aspect='equal')
plt.pcolormesh(x, y, temperature_grid.transpose(), shading='gouraud')
plt.autoscale(tight=True)
plt.colorbar()
plt.title('3D Temperature (x-y slice, function)')

# the cherab package has a convenience tool for viewing an equilibrium
# this function samples the various equilibrium attributes and renders them as images
print('Plotting equilibrium data...')
plot_equilibrium(equilibrium, detail=True)
Beispiel #4
0
# other method
power_profile = sample_power_at_surface(interface_point_a, interface_point_b,
                                        equilibrium, footprint)
interface_power = 1e6  # 1MW
angle_period = 45

interface_surface = InterfaceSurface(interface_point_a, interface_point_b,
                                     power_profile, interface_power)
interface_surface.histogram_plot()

plt.figure()
plt.plot(psi_on_interface)
plt.title('PSI along divertor interface')

plot_equilibrium(equilibrium, detail=False)
plt.plot([interface_point_a.x, interface_point_b.x],
         [interface_point_a.y, interface_point_b.y], 'k')

# TODO - Jeppe could insert his calculation method here, allowing comparison within the same script.

# find and plot the peak of the histogram
index, value = max(enumerate(n), key=operator.itemgetter(1))
peak_position = (bins[index] + bins[index + 1]) / 2
peak_point2d = interface_point_a + interface_vector.normalise() * peak_position
plt.plot([peak_point2d.x], [peak_point2d.y], 'r.')

# # add jeppes peak position
# jeppes_peak_position = 0.02  JEPPE - add your peak position here for the plots
# peak_point2d = interface_point_a + interface_vector.normalise() * peak_position
# plt.plot([peak_point2d.x], [peak_point2d.y], 'g.')
Beispiel #5
0
# Copyright 2014-2017 United Kingdom Atomic Energy Authority
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.tools.equilibrium import plot_equilibrium
from cherab.mastu.equilibrium import MASTUEquilibrium

print("Reading equilibrium...")
pulse_equilibrium = MASTUEquilibrium(28101)

eq = pulse_equilibrium.time(0.2)

plot_equilibrium(eq)
Beispiel #6
0
    def _process_efit_polygon(self, poly_r, poly_z):

        if poly_r.shape != poly_z.shape:
            raise ValueError("EFIT polygon coordinate arrays are inconsistent in length.")

        n = poly_r.shape[0]
        if n < 2:
            raise ValueError("EFIT polygon coordinate contain less than 2 points.")

        # boundary polygon contains redundant points that must be removed
        unique = (poly_r != poly_r[0]) | (poly_z != poly_z[0])
        unique[0] = True  # first point must be included!
        poly_r = poly_r[unique]
        poly_z = poly_z[unique]

        # generate single array containing coordinates
        poly_coords = np.zeros((2, len(poly_r)))
        poly_coords[0, :] = poly_r
        poly_coords[1, :] = poly_z

        return poly_coords

if __name__ == "__main__":
    from os.path import expanduser
    from cherab.tools.equilibrium import plot_equilibrium
    path = expanduser("~/EFIT/17636.1.h5")

    equilibrium = COMPASSEquilibrium(path=path)
    eq_slice = equilibrium.time(1.135)
    plot_equilibrium(equilibrium=eq_slice, detail=True, resolution=0.01)
Beispiel #7
0
# Copyright 2014-2017 United Kingdom Atomic Energy Authority
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.tools.equilibrium import plot_equilibrium
from cherab.jet.equilibrium import JETEquilibrium

print("Reading equilibrium...")
pulse_equilibrium = JETEquilibrium(87738)

eq = pulse_equilibrium.time(45.0)

plot_equilibrium(pulse_equilibrium.time(45.0))

plot_equilibrium(pulse_equilibrium.time(50.0))

plot_equilibrium(pulse_equilibrium.time(55.0))