RAPTOR NTM simulation tutorial

NTMs can also be simulated, either by prescribing the time-evolution of the modes directly (affecting transport) or by solving MRE self-consistently.

Contents

RAPTOR Prescribed NTM time-evolution

This simulation also includes sawteeth, you will see the effect!

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

config.saw = saw('porcelli');

% load an ntm model.
config.ntm = ntm('prescribed');
config.debug.iterdisp = 50;

% build RAPTOR structure
config.init.te0=100;
config.grid.tgrid = [0.:0.001:1];
% 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,160e3);

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

% Prescribe NTM evolution
% make v0 vector time-varying
nt = numel(params.tgrid); vtvar = v*ones(1,nt);

% parameters
params.saw.s1crit = 0.3;
params.ntm.chiefact_A(:) = 2; % factor increase in chie

% define NTM appearance times and width
w43 = zeros(1,nt);
w43(params.tgrid > 0.2 & params.tgrid<0.3) = 0.05; % 4/3 NTM
w32 = zeros(1,nt);
w32(params.tgrid > 0.4 & params.tgrid<0.5) = 0.05; % 3/2 NTM
w21 = zeros(1,nt);
w21(params.tgrid > 0.6 & params.tgrid<0.7) = 0.05; % 2/1 NTM
w31 = zeros(1,nt);
w31(params.tgrid > 0.8 & params.tgrid<0.9) = 0.05; % 3/1 NTM

% assign to V
% Make sure that the indices match with the m and n parameters
vtvar(model.ntm.vind(1),:) = w21;
vtvar(model.ntm.vind(2),:) = w32;
vtvar(model.ntm.vind(3),:) = w43;
vtvar(model.ntm.vind(4),:) = w31;

% must turn these off for technical reasons
params.neos.implicit = false;
params.chi_e.implicit = false;

simres = RAPTOR_predictive(x0,g,vtvar,U,model,params);
out = RAPTOR_out(simres,model,params);

% inspect result
RAPTOR_plot_GUI(out,'overview');

plot(out.time,[out.w_32; out.w_43; out.w_31;out.w_21]);
     it  telaps newt     res   t[ s]  dt[ s]  Ip[kA] Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV] Ti0[keV] ne0[e19]   f_ss  
      1    0.32    2 9.1e-16       0   0.001      80       0   0.532    79.4    15.3    4.89    4.89 6.7e+00    0.30    0.59    1.00 2.0e+01 
     51     1.1    2 2.5e-14    0.05   0.001     160       0    6.97     153    7.67    1.22    1.22 3.0e+00    0.75    1.51    1.00 6.8e+00 
    101     2.1    2 4.6e-14     0.1   0.001     160       0    7.24     153    7.67   0.837   0.837 1.7e+00    1.05    2.10    1.00 3.0e+00 
    151     3.1    2 5.3e-14    0.15   0.001     160       0     7.3     153    7.67   0.896   0.896 1.6e+00    1.08    2.16    1.00 4.2e+00 
    201     3.9    2 5.9e-14     0.2   0.001     160       0    7.29     153    7.66   0.978   0.978 1.6e+00    0.81    1.62    1.00 1.5e+01 
    251     4.7    2 6.0e-14    0.25   0.001     160       0    6.42     154    7.67   0.905   0.905 1.9e+00    0.68    1.36    1.00 9.2e-01 
    301     5.4    1 1.2e-11     0.3   0.001     160       0    6.53     153    7.67   0.978   0.978 1.9e+00    0.68    1.36    1.00 1.0e-02 
    351     6.2    2 4.5e-14    0.35   0.001     160       0    7.26     153    7.66   0.989   0.989 1.7e+00    0.85    1.70    1.00 1.3e+01 
    401     7.1    2 1.1e-13     0.4   0.001     160       0    7.31     153    7.67   0.896   0.896 1.5e+00    1.08    2.17    1.00 4.3e+00 
    451     7.9    2 9.5e-14    0.45   0.001     160       0    6.16     154    7.67   0.855   0.855 2.0e+00    0.67    1.34    1.00 1.4e+00 
    501     8.5    1 3.9e-10     0.5   0.001     160       0    6.32     154    7.67   0.995   0.995 2.0e+00    0.64    1.29    1.00 1.2e-01 
    551     9.4    2 6.7e-14    0.55   0.001     160       0    7.25     153    7.67   0.837   0.837 1.7e+00    1.07    2.13    1.00 3.2e+00 
    601      10    2 2.2e-13     0.6   0.001     160       0     7.3     153    7.67    0.94    0.94 1.6e+00    1.00    2.01    1.00 7.1e+00 
    651      11    2 1.5e-13    0.65   0.001     160       0    5.57     154    7.66       1    1.02 2.2e+00    0.65    1.30    1.00 8.6e+00 
    701      12    2 1.9e-13     0.7   0.001     160       0    5.58     154    7.67    0.86    0.86 2.2e+00    0.79    1.57    1.00 4.5e+00 
    751      13    2 3.2e-13    0.75   0.001     160       0    7.28     153    7.67   0.895   0.895 1.6e+00    1.07    2.14    1.00 4.1e+00 
    801      14    2 1.3e-13     0.8   0.001     160       0    7.31     153    7.67   0.896   0.896 1.5e+00    1.09    2.17    1.00 4.4e+00 
    851      15    2 2.5e-13    0.85   0.001     160       0    5.49     155    7.66       1    1.01 2.1e+00    0.60    1.20    1.00 1.4e+01 
    901      16    2 9.7e-14     0.9   0.001     160       0     5.5     155    7.66       1    1.01 2.0e+00    0.61    1.21    1.00 1.4e+01 
    951      17    2 2.1e-13    0.95   0.001     160       0    7.32     153    7.67    0.94    0.94 1.5e+00    1.01    2.01    1.00 7.5e+00 
     it  telaps newt     res   t[ s]  dt[ s]  Ip[kA] Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV] Ti0[keV] ne0[e19]   f_ss  
   1001      18    2 3.0e-13       1   0.001     160       0    7.18     153    7.67   0.865   0.865 1.5e+00    1.11    2.21    1.00 4.3e+00 

