RAPTOR Sawtooth Tutorial

RAPTOR includes a sawtooth module. This tutorial explains how to use it

close all hidden;
run('../RAPTOR_path.m');
[config] = RAPTOR_config; % load default params

% set some things
config.init.te0 = 100;
config.debug.iterdisp = 50;
config.grid.tgrid = [0.:0.0005:0.2]; % small time step to see crashes well

% load sawtooth model
config.saw = saw('porcelli'); % this is a dummy sawtooth model that just reduces Te
% set critical temperature
config.saw.params.s1crit = 0.4; % critical shear for reconnection

% generate model structure for these params.
[model,params,init,g,v,U] = build_RAPTOR_model(config);

% define input
rampfun = @(t,tmin,ymin,tmax,ymax) ...
    max(ymin,min((ymax-ymin)/(tmax-tmin)*(t-tmin),ymax-ymin)+ymin); % anonymous function for ramps
init.Ip0 = 80e3;
U(1,:) = rampfun(config.grid.tgrid,0,init.Ip0,0.05,200e3);

% Define the initial condition
x0 = RAPTOR_initial_conditions(model,init,g(:,1),v(:,1));

% run RAPTOR
simres = RAPTOR_predictive(x0,g,v,U,model,params);
out = RAPTOR_out(simres,model,params);
% inspect result
figure;
plot(out.time,out.te);
     it  telaps newt     res   t[ms]  dt[ms]  Ip[kA] Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV] Ti0[keV] ne0[e19]   f_ss  
      1   0.051    5 7.1e-12       0     0.5      80       0   0.532    79.4    15.3    5.86    5.86 3.5e+00    0.14    0.29    1.00 1.2e+01 
     51       1    2 1.1e-14      25     0.5     140       0    6.02     134    8.76    1.91    1.91 3.7e+00    0.53    1.06    1.00 9.4e+00 
    101       2    2 5.3e-14      50     0.5     200       0    8.41     192    6.13     1.2     1.2 3.2e+00    0.88    1.76    1.00 8.9e+00 
    151       3    2 5.2e-14      75     0.5     200       0    8.55     191    6.13   0.873   0.873 1.9e+00    1.14    2.28    1.00 4.4e+00 
    201       4    3 6.0e-10     100     0.5     200       0    8.19     192    6.13   0.923   0.923 1.6e+00    1.13    2.26    1.00 7.2e+00 
    251       5    2 2.6e-09     125     0.5     200       0    8.47     191    6.13   0.881   0.881 1.5e+00    1.27    2.54    1.00 6.2e+00 
    301     6.1    4 9.6e-14     150     0.5     200       0    8.59     191    6.13   0.959   0.959 1.4e+00    1.01    2.03    1.00 1.1e+01 
    351     7.2    2 5.1e-11     175     0.5     200       0    8.56     191    6.13   0.862   0.862 1.5e+00    1.31    2.62    1.00 5.9e+00 
    401     8.3    3 9.0e-09     200     0.5     200       0    8.18     192    6.13   0.928   0.928 1.4e+00    1.13    2.26    1.00 8.9e+00