# RAPTOR Exercise 1: Ramp-up current diffusion with varying heating

In this exercise you will test the effect of differently timed heating during a plasma current ramp.

## Contents

- ITER simulation setup
- EXERCISES

## ITER simulation setup

First we set up the RAPTOR simulation.

    clear
    run ../../RAPTOR_path.m

    % load the default parameters for ITER
    config = RAPTOR_config('ITER'); % load default params
    config.grid.tgrid = [0:0.1:1,3:2:140];

    % tranport model: choose empirical model with
    % transport reduction at low shear.
    config.chi_e = chi_e('FF');
    config.chi_e.params.cano = 4;
    config.chi_e.params.cneo = 0.1;

    % Heating actuators: EC and NBI
    config.nbhcd = nbhcd('nbhcd_gaussian');
    config.nbhcd.params.active = true;
    config.nbhcd.params.rdep = [0.26]; %
    config.nbhcd.params.wdep = [0.15]; % broad heating
    config.nbhcd.params.wdep_out = [0.75]; % broad heating
    config.nbhcd.params.cd_eff = [5]; % current drive
    config.nbhcd.params.uindices = [2];% index in input vector

    config.echcd = echcd('echcd_gaussian');
    config.echcd.params.active = true;
    config.echcd.params.rdep = [0.2 0.4 0.55 ]; % two actuators, set rdep=0 for first, rdep=0.4 for second
    config.echcd.params.wdep = [.05 .05 .05 ];  % wdep =0.35 for each
    config.echcd.params.cd_eff = [10 10 10];  % current drive efficiency factor: pure ECH for first, co-ECCD for second
    config.echcd.params.uindices = [3 4 5]; % index of power for each actuator in input vector

    % radiation modules etc
    config.prad.active = false;
    config.pei.active = true;
    config.palpha.active = false;

    [~,model,params,init] = RAPTOR_config(config); % generate model structure for these params.
    params.debug.iterdisp = 10; % display every 10

    % Plasma current ramp
    rampfun = @(t,tmin,ymin,tmax,ymax) max(ymin,min((ymax-ymin)/(tmax-tmin)*(t-tmin),ymax-ymin)+ymin); % anonymous function for ramps

    U(1,:) = rampfun(params.tgrid.tgrid,0,4e6,100,12e6); % input Ip trace
    U(2,:) = zeros(size(U(1,:))); % placeholder, will replace this with heating later.
    U(3,:) = zeros(size(U(1,:))); % placeholder, will replace this with heating later.
    U(4,:) = zeros(size(U(1,:))); % placeholder, will replace this with heating later.
    U(5,:) = zeros(size(U(1,:))); % placeholder, will replace this with heating later.

    % initial conditions
    init.te0 = 2e3;
    init.ne0 = 1e19;
    [x0,g0,v0] = RAPTOR_initial_conditions(U(1),model,init); % Define the initial condition
    v0 = v0*ones(1,params.tgrid.nt);

    % specify density ramp: multiply initial profile by ne0(t)
    negauss = model.te.LamTegauss*v0(model.ne.ind,1);
    ne0 = rampfun(params.tgrid.tgrid,0,1,100,5);
    negauss_varying = negauss*ne0;
    v0(model.ne.ind,:) = model.te.LamTegauss \ negauss_varying;
    v0(model.ni.ind,:) = 0.9*v0(model.ne.ind,:);

    % Run the simulation
    simres = RAPTOR_predictive(x0,g0,v0,U,model,params);
    out = RAPTOR_out(simres,model,params);
    RAPTOR_plot_GUI(out);

    Loading default configuration for ITER
    loading CHEASE equilibrium from /Users/ffelici/Dropbox/4K480 - Dropbox/Exercises/Week7/RAPTOR_exercise/chease_equils/ITER_hybrid_citrin_equil_cheasedata
    Scaling Te initial condition to match edge value boundary value (200)
      istep  telaps newt     res   t[ s]  dt[ s]  Ip[MA] Icd[MA] Ibs[MA] Ioh[MA]      qe    qmin      q0   Vl[V] Te0[keV] ne0[e19]  Wi[MJ] We[MJ]  f_ss
          1    0.03    4 1.2e-10       0     0.1       4       0  0.0559    3.95    14.7    3.68    3.68 6.6e-01    1.58    1.00   22.69    0.57 9.2e+00
         11    0.26    3 1.9e-10       1       2    4.08       0  0.0358    4.05    14.5     2.6     2.6 1.3e+00    1.17    1.04   24.41    0.46 4.3e+00
         21    0.46    2 9.5e-11      21       2    5.68       0  0.0535    5.63    10.4     1.2     1.2 1.5e+00    1.56    1.84   53.82    0.97 3.4e+00
         31    0.64    2 4.6e-11      41       2    7.28       0  0.0713    7.21     8.1   0.851   0.851 1.5e+00    1.88    2.64   95.55    1.63 3.5e+00
         41    0.81    2 5.3e-11      61       2    8.88       0  0.0883     8.8    6.64   0.657   0.657 1.6e+00    2.16    3.44  149.89    2.41 3.5e+00
         51       1    2 5.5e-11      81       2    10.5       0   0.104    10.4    5.63   0.533   0.533 1.6e+00    2.43    4.24  217.17    3.32 3.5e+00
         61     1.2    3 8.3e-11     101       2      12       0   0.119    11.9    4.92   0.448   0.448 1.6e+00    2.69    5.00  296.17    4.30 3.3e+00
         71     1.4    2 7.7e-10     121       2      12       0   0.121    11.9    4.92   0.381   0.381 1.3e+00    3.07    5.00  334.19    4.59 1.9e+00

## EXERCISES

1. By varying `U(1,:)`, investigate the effect of different plasma current ramp rates on the speed of penetration of inductive current, the evolution of the loop voltage profile `U_{pl}`, and the `q` profile.
2. Returning to the original Ip time trace, now use `U(2,:)` to add 16MW of NBI power starting at different times during the ramp-up. Examine the effect on the `T_e` `q` and `jpar` profiles and explain the results.
3. Vary U(3:5,:) to add at most 20MW of off-axis EC current drive at different times, and try to obtain a transport barrier by getting a reversed-shear q profile.
4. Find a combination of timing for heating and current drive to keep qmin above 1 for as long as possible.