scotty.ray_solver
scotty.ray_solver#
Functions for evolving a single ray
Used by the main code to find the point where the beam leaves the plasma, which then sets the integration limits for the beam solver.
- class scotty.ray_solver.K_cutoff_data(q_R, q_Z, K_norm_min, poloidal_flux, theta_m)#
Bases:
object
Properties of \(K\)-cutoff
- scotty.ray_solver.handle_leaving_plasma_events(tau_events, ray_parameters_2D_events)#
Handle events detected by
scipy.integrate.solve_ivp
. This only handles events due to the ray leaving the plasma or simulation:"leave_plasma"
: the ray has left the plasma"leave_LCFS"
: the ray has left the last-closed flux surface. For most simulations, this is likely identical to leaving the plasma"leave_simulation"
: the ray has left the simulated area (essentially the bounding box of the plasma)"cross_resonance"
: the ray has crossed a resonance
- Parameters
tau_events (Dict[str, FloatArray]) – A mapping between event names and the solver
t_events
K_R_LCFS (float) – The radial wavevector in the case where the beam has crossed the LCFS
ray_parameters_2D_events (numpy.ndarray[Any, numpy.dtype[numpy.float64]]) –
- Returns
The value of
tau
when the detected event first occurred- Return type
FloatArray
- scotty.ray_solver.handle_no_resonance(solver_ray_output, tau_leave, tau_points, K_zeta, solver_arguments, event_leave_plasma)#
Add an additional tau point at the cut-off (minimum K) if the beam does NOT reach a resonance
Propagates another ray to find the cut-off location
- Parameters
tau_leave (float) –
tau_points (numpy.ndarray[Any, numpy.dtype[numpy.float64]]) –
K_zeta (float) –
event_leave_plasma (Callable) –
- Return type
numpy.ndarray[Any, numpy.dtype[numpy.float64]]
- scotty.ray_solver.make_solver_events(poloidal_flux_enter, launch_angular_frequency, field)#
Define event handlers for the ray solver
Only works correctly for the 2D case
- Parameters
poloidal_flux_enter (float) – Poloidal flux label of plasma surface
launch_angular_frequency (float) – Beam frequency
field (MagneticField) – Magnetic field object
- Returns
Dictionary of event handlers with names
- Return type
Dict[str, Callable]
- scotty.ray_solver.propagate_ray(poloidal_flux_enter, launch_angular_frequency, field, initial_position, K_initial, hamiltonian, rtol, atol, quick_run, len_tau, tau_max=100000.0, verbose=True)#
Propagate a ray. Quickly finds tau at which the ray leaves the plasma, as well as estimates location of cut-off.
- Parameters
poloidal_flux_enter (float) – Flux label where ray enters plasma
launch_angular_frequency (float) – Angular frequency of beam
field (MagneticField) – Object describing magnetic field
initial_position (FloatArray) – Initial position in
q
coordinatesK_initial (FloatArray) – Initial wavevector
hamiltonian (Hamiltonian) – Object to compute Hamiltonian
rtol (float) – Relative tolerance
atol (float) – Absolute tolerance
quick_run (bool) – If true, use minimum of \(|K|\) to estimate cut-off location
len_tau (int) – Number of points for tau
tau_max (float) – Maximum value of tau before the solver stops
verbose (bool) – If true, print some timing information
- Returns
Returns either: value of tau where ray left plasma, along with an array of tau points for the beam solver to output results at; or, a
K_cutoff_data
with information about the estimated location of the cut-off- Return type
Union[Tuple[float, FloatArray], K_cutoff_data]
- scotty.ray_solver.quick_K_cutoff(ray_parameters_turning_pt, K_zeta, field)#
Calculate some quantities at the minimum \(|K|\) along the ray
- Parameters
ray_parameters_turning_pt (FloatArray) – State vector from ray evolution
K_zeta (float) – \(K_\zeta\) for the ray
field (MagneticField) – Object describing the magnetic field
- Returns
Ray coordinates, \(|K|\), magnetic flux, and mismatch angle
- Return type
q_R, q_Z, K_norm, poloidal_flux, theta_m
- scotty.ray_solver.ray_evolution_2D_fun(tau, ray_parameters_2D, K_zeta, hamiltonian)#
- Parameters
tau (float) – Parameter along the ray.
ray_parameters_2D (complex128) – q_R, q_Z, K_R, K_Z
hamiltonian (scotty.hamiltonian.Hamiltonian) – Hamiltonian object
- Returns
d (beam_parameters) / d tau
- Return type
d_beam_parameters_d_tau
Notes