scotty.beam_me_up module#

Notes

  • K**2 = K_R**2 + K_z**2 + (K_zeta/r_R)**2, and K_zeta is constant (mode number). See 14 Sep 2018 notes.

  • Start in vacuum, otherwise Psi_3D_beam_initial_cartersian does not get done properly

  • Launching from plasma is possible, but beam needs to be initialised differently

Coordinates#

  • X, Y, Z - Lab Cartesian coordinates

  • R, zeta, Z - Lab cylindrical coordinates

  • x, y, g - Beam coordinates

  • u1, u2, u_parallel - Field-aligned coordinates

Abbreviations#

  • bs - backscattered

  • loc - localisation

  • cum_loc - cumulative_localisation

  • ne - equilibrium electron density

  • dt - datatree (stores data)

Angles#

  • theta - angle between g and u1, small when mismatch is small

  • theta_m - mismatch angle, angle between u1 and K

Units#

  • SI units

  • Distance in m

  • Angles in rad

  • Temperature in KeV

  • electron cyclotron frequency positive

  • K normalised such that K = 1 in vacuum. (Not implemented yet)

  • Distance not normalised yet, should give it thought

scotty.beam_me_up.beam_me_up(poloidal_launch_angle_Torbeam, toroidal_launch_angle_Torbeam, launch_freq_GHz, mode_flag, launch_beam_width, launch_beam_curvature, launch_position, vacuumLaunch_flag=True, relativistic_flag=False, find_B_method='torbeam', density_fit_parameters=None, temperature_fit_parameters=None, shot=None, equil_time=None, vacuum_propagation_flag=False, Psi_BC_flag=None, poloidal_flux_enter=1.0, poloidal_flux_zero_density=1.0, poloidal_flux_zero_temperature=1.0, auto_delta_sign=True, delta_R=-0.0001, delta_Z=0.0001, delta_K_R=0.1, delta_K_zeta=0.1, delta_K_Z=0.1, interp_order=5, len_tau=102, rtol=0.001, atol=1e-06, interp_smoothing=0, ne_data_path=PosixPath('.'), magnetic_data_path=PosixPath('.'), Te_data_path=PosixPath('.'), output_path=PosixPath('.'), input_filename_suffix='', output_filename_suffix='', figure_flag=True, detailed_analysis_flag=True, quick_run=False, plasmaLaunch_K=array([0., 0., 0.]), plasmaLaunch_Psi_3D_lab_Cartesian=array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]), density_fit_method=None, temperature_fit_method=None, B_T_axis=None, B_p_a=None, R_axis=None, minor_radius_a=None)#

Run the beam tracer

Overview#

  1. Initialise density fit parameters. One of:
    • spline with data from file

    • Stefanikova

    • O(3) polynomial

    • tanh

    • quadratic

    See profile_fit for more details

  2. If relativistic_flag enabled, initialise temperature fit parameters. Not yet fully implemented. One of:

    • spline with data from file

    • linear

    See ‘profile_fit’ for more details

  3. Initialise magnetic field method. One of:
    • TORBEAM

    • OMFIT

    • analytical

    • EFIT++

    • UDA

    • curvy slab

    • test/test_notime

    See geometry for more details

  4. Initialise beam launch parameters (vacuum/plasma). See launch for more details.

  5. Propagate single ray with IVP solver to find point where beam leaves plasma. See ray_solver for more details

  6. Propagate beam with IVP solver

  7. Dump raw output

  8. Analysis

param poloidal_launch_angle_Torbeam:

Poloidal angle of antenna in TORBEAM convention

type poloidal_launch_angle_Torbeam:

float

param toroidal_launch_angle_Torbeam:

Toroidal angle of antenna in TORBEAM convention

type toroidal_launch_angle_Torbeam:

float

param launch_freq_GHz:

Frequency of the launched beam in GHz

type launch_freq_GHz:

float

param mode_flag:

Either +/-1, used to determine which mode branch to use

type mode_flag:

int

param launch_beam_width:

Width of the beam at launch

type launch_beam_width:

float

param launch_beam_curvature:

Curvatuve of the beam at launch

type launch_beam_curvature:

float

param launch_position:

Position of the antenna in cylindrical coordinates

type launch_position:

FloatArray

param vacuumLaunch_flag:

If True, launch beam from vacuum, otherwise beam launch position is inside the plasma already

type vacuumLaunch_flag:

bool

param vacuum_propagation_flag:

If True, run solver from the launch position, and don’t use analytical vacuum propagation

type vacuum_propagation_flag:

bool

param relativistic_flag:

If True, generates a temperature profile from given data or parameters and applies relativistic corrections to electron mass.

type relativistic_flag:

bool

param Psi_BC_flag:

If None, do no special treatment at plasma-vacuum boundary If continuous, apply BCs for continuous ne but discontinuous gradient of ne If discontinuous, apply BCs for discontinuous ne Using True or False is now deprecated

type Psi_BC_flag:

String

param poloidal_flux_enter:

Normalised poloidal flux label of plasma boundary. If vacuum_propagation_flag, then this is where the solver begins. If Psi_BC_flag, then this is where the plasma-vacuum BCs are applied

