scotty.torbeam module
scotty.torbeam module#
Created on Mon Jul 24 14:31:24 2017
@author: Valerian Chen
Notes
Bear in mind that Te currently uses the same function as ne. Not important for me since I don’t care about temperature
I’ve checked (CompareTopfiles) that B_z and B_r does indeed have the correct symmetry
Version history
- v3 - Added a function for the generation of density (n_e) profiles.
Used this function to make the profiles linear in rho rather than psi
- v4 - Fixed bug with B_z and B_r
Made B_poloidal = B_poloidal max outside the last closed flux surface
Changed the way B_z, B_r, and B_poloidal are written, such that they use for loops. Not elegant, but at least I’ve made them work.
Cleaned up the transposes and the order part of reshape to be more understandable
v5 - B_toroidal now has correct units v6 - Added two different methods of selecting the launch position v7 - Fixed an issue where psi was transposed (shape(psi) = transpose(shape(B))) because meshgrid was using ‘xy’ by default, instead of ik
- class scotty.torbeam.Torbeam(R_grid, Z_grid, B_R, B_T, B_Z, psi)#
Bases:
objectUtility class for reading/writing TORBEAM geometry files
- Parameters
R_grid – Major radius grid points in metres
Z_grid – Vertical coordinate grid points in metres
B_R – Major-radial magnetic field component in Tesla
B_T – Toroidal magnetic field component in Tesla
B_Z – Vertical magnetic field component in Tesla
psi – Poloidal flux
- classmethod from_file(filename)#
Read TORBEAM geometry file
- Parameters
filename (Union[os.PathLike, str]) –
- Return type
- write(filename)#
Write TORBEAM geometry file
- Parameters
filename (Union[os.PathLike, str]) –
- scotty.torbeam.main(poloidal_launch_angle=0.0, toroidal_launch_angle=0.0, tau_step=0.05, B_toroidal_max=1.0, B_poloidal_max=0.0, core_ne=4.0, core_Te=0.01, aspect_ratio=1.5, minor_radius=0.5, torbeam_directory_path='.', nedata_length=101, Tedata_length=101, buffer_factor=1.1, x_grid_length=130, z_grid_length=65)#
Create TORBEAM input files
- Parameters
poloidal_launch_angle (float) – In degrees
toroidal_launch_angle (float) – In degrees
tau_step (float) – Was 0.05, making it smaller to speed up runs
B_toroidal_max (float) – In Tesla
B_poloidal_max (float) – In Tesla
core_ne (float) – In 10^19 m-3 (IDL files, discussion w/ Jon)
core_Te (float) –
aspect_ratio (float) – major_radius/minor_radius
minor_radius (float) – In meters
torbeam_directory_path (Union[os.PathLike, str]) – Directory to save output files, defaults to working directory
nedata_length (int) – Number of grid points for density
Tedata_length (int) – Number of grid points for temperature
buffer_factor (float) – Size of buffer in
xas a factor ofminor_radiusx_grid_length (int) – Size of
xgridz_grid_length (int) – Size of
zgrid (should be a multiple of 5)
- scotty.torbeam.n_e_fun(nedata_psi, core_ne)#
- scotty.torbeam.write_inbeam(minor_radius, major_radius, toroidal_launch_angle, poloidal_launch_angle, launch_position_x, launch_position_z, tau_step, torbeam_directory_path)#
Writes inbeam.dat
Refer to input-output.pdf for more detail. All offsets, flipping of signs, and so on should be done outside this function
- Parameters
torbeam_directory_path (pathlib.Path) –
- scotty.torbeam.write_torbeam_file(major_radius, minor_radius, buffer_factor, x_grid_length, z_grid_length, B_toroidal_max, B_poloidal_max, torbeam_directory_path)#
Write a TORBEAM magnetic geometry file based on a circular cross-section equilibrium