RAPTOR Tutorial 1: Simplest possible RAPTOR run.

RAPTOR (RApid Plasma Transport simulatOR) is a code that rapidly solves the tokamak 1D plasma transport PDEs.

It has been designed to be modular and simple to run from a single scripts, by modifying parameters.

Contents

RAPTOR workflow

A typical stand-alone run of RAPTOR consits of the steps:

  1. Define environment (add path)
  2. load default parameters
  3. Customize default parameters
  4. Create RAPTOR model for custom parameter structure.
  5. Define input variables (actuators)
  6. Prepare initial conditions
  7. Run RAPTOR.

The simplest possible RAPTOR run

Before going into details, we will perform all the above steps once in their simplest form.

First, add the RAPTOR_code directory at the end of your MATLAB path

addpath(fullfile(pwd,'..','RAPTOR_code'),'-end'); % add RAPTOR path

Then, load the default parameters,

[~,params] = RAPTOR_config; % load default params

This loads the default parameter structure, representing a TCV-type plasma setup. We could optionally modify this structure here, but for now we will use the default structure directly to generate a RAPTOR model structure.

[model,params] = RAPTOR_config(params); % generate model structure for these params.

The model structure contains everything that can be pre-calculated, including matrices with spline bases, fixed profiles, and much more.

In the default case we only need to define the actuator input for Ip at all times.

This first tutorial introduces the basic steps needed for a single RAPTOR run in predictive mode.

U = 80e3*ones(size(params.grid.tgrid)); % input Ip trace: constant 80kA

To start the simulation, RAPTOR needs an initial condition, to load the default:

[x0,g0,v0] = RAPTOR_initial_conditions(U(1),model,params); % Define the initial condition
Scaling Te initial condition to match edge value in params.BC.Te.value=(50)

These three vectors contain time-varying RAPTOR data and will appear throughout the code.

Now we are ready to run RAPTOR - this will display some plasma quantities as they evolve.

