rundke_runaway_taur

PURPOSE ^

This script is used to run LUKE for the runaway problem

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 This script is used to run LUKE for the runaway problem

 by J. Decker, Y. Peysson and E. Nilsson

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %
0002 % This script is used to run LUKE for the runaway problem
0003 %
0004 % by J. Decker, Y. Peysson and E. Nilsson
0005 %
0006 clear all
0007 clear mex
0008 clear functions
0009 close all
0010 warning('off')
0011 %
0012 permission = test_permissions_yp;
0013 %
0014 if ~permission 
0015     disp('Please move the script to a local folder where you have write permission before to run it')
0016     return;
0017 end
0018 %
0019 % *********************** This part must be specified by the user *****************************
0020 %
0021 % printing option
0022 %
0023 id_simul = 'Runaway_alpha3_sync';%Simulation ID
0024 p_opt = -1;% printing and saving options : (-1) do nothing (0) print figures (1) print figures and save figures and results (2) save figures and results
0025 %
0026 [qe,me,~,~,e0,~,~,mc2] = pc_dke_yp;%Universal physics constants
0027 %
0028 % calculation mode : (0) quasi steady state (1) time evolution
0029 %
0030 opt.timevol = 1;
0031 %
0032 % normalized electric field (with respect to the Critical field Ec)
0033 %
0034 alpha = 3;% E/Ec
0035 %
0036 % temperature betath2 = Te/mc2
0037 % (betath2 = 10^(-6) is validated for NR limit)
0038 %
0039 betath2 = 0.01;% Te/mc2
0040 %
0041 % the ratio of the syncrotron reaction force to the collisional drag scales
0042 % as taurinv = 1/taur
0043 % -> set taurinv = 0 or opt.synchro_mode = 0 to ignore syncrotron reaction force
0044 %
0045 % note :
0046 %   - without the syncrotron reaction force, and with a single cold ion
0047 %   species of charge Zi, the normalized runaway rate - with respect to the
0048 %   electron density and ee collision time - only depends upon Zi, alpha and betath2
0049 %
0050 %   - with the syncrotron reaction force, an additional parameter is
0051 %   provived by taurinv
0052 %
0053 %   - the link between wpr=wc2/wp2 and taurinv is :
0054 %       taurinv = wpr*(2/3)/ln(Lambda)
0055 %
0056 %   - the magnetic field being fixed, the density is adjusted in LUKE according to bhat
0057 %
0058 taurinv = 0.6;
0059 %
0060 opt.synchro_mode = 1;
0061 %
0062 % ion charge (single species, cold ions)
0063 %
0064 Zi = 1;
0065 %
0066 Emin = NaN;%runaway energy threshold in MeV (limit where electrons are "counted")
0067 % Emax = (sqrt(20^2*betath2+1)-1)*mc2/1e3;%1;%grid energy threshold in MeV [(sqrt(pnmax_S^2*betath2+1)-1)*mc2/1e3 = 0.63163 corresponds to pnmax_S = 20 for betath = 0.1]
0068 %
0069 % collision mode :
0070 % (0) : Relativistic Maxwellian background
0071 % (1) : High-velocity limit
0072 % (2) : Linearized Belaiev-Budker (momentum-conserving)
0073 %
0074 opt.coll_mode = 0;
0075 opt.bounce_mode = 0;%1;% bounce-averaged calculation
0076 opt.boundary_mode_f = 0;% Enforcing the Maxwellian initial value at the first "boundary_mode_f" grid points
0077 %
0078 % normalization mode :
0079 % (0) : "free" mode
0080 % (1) : normalization of f0 maintained to its initial (maxwellian) value. DO NOT use in the runaway problem
0081 % (2) : normalization of f0 maintained to its value at the previous time. Use only in the runaway problem with (+1i)
0082 % (3) : injection at center of particles lost at boundary (use only for stream function)
0083 % (... + 1i) : compensate for numerical error after each time step, acounting for boundary losses.
0084 opt.norm_mode_f = 1i;
0085 %
0086 % time grid (normalized to collision time) -> you can specify :
0087 % - linear arbitrary grid with tn array                 : opt.tnmin = 0 ;opt.tn = 1000:1000:10000,dtn = NaN;opt.tnmin = 0
0088 % - linear arbitrary grid with dtn array                : opt.tnmin = 0 ;opt.tn = NaN;dtn = 1000*ones(1,10);
0089 % - linear grid with tnmax and grid step                : opt.tnmin = 0 ;opt.tn = 10000;dtn = 1000;
0090 % - linear grid with tnmax and number of grid steps     : opt.tnmin = 0 ;opt.tn = 10000;dtn = 10i;
0091 % - log grid with tnmin, tnmax and number of grid steps : opt.tnmin = 1 ;opt.tn = 10000;dtn = 10;
0092 %
0093 % opt.tnmin = 0;% > 0 for log scale
0094 % opt.tn = 10000;% 10000 is time for asymptotic solution
0095 % opt.dtn = 1000;% 10 time steps required for accurate runaway solution - see rundke_dtn
0096 % graph.itdisp = [1,5,10];% display times - only used if opt.timevol > 0
0097 %
0098 % opt.tnmin = 1;% > 0 for log scale
0099 % opt.tn = 1e5;% 10000 is time for asymptotic solution
0100 % opt.dtn = 51;% 10 time steps required for accurate runaway solution - see rundke_dtn
0101 % graph.itdisp = 11:10:51;% display times - only used if opt.timevol > 0
0102 %
0103 opt.tnmin = 1e0;% > 0 for log scale
0104 %
0105 opt.tn = [1e8,1e9];%[1e7,1e8];%1e10;% 10000 is time for asymptotic solution
0106 opt.dtn = [161,90];%[141,90];%161;%21;%201;% 10 time steps required for accurate runaway solution - see rundke_dtn
0107 graph.itdisp = [61:40:141,251];%[61:40:141,231];%41:40:161;%5:4:17;%5:4:21;%81:40:201;%1:4:17;% display times - only used if opt.timevol > 0
0108 %
0109 % opt.tn = [1e7,1e8];%1e10;% 10000 is time for asymptotic solution
0110 % opt.dtn = [141,90];%161;%21;%201;% 10 time steps required for accurate runaway solution - see rundke_dtn
0111 % graph.itdisp = [61:40:141,231];%41:40:161;%5:4:17;%5:4:21;%81:40:201;%1:4:17;% display times - only used if opt.timevol > 0
0112 %
0113 % opt.tnmin = 1;%0;% > 0 for log scale
0114 % opt.tn = 1e8;%1e9;%1e10;% 10000 is time for asymptotic solution
0115 % opt.dtn = 17;%10*1i;%100*1i;%161;%21;%201;% 10 time steps required for accurate runaway solution - see rundke_dtn
0116 % graph.itdisp = [1,10];%[1,10,100];%41:40:161;%5:4:17;%5:4:21;%81:40:201;%1:4:17;% display times - only used if opt.timevol > 0
0117 %
0118 % momentum space grid -> you can specify nmhu_S and either
0119 % - the momentum grid pn_S directly
0120 % - the parameters np_S, pnmax_S, np_tail, pnmax_S_tail as follows
0121 %
0122 grid.nmhu_S = 141;% number of pitch angle grid points
0123 grid.sfac1 = 80;%40;% % reduction factor for fine grid near abs(mhu) = 1
0124 grid.snmhu1 = 5; % number of fine grid points near abs(mhu) = 1
0125 %
0126 % momentum grid contruction option :
0127 %   (0) do not adjust number of fine and coarse grid points
0128 %   (1) keep fine grid step constant (typically, 0.2)
0129 %       if isreal(np_tail) : keep coarse grid steps constant (typically, 1). Note : do not enforce np_S and np_tail variations
0130 %       if isimag(np_tail), enforce continuity of grid step size at pnmax_S. Note : do not enforce np_S and np_tail variations
0131 %
0132 grid.opt = 1;
0133 %
0134 grid.np_S = 141;% number of bulk momentum grid points
0135 grid.pnmax_S = 28;%sqrt(((1 + Emax*1e3/mc2)^2 - 1)/betath2);% maximum of bulk momentum (normalized to pT) [pn = 28 corresponds to 1 MeV electrons for betath = 0.1]
0136 grid.np_tail = 4i;%960;%558;%331;%217;%103;%100;% number of tail momentum grid points
0137 grid.pnmax_S_tail = 1967;%988;%597;%401;205;% maximum of tail momentum (normalized to pT) [107,205,303,401,499,597,793,988,1184,1576,1967] corresponds to [5,10,15,20,25,30,40,50,60,80,100] MeV electrons for betath = 0.1
0138 %
0139 % avalanche modelling :
0140 %
0141 % dkeparam.pnmin0_KO is the low threshold on initial primary electrons for the knock-on operator
0142 % The condition pnmin0_KO <= pnmax_S is enforced so that the source can be calculated
0143 % - For pnmin0_KO = NaN, the limit is set to pnmax_S
0144 %
0145 % dkeparam.pnmax1_KO is the high threshold on initial secondary (bulk) electrons for the knock-on operator
0146 % in principle, pnmax1_KO <= pnmin2_KO so that secondary electrons can only 'lose energy'
0147 % - For pnmax1_KO = 0, the bulk population is taken as f(1)/fM(1), a logical estimate considering the sink term
0148 % - For pnmax1_KO = NaN, the limit is set to pnmin2_KO
0149 %
0150 % dkeparam.pnmin2_KO is the low threshold on final secondary electrons for the knock-on operator
0151 % - If pnmin2_KO == NaN, the current value of pc (or pnmin_S) is used
0152 % - If pnmin2_KO is imaginary, it is normalized to the actual thermal momentum (instead of reference)
0153 %
0154 % dkeparam.pnmax2_KO is the high threshold on final secondary electrons for the knock-on operator
0155 % in principle, as rosenbluth assumes p0 > p1 we must separate the domain of source runaways (ex : 1MeV) from that of secondary electrons.
0156 % Therefore, we should ensure pnmax2_KO <= pnmin0_KO
0157 % - For pnmax2_KO = NaN, the limit is set to pnmin0_KO
0158 % - If pnmax2_KO > pnmax_S (which violate the principle described above), the source between pnmax_S and pnmax2_KO is calculated as a "number"
0159 %
0160 opt.avalanche_mode = false;%true;%
0161 opt.pnmin0_KO = NaN;% pnmin0_KO = 28 corresponds to 1 MeV electrons for betath = 0.1
0162 opt.pnmax1_KO = 0;%NaN;%grid.pnmax_S;%
0163 opt.pnmin2_KO = 1i;%NaN;%1;% 1i is the "natural" limit as for lower energies it is simply the identity operator
0164 opt.pnmax2_KO = NaN;%100;%
0165 %
0166 path_simul = '';%Simulation path
0167 %
0168 if opt.bounce_mode == 0,
0169     id_equil = 'TScyl';% cylindrical equilibrium, rho_S has no effect
0170 else
0171     id_equil = 'TScirc_e1';% toroidal equilibirum with a/R = 1 : then rho_S = r/R
0172 end
0173 id_wave = '';
0174 %
0175 rho_S = 0.5;
0176 %
0177 opt.heavyions = true;
0178 opt.adjustB = true;
0179 %
0180 opt.keyboard = true;
0181 opt.color = true;
0182 %
0183 graph.tnc = true;
0184 graph.xec = true;
0185 graph.xlog = 1;
0186 graph.xlim = [1e-3,1e2];
0187 graph.xtick = 10.^(-3:2);
0188 %
0189 if alpha == 2,
0190     %
0191     % E/Ec = 2
0192     %
0193     graph.ylim_norm = [1e-25,1e1];
0194     graph.ytick_norm = 10.^(-25:5:5);
0195     graph.ylim_gamma = [1e-26,1e-12];
0196     graph.ytick_gamma = 10.^(-26:4:-12);
0197     graph.ylim_f = [1e-20,1e0];%[1e-45,1e5];
0198     graph.ytick_f = 10.^(-20:4:0);%10.^(-45:5:5);
0199 elseif alpha == 2.5,
0200     %
0201     % E/Ec = 2.5
0202     %
0203     graph.ylim_norm = [1e-15,1e1];
0204     graph.ytick_norm = 10.^(-15:3:0);
0205     graph.ylim_gamma = [1e-25,1e-10];
0206     graph.ytick_gamma = 10.^(-25:3:-10);
0207     graph.ylim_f = [1e-45,1e5];
0208     graph.ytick_f = 10.^(-45:5:5);
0209 elseif alpha == 3,
0210     %
0211     % E/Ec = 3
0212     %
0213     graph.ylim_norm = [1e-11,1e1];%[1e-25,1e1];
0214     graph.ytick_norm = 10.^(-10:2:0);%10.^(-25:5:5);
0215     graph.ylim_gamma = [1e-12,1e-2];
0216     graph.ytick_gamma = 10.^(-12:2:-2);
0217     graph.ylim_f = [1e-20,1e0];%[1e-35,1e5];
0218     graph.ytick_f = 10.^(-20:4:0);%10.^(-35:5:5);
0219     %
0220     graph.dp_cyl = 0;%0.2;
0221     graph.cont = (0:3:100)*1e-11;
0222 %     graph.cont = 1e-7*(-31:2:15)/8;%-3.875e-7:0.25e-7:1.875e-7;%-4e-7:0.25e-7:2e-7;
0223     graph.pnmax_disp = 300;
0224     graph.xlim_disp = [-5,20];
0225     graph.ylim_disp = [0,10];
0226     graph.xtick_disp = -5:5:20;
0227     graph.ytick_disp = 0:5:10;
0228     %
0229 elseif alpha == 5,
0230     %
0231     % E/Ec = 5
0232     %
0233     graph.ylim_norm = [1e-9,1e1];
0234     graph.ytick_norm = 10.^(-10:2:2);
0235     graph.ylim_gamma = [1e-12,1e-4];
0236     graph.ytick_gamma = 10.^(-12:2:-4);
0237 else
0238     graph.ylim_norm = NaN;
0239     graph.ylim_gamma = NaN;
0240 end
0241 %
0242 %************************************************************************************************************************************
0243 %
0244 dp_bulk = grid.pnmax_S/(grid.np_S - 1);
0245 dp_fine = (grid.pnmax_S_tail - grid.pnmax_S)/grid.np_tail;
0246 pfac = imag(grid.np_tail);
0247 if grid.opt == 1,
0248     grid.np_S = 1 + round(grid.pnmax_S/dp_bulk);
0249     if pfac == 0,
0250         grid.np_tail = round((grid.pnmax_S_tail - grid.pnmax_S)/dp_fine);
0251     else
0252         grid.np_tail = round((grid.np_S - 1)*pfac*((grid.pnmax_S_tail/grid.pnmax_S)^(1/pfac) - 1));
0253         grid.opt = pfac;
0254     end
0255 end
0256 %
0257 opt.pnmin_S = sqrt(((1 + Emin*1e3/mc2)^2 - 1)/betath2);
0258 wpr = -taurinv*1i;% real wpr : wpr, positive imaginary part : bhat, negative imaginary part : taurinv.
0259 %
0260 % RUN LUKE
0261 %
0262 [RR,mksa,Ec,f,tn,tRR,tnorm,fgrid,tacc,pmhucrit,ZXXS] = frundke_runaway(id_simul,alpha,betath2,wpr,Zi,opt,grid,id_equil,id_wave,rho_S);
0263 %
0264 %************************************************************************************************************************************
0265 %
0266 % PROCESS DATA
0267 %
0268 fproc_runaway(RR,mksa,Ec,f,tn,tRR,tnorm,fgrid,tacc,pmhucrit,ZXXS,alpha,betath2,wpr,Zi,opt,grid,id_equil,rho_S,graph,p_opt,id_simul);
0269 %
0270 %************************************************************************************************************************************
0271 %
0272 if p_opt > 0,
0273     filename = [path_simul,'DKE_RESULTS_',id_simul,'.mat'];
0274     save(filename);
0275     info_dke_yp(2,['Data saved in ',filename]);
0276 end

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.