The Open FUSION Toolkit 26.6
An open-source framework for fusion and plasma science and engineering
Loading...
Searching...
No Matches
pulse_design.py File Reference

Classes

class  MyEncoder
 JSON Encoder Object to store simulation results. More...
class  TokaMaker_TORAX
 TokaMaker + TORAX Coupled Pulse Simulation Code. More...

Namespaces

namespace  OpenFUSIONToolkit
 Python interface for Open FUSION Toolkit.
namespace  OpenFUSIONToolkit.TokaMaker
 Python interface for TokaMaker Grad-Shafranov functionality.
namespace  OpenFUSIONToolkit.TokaMaker.pulse_design
 TokaMaker + TORAX Coupled Pulse Design and Simulation Workflow (TokaMaker_TORAX/tmtx).

Functions

 _coil_aturn_clim (tt)
 Return (min, max) colormap limits in A-turns from _coil_bounds (A/turn * turns).
 _coil_net_turns (tt, cname)
 Return net_turns for a coil set name, defaulting to 1.
 _draw_equil_from_dir (ax, tt, loop, idx, t_now, equil_dir)
 Draw equilibrium from pre-rendered PNG in equil_dir.
 _draw_info (ax, tt, loop, run_name)
 _draw_profiles_movie (axes, tt, idx)
 Draw the 6 radial profile panels for a movie frame.
 _draw_scalars_movie (axes, tt, times, t_now, flux_con_tm, flux_con_tx)
 Draw the 6 scalar time-series panels for a movie frame.
 _embed_video_jupyter (video_path)
 Embed an MP4 video in a Jupyter notebook.
 _encode_video_from_dir (frame_dir, out_path, fps=2)
 Encode frames from a directory into an MP4 file.
 _in_jupyter ()
 Return True if running inside a Jupyter notebook.
 _make_temp_dir_viz ()
 Create temp directory for visualization temporary files: RAM-backed on Linux, OS default elsewhere.
 _prof (state_dict, idx)
 Return (x, y) arrays from a profile state dict, or (None, None).
 _render_equil_frames (tt, loop, equil_dir)
 Render equilibrium plots from stored equilibrium snapshots to PNG files.
 _render_frame (tt, loop, idx, t_now, times, flux_con_tm, flux_con_tx, out_path, run_name, equil_dir)
 Create a single movie frame.
 _save_or_display (fig, save_path=None, display=True)
 Save figure and/or display it, then close.
 _style (ax)
 Apply consistent styling to a matplotlib Axes.
 _trace_lcfs_for_evolution_plot (equil)
 Try successive normalized psi surfaces until tracing returns a non-empty contour.
 _tx_profile_at_rho (tt, var_name, rho_val, rho_coord='rho_norm', scale=1.0)
 Return (times, values) for a profile variable at a fixed rho, full resolution.
 _tx_scalar (tt, var_name, scale=1.0)
 Return (times, values) arrays from data_tree.scalars at full TORAX resolution.
 _x_points_active (tt, i, t=None)
 Return True when X-point targets should be applied at timestep index i.
 log_redirect_setup ()
 Step 1/3 of setup to redirect noisy outputs to log file.
 make_movie (tt, save_path=None, display=True, speed_factor=1.0, loop=None, notebook_mode=None)
 Create pulse movie from simulation data.
 plot_coils (tt, save_path=None, display=True)
 Plot coil current traces in MA-turns with limit bands.
 plot_equil_interactive (tt, loop=None, notebook_mode=None, save_path=None)
 Equilibrium viewer — widget slider in notebook, saved PNGs otherwise.
 plot_lcfs_evolution (tt, save_path=None, display=True, one_plot=False)
 Plot time evolution of the last closed flux surface for each phase.
 plot_profile_evolution (tt, save_path=None, display=True, one_plot=False)
 Plot profile evolution by pulse phase by default, or as one figure when one_plot=True.
 plot_profiles_interactive (tt)
 Interactive profile viewer with ipywidgets slider to scrub through timesteps.
 plot_scalars (tt, save_path=None, display=True)
 Plot 4x3 grid of time-series scalars.
 plot_tx_relax_profiles (tt, data_tree, *, stage, t_final_relax, user_ref_curves=None, save_path=None, display=False)
 Plot psi, n_e, T_e, T_i vs rho_norm after a short TORAX relax.
 profile_plot (tt, i, t, save_path=None, display=True)
 Detailed profile comparison at a single timestep.
 redirect_outputs_to_log (filename)
 Step 2/3 of setup to redirect noisy outputs to log file.
 summary (tt)
 Print and return key physics figures of merit from the simulation.
 tm_diagnostic_plot (tt, i, t, level_attempts, solve_succeeded, save_path=None, display=True)
 TokaMaker input/output diagnostic plot for a single timestep.
 tm_loop_summary_plot (tt, loop_level_log, save_path=None, display=True)
 Summary figure showing per-timestep GS solve outcomes.

Variables

tuple _LCFS_EVO_PSI_TRY = (1.0, 0.99, 0.98, 0.97)
int _NBI_W_TO_MA = 1/16e6
dict BASE_CONFIG
str COLOR_TM = 'steelblue'
str COLOR_TX = 'crimson'
list COLORS_MULTI
int DEFAULT_LOOP0_TX_FACE_POINTS = 51
int DIAG_FS = 13
tuple EQDSK_SAVE_NR_NZ_SEQUENCE = (100, 150, 200, 250, 300, 350, 400, 450, 500)
float GRID_ALPHA = 0.2
int INFO_FS = 13
int LABEL_FS = 11
float LCFS_WEIGHT = 100.0
int LEGEND_FS = 9
str LS_PRI = '-'
str LS_SEC = '--'
float LW = 1.6
int MK_SZ = 3
str MK_TM = '.'
int MOVIE_DPI = 200
 MOVIE_FIG_H
 MOVIE_FIG_W
float mu_0 = 4.0 * np.pi * 1e-7
int N_PSI = 1000
float RELAX_FIXED_DT = 0.01
int TICK_FS = 10
int TITLE_FS = 13
str VLINE_COLOR = 'black'
str VLINE_LS = ':'
float VLINE_LW = 1.0