## Contents

- RAPTOR Tutorial 4: Time varying kinetic profiles
- time varying ne: scale ne by time-dependent factor
- time varying Zeff

## RAPTOR Tutorial 4: Time varying kinetic profiles

Example of how to input time-varying kinetic profiles ne,ni,ti,zeff These are provided externally to the simulation.

    addpath(fullfile(pwd,'..','RAPTOR_code'),'-end'); % add RAPTOR path
    %
    % load the default parameters,
    [config] = RAPTOR_config; % load default config
    [~,model,params,init] = RAPTOR_config(config); % generate model structure for these params.
    params.debug.iterdisp = 10; % display every 10

    % simple inputs: constant current plasma
    U = 200e3*ones(size(params.tgrid.tgrid)); % input Ip trace

    % initial conditions
    [x0,g0,v0] = RAPTOR_initial_conditions(U(1),model,init); % Define the initial condition

    loading CHEASE equilibrium from /Users/ffelici/matlab/RAPTOR/chease_equils/TCV_41083_cheasedata
    Scaling Te initial condition to match edge value boundary value (50)

## time varying ne: scale ne by time-dependent factor

    ne0 = v0(model.ne.ind);
    % initialize V0
    V0 = repmat(v0,1,params.tgrid.nt);
    % factor
    nefactor = linspace(1,3,params.tgrid.nt);
    % clip to 2
    nefactor(round(numel(nefactor)/2):end) = nefactor(round(numel(nefactor)/2));
    % substitute new time-varying ne0
    V0(model.ne.ind,:) = bsxfun(@times,ne0,nefactor);

    % run RAPTOR simulation
    simres = RAPTOR_predictive(x0,g0,V0,U,model,params);
    out1 = RAPTOR_out(simres,model,params);

      istep  telaps newt     res   t[ms]  dt[ms]  Ip[kA] Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV] ne0[e19]  Wi[kJ] We[kJ]  f_ss
          1   0.016    4 1.4e-11       0       1     200       0     7.9     192    6.36    2.32    2.32 3.7e+00    0.85    1.00    7.51    0.53 1.5e+01
         11    0.15    3 1.5e-11      10       1     200       0    6.93     193    6.36     1.7     1.7 3.0e+00    0.75    1.40    9.36    0.66 9.7e+00
         21    0.33    2 9.9e-09      20       1     200       0    6.86     193    6.36    1.25    1.25 2.8e+00    0.76    1.80   10.56    0.79 7.6e+00
         31    0.48    2 6.8e-09      30       1     200       0    6.76     193    6.36   0.972   0.972 2.7e+00    0.79    2.00   11.46    0.85 5.7e+00
         41    0.58    2 8.9e-10      40       1     200       0    6.77     193    6.36   0.817   0.817 2.6e+00    0.85    2.00   12.18    0.88 4.3e+00
         51    0.67    2 4.9e-10      50       1     200       0    6.79     193    6.36   0.725   0.725 2.4e+00    0.90    2.00   12.75    0.90 3.3e+00

## time varying Zeff

    ze0 = v0(model.ze.ind); % get original Zeff profile coefficients
    V0 = repmat(v0,1,params.tgrid.nt); % reset to old values

    zefactor = 1+linspace(1,0,numel(ze0))'*linspace(0,2,params.tgrid.nt);
    % Zeff ramp by factor 3 in core only, keep edge fixed
    V0(model.ze.ind,:) = bsxfun(@times,ze0,zefactor);
    simres = RAPTOR_predictive(x0,g0,V0,U,model,params);

    out2 = RAPTOR_out(simres,model,params);

    % end of tutorial

      istep  telaps newt     res   t[ms]  dt[ms]  Ip[kA] Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV] ne0[e19]  Wi[kJ] We[kJ]  f_ss
          1   0.016    4 1.4e-11       0       1     200       0     7.9     192    6.36    2.32    2.32 3.7e+00    0.85    1.00    7.51    0.53 1.5e+01
         11    0.13    2 1.5e-11      10       1     200       0    6.92     193    6.36    1.74    1.74 2.8e+00    0.90    1.00    9.28    0.57 8.7e+00
         21    0.22    2 9.6e-13      20       1     200       0    7.08     193    6.36    1.35    1.35 2.5e+00    1.10    1.00   10.37    0.63 6.5e+00
         31    0.32    2 2.9e-13      30       1     200       0    7.25     193    6.36     1.1     1.1 2.4e+00    1.28    1.00   11.16    0.69 4.9e+00
         41    0.42    2 9.5e-14      40       1     200       0    7.43     193    6.36   0.954   0.954 2.3e+00    1.44    1.00   11.74    0.73 3.6e+00
         51    0.51    2 5.3e-14      50       1     200       0    7.62     192    6.36   0.864   0.864 2.3e+00    1.58    1.00   12.17    0.78 2.6e+00