## Contents

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

## RAPTOR Tutorial 5: 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 /home/ffelici/matlab/RAPTOR-RT/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.029    5 4.6e-15       0       1     200       0    9.99     190    6.36    2.26    2.26 4.5e+00    0.85    1.00    7.60    0.55 1.8e+01
         11     0.2    3 2.9e-11      10       1     200       0    9.63     190    6.36    1.57    1.57 3.3e+00    0.82    1.40    9.85    0.72 1.2e+01
         21    0.35    3 4.5e-11      20       1     200       0    9.99     190    6.36    1.13    1.13 3.2e+00    0.86    1.80   11.40    0.88 9.5e+00
         31    0.52    3 4.5e-11      30       1     200       0    9.97     190    6.36   0.854   0.854 3.0e+00    0.91    2.00   12.64    0.96 7.4e+00
         41    0.64    2 4.4e-09      40       1     200       0    9.76     190    6.36   0.704   0.704 2.7e+00    0.99    2.00   13.62    0.99 5.6e+00
         51    0.76    2 2.6e-09      50       1     200       0    9.62     190    6.36   0.616   0.616 2.5e+00    1.05    2.00   14.39    1.01 4.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.027    5 4.6e-15       0       1     200       0    9.99     190    6.36    2.26    2.26 4.5e+00    0.85    1.00    7.60    0.55 1.8e+01
         11    0.16    2 3.2e-11      10       1     200       0    8.86     191    6.36    1.62    1.62 3.0e+00    0.97    1.00    9.68    0.61 9.9e+00
         21    0.28    2 1.3e-12      20       1     200       0    8.82     191    6.36    1.26    1.26 2.7e+00    1.19    1.00   10.96    0.68 7.5e+00
         31     0.4    2 3.0e-13      30       1     200       0    8.89     191    6.36    1.01    1.01 2.5e+00    1.39    1.00   11.90    0.73 5.8e+00
         41    0.53    2 9.8e-14      40       1     200       0    9.03     191    6.36   0.864   0.864 2.4e+00    1.57    1.00   12.63    0.79 4.4e+00
         51    0.65    2 3.5e-14      50       1     200       0     9.2     191    6.36   0.772   0.772 2.3e+00    1.73    1.00   13.19    0.83 3.3e+00