import numpy as np import matplotlib.pyplot as plt from mayavi import mlab from raysect.core import World, Point3D, Vector3D from cherab.core.math import ConstantVector3D from vita.modules.cherab import FieldlineTracer, Euler # the world scene-graph world = World() b_field = ConstantVector3D(Vector3D(0, 1.5, 0)) field_tracer = FieldlineTracer(b_field, method=Euler(step_size=0.001)) start_point = Point3D(0, 0, 0) end_point, trajectory = field_tracer.trace(world, start_point, save_trajectory=True, max_steps=1000) num_segments = len(trajectory) x = np.zeros(num_segments) y = np.zeros(num_segments) z = np.zeros(num_segments) for ith_position, position in enumerate(trajectory): x[ith_position] = position.x y[ith_position] = position.y z[ith_position] = position.z mlab.plot3d(x, y, z, tube_radius=0.0005, color=(1, 0, 0))
# At each ray position sample the parameters of interest. for i, t in enumerate(t_samples): # Get new sample point location and log distance x = centre_point.x + parametric_vector.x * t y = centre_point.y + parametric_vector.y * t z = centre_point.z + parametric_vector.z * t ray_r_points.append(np.sqrt(x**2 + y**2)) ray_z_points.append(z) plt.plot(ray_r_points, ray_z_points, color=cmap(percent_error/25)) # plt.plot(ray_r_points[0], ray_z_points[0], 'b.') # plt.plot(ray_r_points[-1], ray_z_points[-1], 'r.') full_world = World() FULL_MESH_SEGMENTS = VESSEL + PSL + ICRH + DIVERTOR + A_B_COILS import_mesh_segment(full_world, FULL_MESH_SEGMENTS) fhc = load_default_bolometer_config('FHC', parent=full_world, inversion_grid=grid) flh = load_default_bolometer_config('FLH', parent=full_world, inversion_grid=grid) fhs_world = World() import_mesh_segment(fhs_world, FHS_TUBE) fhs = load_default_bolometer_config('FHS', parent=fhs_world, inversion_grid=grid) fvc_world = World() import_mesh_segment(fvc_world, FVC_TUBE) fvc = load_default_bolometer_config('FVC', parent=fvc_world, inversion_grid=grid) fdc_world = World() import_mesh_segment(fdc_world, FDC_TUBE)