NTM simulation using Modified Rutherford equation

Includes ECRH power to stabilise the mode

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

% load the Modified Rutherford Equation ntm model.
config.ntm = ntm('mre');
config.ntm.params.m=[2 3];
config.ntm.params.n=[1 2];
config.ntm.params.chiefact_A=[2 1]; % factor increase in chie
config.ntm.params.chiefact_w=2*ones(1,config.ntm.n_ntm);
config.ntm.params.w_d_e=0.01*ones(1,config.ntm.n_ntm);
config.ntm.params.w_d_i=0.01*ones(1,config.ntm.n_ntm);
config.ntm.params.a2_bs=0.1*ones(1,config.ntm.n_ntm);
config.ntm.params.a_ggj=ones(1,config.ntm.n_ntm);
config.ntm.params.conf_deg=zeros(1,config.ntm.n_ntm);
config.ntm.params.w_cd_ntm=0.01*ones(1,config.ntm.n_ntm);
config.ntm.params.rhodeltap_cl0=-config.ntm.params.m;

% Specify the ECRH launcher, make sure that the last NTM launcher can be
% moved
config.echcd.params.active=true;
config.echcd.params.rdep=[0      0.4100 -1];
config.echcd.params.wdep=[0.3000 0.3500 0.35];
config.echcd.params.cd_eff=[0 1 1];
config.echcd.params.eta_eccd0=7.0000e+14;
config.echcd.params.uindices=[2 3 4 5];
config.nbhcd.params.uindices=max(config.echcd.params.uindices)+1;

% build RAPTOR structure
config.debug.iterdisp = 50;
config.init.te0=100;
config.grid.tgrid = 0.:0.001:1;
% generate model structure for these params.
[model,params,init,g,v,U] = build_RAPTOR_model(config);

define input

nt = numel(params.tgrid);

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;

P_central1 = zeros(1,size(config.grid.tgrid,2));
P_central1(:,params.tgrid >= 0.05 & params.tgrid <= 1.1) = 1.0e6;


NTM_stabpow2=zeros(1,size(config.grid.tgrid,2));
NTM_stabpow2(params.tgrid >= 0.5  & params.tgrid <= 0.6) = 0.1e6;

NTM_stabpow3=zeros(1,size(config.grid.tgrid,2));
rhodep3 = 0.45*ones(1,size(config.grid.tgrid,2));

U(1:5,:) = ...
    [rampfun(config.grid.tgrid,0,init.Ip0,0.05,160e3); ...
     P_central1;...
     NTM_stabpow2;...
     NTM_stabpow3;...
     rhodep3]; % rho dep

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

% ntm
% make v0 vector time-varying
vtvar = v*ones(1,nt);

define NTM appearance times and width

% Seed the 3/2 to 5 cm which provides a lower bound between 0.4 s and 0.5 s
w32 = zeros(1,nt);
w32(params.tgrid >= 0.4 & params.tgrid <= 0.45) = 0.05; % 3/2 NTM, island held for some time
% Seed the 2/1 at 0.1 s to 15 cm
w21 = zeros(1,nt);
w21(params.tgrid == 0.1) = 0.15; % 2/1 NTM

% assign to V
% Make sure that the indices match with the m and n parameters
vtvar(model.ntm.vind(1),:) = w21;
vtvar(model.ntm.vind(2),:) = w32;