type poloidal_flux_enter:

float

param poloidal_flux_zero_density:

At and above this normalised poloidal flux label, Scotty sets the electron density to zero

type poloidal_flux_zero_density:

float

param poloidal_flux_zero_temperature:

At and above this normalised poloidal flux label, Scotty sets the electron temperature to zero. This effectively negates any relativistic mass corrections.

type poloidal_flux_zero_temperature:

float

param plasmaLaunch_Psi_3D_lab_Cartesian:

\(\Psi\) of beam in lab Cartesian coordinates. Required if vacuumLaunch_flag is False

type plasmaLaunch_Psi_3D_lab_Cartesian:

FloatArray

param plasmaLaunch_K:

Wavevector of beam at launch. Required if vacuumLaunch_flag is False

type plasmaLaunch_K:

FloatArray

param delta_R:

Finite difference spacing to use for R

type delta_R:

float

param delta_Z:

Finite difference spacing to use for Z

type delta_Z:

float

param delta_K_R:

Finite difference spacing to use for K_R

type delta_K_R:

float

param delta_K_zeta:

Finite difference spacing to use for K_zeta

type delta_K_zeta:

float

param delta_K_Z:

Finite difference spacing to use for K_Z

type delta_K_Z:

float

param find_B_method:

See create_magnetic_geometry for more information.

Common options:

  • "efitpp" uses magnetic field data from efitpp files directly

  • "torbeam" uses magnetic field data from TORBEAM input files

  • "omfit" is similar to "torbeam" but reads the data from JSON files

  • "UDA_saved" reads EFIT data from numpy’s .npz files

  • "analytical" uses a constant current density circular equilibrium

Or pass a MagneticField instance directly.

param density_fit_parameters:

A list of parameters to be passed to the density_fit_method constructor. See the docs for the individual methods for the meaning of their parameters

Note

These parameters should not include poloidal_flux_zero_density

param density_fit_method:

Parameterisation of the density profile. Either a callable (see ProfileFit), or one of the following options:

  • "smoothing-spline": 1D smoothing spline (SmoothingSplineFit)

  • "smoothing-spline-file": 1D smoothing spline constructed from file (SmoothingSplineFit.from_dat_file)

  • "stefanikova": combination of modified hyperbolic \(\tan\) and a Gaussian (StefanikovaFit)

  • "poly3" or "polynomial": \(n\)-th order polynomial (PolynomialFit)

  • "tanh": hyperbolic \(\tan\) (TanhFit)

  • "quadratic": constrained quadratic (QuadraticFit)

If density_fit_method is a string, then the corresponding DensityFit object is constructed using poloidal_flux_zero_density and density_fit_parameters.

"smoothing-spline-file" looks for a file called ne<input_filename_suffix>.dat in ne_data_path. It also uses interp_order and interp_smoothing instead of density_fit_parameters.

Deprecated since version 2.4.0: If None (the default) is passed, the method will be guessed from the length of density_fit_parameters. In this case, quadratic and tanh parameters _should_ include poloidal_flux_zero_density as the last value.

param temperature_fit_method:

Parameterisation of the temperature profile. Leverages the same ProfileFit class used for density. See density_fit_method for details.

param len_tau:

Number of output tau points

type len_tau:

int

param rtol:

Relative tolerance for ODE solver

type rtol:

float

param atol:

Absolute tolerance for ODE solver

type atol:

float

param quick_run:

If true, then run only the ray tracer and get an analytic estimate of the \(K\) cut-off location

type quick_run:

bool

param auto_delta_sign:

Boolean. Ensures that forward difference is always in negative poloidal flux gradient direction (into the plasma).

Parameters:
Return type:

DataTree

scotty.beam_me_up.create_magnetic_geometry(find_B_method, magnetic_data_path=None, input_filename_suffix='', interp_order=5, interp_smoothing=0, B_T_axis=None, R_axis=None, minor_radius_a=None, B_p_a=None, shot=None, equil_time=None, delta_R=None, delta_Z=None, **kwargs)#

Create an object representing the magnetic field geometry

Parameters:
Return type:

MagneticField

scotty.beam_me_up.default_plots(dt, field, output_path, suffix)#

Save some simple figures

Allows one to quickly gain an insight into what transpired in the simulation

Parameters:
Return type:

None

scotty.beam_me_up.make_density_fit(method, poloidal_flux_zero_density, parameters, filename)#

Either construct a ProfileFit instance, or return method if it’s already suitable. Suitable methods are callables that take an array of poloidal fluxes and return an array of densities.

Parameters:
Return type:

Callable[[float | ndarray[tuple[int, …], dtype[float64]]], float | ndarray[tuple[int, …], dtype[float64]]]

scotty.beam_me_up.make_temperature_fit(method, poloidal_flux_zero_temperature, parameters, filename)#

Either construct a DensityFit instance, or return method if it’s already suitable. Suitable methods are callables that take an array of poloidal fluxes and return an array of temperatures.

Parameters:
Return type:

Callable[[float | ndarray[tuple[int, …], dtype[float64]]], float | ndarray[tuple[int, …], dtype[float64]]]