Diagnostic modelling

The tokamesh.diagnostics module contains tools for generating lines-of-sight used as part of diagnostic models.

tokamesh.diagnostics.radial_fan(poloidal_position: tuple[float, float], phi: float, n_lines: int = 8, angle_range: tuple[float, float] = (130.0, 230.0), angles: ndarray[float] = None) tuple[numpy.ndarray, numpy.ndarray]

Generate a fan of lines-of-sight which are purely radial (i.e. have a constant toroidal angle).

Parameters
  • poloidal_position – The (R, z) position of the origin point of the fan as a tuple of two floats.

  • phi – The toroidal angle of the fan origin point.

  • n_lines – The number of lines-of-sight in the fan.

  • angle_range – The range of angles in the poloidal plane over which the fan is spread as a tuple of two floats.

  • angles – An array of angles (in degrees) for each line-of-sight. If provided, this argument overrides the n_lines and angle_range arguments.

Returns

The ray origins and the ray directions as a pair of numpy arrays.

tokamesh.diagnostics.tangential_fan(poloidal_position: tuple[float, float], phi: float, n_lines: int = 8, angle_range: tuple[float, float] = (0.0, 60.0), angles: ndarray[float] = None) tuple[numpy.ndarray, numpy.ndarray]

Generate a fan of lines-of-sight with different tangency radii but a constant z-height value.

Parameters
  • poloidal_position – The (R, z) position of the origin point of the fan as a tuple of two floats.

  • phi – The toroidal angle of the fan origin point.

  • n_lines – The number of lines-of-sight in the fan.

  • angle_range – The range of angles (in degrees) between the inward major radius vector and the lines of sight. Angles of 0 and 90 degrees therefore correspond to purely radial and purely tangential lines of sight respectively.

  • angles – An array of angles (in degrees) for each line-of-sight. If provided, this argument overrides the n_lines and angle_range arguments.

Returns

The ray origins and the ray directions as a pair of numpy arrays.

tokamesh.diagnostics.find_ray_boundary_intersections(R_boundary: ndarray, z_boundary: ndarray, ray_origins: ndarray, ray_directions: ndarray, min_distance: float = 0.0) ndarray

Calculate the end-points of a series of lines-of-sight based on the first position along each line which intersects with a polygon representing the machine boundary.

Parameters
  • R_boundary – The major radius values of the boundary polygon as a 1D numpy array.

  • z_boundary – The z-height values of the boundary polygon as a 1D numpy array.

  • ray_origins – The (x,y,z) position vectors of the origin of each ray (i.e. line-of-sight) as a 2D numpy array. The array must have shape (M,3) where M is the total number of rays.

  • ray_directions – The (x,y,z) direction unit-vectors of each ray (i.e. line-of-sight) as a 2D numpy array. The array must have shape (M,3) where M is the total number of rays.

  • min_distance – The minimum allowed distance of an intersection point from the ray origin. Any intersections with the boundary at a distance less than this value are ignored.

tokamesh.diagnostics.line_integration_matrix(origins: ndarray, endpoints: ndarray, target_resolution: float) tuple[numpy.ndarray, numpy.ndarray, scipy.sparse._csc.csc_matrix]

Generate a series of (R, z) points to be used in calculating line-integrals along a set of given lines-of-sight, and a corresponding sparse-matrix operator which computes the integrals when multiplied with a vector of field values at those (R, z) positions.

Parameters
  • origins – The (x,y,z) position vectors of the origin of each ray (i.e. line-of-sight) as a 2D numpy array. The array must have shape (M,3) where M is the total number of rays.

  • endpoints – The (x,y,z) position vectors of the end-point of each ray (i.e. line-of-sight) as a 2D numpy array. The array must have shape (M,3) where M is the total number of rays.

  • target_resolution – The target distance between integration points for each line-of-sight.