% run RAPTOR
params.neos.implicit = false;
params.chi_e.implicit = false;

params.ntm.doplot = false;
simres = RAPTOR_predictive(x0,g,vtvar,U,model,params);
% generate output structure

out = RAPTOR_out(simres,model,params);
     it  telaps newt     res   t[ s]  dt[ s]  Ip[kA] Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV] Ti0[keV] ne0[e19]   f_ss  
      1   0.075    2 9.1e-16       0   0.001      80       0   0.532    79.4    15.3    4.89    4.89 6.7e+00    0.30    0.59    1.00 2.0e+01 
     51    0.97    2 3.0e-14    0.05   0.001     160       0    6.97     153    7.67    1.22    1.22 3.0e+00    3.97    7.95    1.00 6.8e+00 
    101     1.7    1 3.1e-09     0.1   0.001     160       0    65.8    94.1    7.67    1.31    1.41 2.7e-01   10.07   20.14    1.00 1.4e+00 
    151     2.6    2 1.9e-14    0.15   0.001     160       0    54.6     105    7.67   0.908    1.21 2.2e-01   10.45   20.91    1.00 9.3e-01 
    201     3.3    1 1.3e-10     0.2   0.001     160       0      54     106    7.67   0.843    1.05 1.4e-01   10.50   21.00    1.00 5.2e-01 
    251     3.8    1 1.9e-11    0.25   0.001     160       0    52.8     107    7.67   0.797   0.881 1.2e-01   10.52   21.04    1.00 4.3e-01 
    301     4.4    1 8.2e-12     0.3   0.001     160       0      52     108    7.67    0.76   0.764 1.1e-01   10.54   21.08    1.00 3.6e-01 
    351       5    1 5.0e-12    0.35   0.001     160       0    51.3     109    7.67   0.685   0.685 1.1e-01   10.55   21.11    1.00 3.0e-01 
    401     5.6    1 3.3e-12     0.4   0.001     160       0    50.8     109    7.67    0.63    0.63 1.0e-01   10.57   21.14    1.00 2.5e-01 
    451     6.3    1 2.9e-10    0.45   0.001     160       0    34.8     125    7.67   0.556   0.556 1.9e-01    7.83   15.67    1.00 6.2e-01 
    501     7.1    2 4.6e-14     0.5   0.001     160       0    49.2     111    7.67   0.518   0.518 1.1e-01   10.64   21.28    1.00 2.8e-01 
    551     7.7    1 1.1e-11    0.55   0.001     160    4.86    52.1     103    7.67   0.495   0.495 7.0e-02   10.84   21.68    1.00 1.1e-01 
    601     8.3    1 1.7e-12     0.6   0.001     160    4.86    52.2     103    7.67   0.481   0.481 7.0e-02   10.81   21.62    1.00 6.7e-02 
    651       9    1 4.1e-12    0.65   0.001     160       0    49.3     111    7.67   0.474   0.474 9.7e-02   10.58   21.16    1.00 8.4e-02 
    701     9.5    1 1.1e-12     0.7   0.001     160       0    49.2     111    7.67    0.47    0.47 9.4e-02   10.61   21.22    1.00 6.6e-02 
    751      10    1 4.4e-13    0.75   0.001     160       0    49.2     111    7.67   0.468   0.468 9.2e-02   10.63   21.26    1.00 5.5e-02 
    801      11    1 2.1e-13     0.8   0.001     160       0    49.1     111    7.67   0.466   0.466 9.1e-02   10.64   21.28    1.00 4.7e-02 
    851      11    1 1.3e-13    0.85   0.001     160       0    49.1     111    7.67   0.464   0.464 9.0e-02   10.65   21.30    1.00 4.1e-02 
    901      12    1 8.3e-14     0.9   0.001     160       0      49     111    7.67   0.461   0.461 8.9e-02   10.66   21.32    1.00 3.5e-02 
    951      13    1 1.1e-13    0.95   0.001     160       0      49     111    7.67   0.459   0.459 8.8e-02   10.66   21.33    1.00 3.0e-02 
     it  telaps newt     res   t[ s]  dt[ s]  Ip[kA] Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV] Ti0[keV] ne0[e19]   f_ss  
   1001      13    1 7.0e-14       1   0.001     160       0    48.9     111    7.67   0.457   0.457 8.8e-02   10.67   21.33    1.00 2.5e-02 

Inspect result

RAPTOR_plot_GUI(out,'overview');

figure
hold on
plot(out.time,out.w_21,'x')
plot(out.time,out.w_32,'or')
xlabel('Time t [s]')
ylabel('Island width  w [m]')
legend('2/1','3/2')