simres = RAPTOR_predictive(x0,g0,v0,U,model,params);
  istep  telaps newt     res   t[ms]  dt[ms]    IpkA Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV]  Wi[kJ]  We[kJ]   f_ss  
      1    0.03    5 1.1e-14       0     1.0    80.0    0.00   22.21   58.18   15.89    6.76    8.78 8.6e+00    0.19    0.09    0.25 3.2e+01 
      2    0.04    4 3.9e-14       1     1.0    80.0    0.00   19.42   60.90   15.89    5.82    6.69 6.7e+00    0.19    0.10    0.25 2.0e+01 
      3    0.05    4 2.4e-14       2     1.0    80.0    0.00   18.28   62.00   15.89    5.15    5.33 5.9e+00    0.20    0.11    0.26 1.5e+01 
      4    0.06    3 5.0e-14       3     1.0    80.0    0.00   17.69   62.58   15.89    4.48    4.48 5.4e+00    0.21    0.12    0.27 1.3e+01 
      5    0.07    3 1.1e-14       4     1.0    80.0    0.00   17.30   62.96   15.89    3.90    3.90 5.1e+00    0.22    0.12    0.28 1.1e+01 
      6    0.09    3 6.7e-14       5     1.0    80.0    0.00   17.02   63.24   15.89    3.49    3.49 4.8e+00    0.23    0.13    0.28 9.2e+00 
      7    0.10    3 3.9e-14       6     1.0    80.0    0.00   16.79   63.46   15.89    3.17    3.17 4.7e+00    0.24    0.13    0.29 8.0e+00 
      8    0.11    3 3.2e-14       7     1.0    80.0    0.00   16.61   63.64   15.89    2.93    2.93 4.5e+00    0.25    0.13    0.29 7.0e+00 
      9    0.12    3 8.2e-14       8     1.0    80.0    0.00   16.46   63.79   15.89    2.74    2.74 4.4e+00    0.26    0.14    0.29 6.2e+00 
     10    0.13    3 9.4e-14       9     1.0    80.0    0.00   16.33   63.91   15.89    2.58    2.58 4.3e+00    0.27    0.14    0.30 5.5e+00 
     11    0.14    3 7.9e-14      10     1.0    80.0    0.00   16.23   64.02   15.89    2.46    2.46 4.2e+00    0.28    0.14    0.30 4.9e+00 
     12    0.15    3 5.4e-14      11     1.0    80.0    0.00   16.13   64.11   15.89    2.35    2.35 4.1e+00    0.28    0.14    0.30 4.3e+00 
     13    0.16    3 1.5e-13      12     1.0    80.0    0.00   16.06   64.18   15.89    2.26    2.26 4.0e+00    0.29    0.15    0.30 3.9e+00 
     14    0.17    3 1.6e-13      13     1.0    80.0    0.00   15.99   64.25   15.89    2.19    2.19 4.0e+00    0.29    0.15    0.31 3.5e+00 
     15    0.18    3 7.8e-14      14     1.0    80.0    0.00   15.93   64.31   15.89    2.13    2.13 3.9e+00    0.30    0.15    0.31 3.1e+00 
     16    0.20    3 2.2e-13      15     1.0    80.0    0.00   15.88   64.36   15.89    2.07    2.07 3.9e+00    0.30    0.15    0.31 2.8e+00 
     17    0.21    3 9.4e-14      16     1.0    80.0    0.00   15.83   64.40   15.89    2.03    2.03 3.8e+00    0.30    0.15    0.31 2.5e+00 
     18    0.22    3 1.5e-13      17     1.0    80.0    0.00   15.79   64.44   15.89    1.99    1.99 3.8e+00    0.31    0.15    0.31 2.3e+00 
     19    0.23    3 1.2e-13      18     1.0    80.0    0.00   15.75   64.48   15.89    1.95    1.95 3.8e+00    0.31    0.16    0.31 2.0e+00 
     20    0.24    3 4.3e-14      19     1.0    80.0    0.00   15.72   64.51   15.89    1.92    1.92 3.7e+00    0.31    0.16    0.31 1.8e+00 
  istep  telaps newt     res   t[ms]  dt[ms]    IpkA Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV]  Wi[kJ]  We[kJ]   f_ss  
     21    0.25    2 8.4e-13      20     1.0    80.0    0.00   15.69   64.54   15.89    1.89    1.89 3.7e+00    0.32    0.16    0.32 1.7e+00 
     22    0.26    2 5.6e-13      21     1.0    80.0    0.00   15.67   64.56   15.89    1.87    1.87 3.7e+00    0.32    0.16    0.32 1.5e+00 
     23    0.27    2 3.8e-13      22     1.0    80.0    0.00   15.64   64.59   15.89    1.85    1.85 3.7e+00    0.32    0.16    0.32 1.4e+00 
     24    0.28    2 2.6e-13      23     1.0    80.0    0.00   15.62   64.61   15.89    1.83    1.83 3.6e+00    0.32    0.16    0.32 1.2e+00 
     25    0.28    2 1.7e-13      24     1.0    80.0    0.00   15.61   64.62   15.89    1.81    1.81 3.6e+00    0.32    0.16    0.32 1.1e+00 
     26    0.30    2 2.4e-13      25     1.0    80.0    0.00   15.59   64.64   15.89    1.79    1.79 3.6e+00    0.32    0.16    0.32 1.0e+00 
     27    0.30    2 7.6e-14      26     1.0    80.0    0.00   15.57   64.66   15.89    1.78    1.78 3.6e+00    0.33    0.16    0.32 9.3e-01 
     28    0.31    2 1.3e-13      27     1.0    80.0    0.00   15.56   64.67   15.89    1.77    1.77 3.6e+00    0.33    0.16    0.32 8.4e-01 
     29    0.32    2 1.3e-13      28     1.0    80.0    0.00   15.55   64.68   15.89    1.76    1.76 3.6e+00    0.33    0.16    0.32 7.6e-01 
     30    0.33    2 3.6e-13      29     1.0    80.0    0.00   15.54   64.69   15.89    1.75    1.75 3.5e+00    0.33    0.16    0.32 6.9e-01 
     31    0.34    2 1.4e-13      30     1.0    80.0    0.00   15.53   64.70   15.89    1.74    1.74 3.5e+00    0.33    0.16    0.32 6.3e-01 
     32    0.35    2 3.5e-13      31     1.0    80.0    0.00   15.52   64.71   15.89    1.73    1.73 3.5e+00    0.33    0.16    0.32 5.7e-01 
     33    0.36    2 3.0e-13      32     1.0    80.0    0.00   15.51   64.72   15.89    1.72    1.72 3.5e+00    0.33    0.16    0.32 5.2e-01 
     34    0.37    2 9.4e-14      33     1.0    80.0    0.00   15.50   64.73   15.89    1.72    1.72 3.5e+00    0.33    0.16    0.32 4.8e-01 
     35    0.38    2 3.0e-13      34     1.0    80.0    0.00   15.50   64.73   15.89    1.71    1.71 3.5e+00    0.33    0.16    0.32 4.3e-01 
     36    0.39    2 1.8e-13      35     1.0    80.0    0.00   15.49   64.74   15.89    1.71    1.71 3.5e+00    0.33    0.16    0.32 3.9e-01 
     37    0.40    2 3.1e-13      36     1.0    80.0    0.00   15.48   64.74   15.89    1.70    1.70 3.5e+00    0.33    0.16    0.32 3.6e-01 
     38    0.40    2 1.6e-13      37     1.0    80.0    0.00   15.48   64.75   15.89    1.70    1.70 3.5e+00    0.33    0.16    0.32 3.3e-01 
     39    0.41    2 2.7e-13      38     1.0    80.0    0.00   15.47   64.75   15.89    1.69    1.69 3.5e+00    0.34    0.16    0.32 3.0e-01 
     40    0.42    2 1.9e-13      39     1.0    80.0    0.00   15.47   64.76   15.89    1.69    1.69 3.5e+00    0.34    0.16    0.32 2.7e-01 
  istep  telaps newt     res   t[ms]  dt[ms]    IpkA Icd[kA] Ibs[kA] Ioh[kA]      qe    qmin      q0   Vl[V] Te0[keV]  Wi[kJ]  We[kJ]   f_ss  
     41    0.43    2 2.4e-13      40     1.0    80.0    0.00   15.47   64.76   15.89    1.68    1.68 3.5e+00    0.34    0.16    0.32 2.5e-01 
     42    0.44    2 4.3e-13      41     1.0    80.0    0.00   15.46   64.76   15.89    1.68    1.68 3.5e+00    0.34    0.16    0.32 2.3e-01 
     43    0.45    2 1.9e-13      42     1.0    80.0    0.00   15.46   64.77   15.89    1.68    1.68 3.5e+00    0.34    0.16    0.32 2.1e-01 
     44    0.46    2 4.3e-13      43     1.0    80.0    0.00   15.46   64.77   15.89    1.68    1.68 3.5e+00    0.34    0.16    0.32 1.9e-01 
     45    0.46    2 2.0e-13      44     1.0    80.0    0.00   15.45   64.77   15.89    1.67    1.67 3.5e+00    0.34    0.16    0.32 1.7e-01 
     46    0.47    2 4.4e-13      45     1.0    80.0    0.00   15.45   64.78   15.89    1.67    1.67 3.5e+00    0.34    0.16    0.32 1.6e-01 
     47    0.48    2 1.0e-13      46     1.0    80.0    0.00   15.45   64.78   15.89    1.67    1.67 3.5e+00    0.34    0.17    0.32 1.4e-01 
     48    0.49    2 1.6e-13      47     1.0    80.0    0.00   15.45   64.78   15.89    1.67    1.67 3.5e+00    0.34    0.17    0.32 1.3e-01 
     49    0.50    2 2.3e-13      48     1.0    80.0    0.00   15.45   64.78   15.89    1.67    1.67 3.5e+00    0.34    0.17    0.32 1.2e-01 
     50    0.50    2 2.5e-13      49     1.0    80.0    0.00   15.44   64.78   15.89    1.67    1.67 3.5e+00    0.34    0.17    0.32 1.1e-01 
     51    0.51    2 1.3e-13      50     1.0    80.0    0.00   15.44   64.78   15.89    1.66    1.66 3.5e+00    0.34    0.17    0.32 9.8e-02 

end of tutorial 1