0001
0002
0003
0004
0005
0006 clear all
0007 clear mex
0008 clear functions
0009 close all
0010 warning('off')
0011 for Zii = 1,
0012
0013 permission = test_permissions_yp;
0014
0015 if ~permission
0016 disp('Please move the script to a local folder where you have write permission before to run it')
0017 return;
0018 end
0019
0020
0021
0022 pnmax_S = 28;
0023 np_S = 201;
0024 nmhu_S = 101;
0025 f_pmax = floor(100/pnmax_S);
0026
0027 mfactor = 100;
0028
0029
0030
0031
0032
0033
0034
0035 betath2 = 1e-2;
0036
0037 alpha = 4;
0038 epsi = alpha*betath2;
0039
0040 pnmin_S = NaN;
0041
0042
0043
0044 Zi = Zii;
0045
0046
0047
0048
0049
0050
0051 coll_mode = 0;
0052
0053 id_simul = 'Runaway';
0054
0055
0056
0057
0058
0059
0060 psin_S = [];
0061 rho_S = [0.1];
0062
0063 id_path = '';
0064 path_path = '';
0065
0066 id_equil = 'TScyl';
0067
0068 path_equil = '';
0069
0070 id_dkeparam = 'UNIFORM10010020';
0071 path_dkeparam = '';
0072
0073 id_display = 'PARTIAL_VISUAL';
0074 path_display = '';
0075
0076 id_transpfaste = 'magneticturbulence';
0077 path_transpfaste = '';
0078
0079
0080
0081
0082 [dkepath,equil,dkeparam,dkedisplay,dummy,dummy,transpfaste] = load_structures_yp('dkepath',id_path,path_path,'equil',id_equil,path_equil,'dkeparam',id_dkeparam,path_dkeparam,'dkedisplay',id_display,path_display,'','','','','','','transpfaste',id_transpfaste,path_transpfaste);
0083
0084
0085
0086
0087 if exist('dmumpsmex','file') == 3,
0088 dkeparam.invproc = -2;
0089 end
0090
0091 dkeparam.pnmin_S = pnmin_S;
0092 dkeparam.pnmin2_KO = 1*1i;
0093 dkeparam.pnmax2_KO = pnmax_S*f_pmax;
0094 dkeparam.pnmax_S = pnmax_S;
0095 dkeparam.boundary_mode_f = 0;
0096 dkeparam.norm_mode_f = 0;
0097 dkeparam.timevol = 1;
0098
0099 dkeparam.tn = 30000;
0100 dkeparam.dtn = 1000;
0101 dkeparam.coll_mode = coll_mode;
0102 dkeparam.bounce_mode = 0;
0103 dkeparam.avalanche_mode = 1;
0104
0105 options_fzero = optimset('fzero');
0106 options_fzero.Display = 'iter';
0107 options_fzero.TolX = 1e-10;
0108 dkeparam.options_fzero = options_fzero;
0109
0110 transpfaste.Dr0 = 0;
0111
0112
0113 equil.pzTi = 1e-10*ones(size(equil.pzTi));
0114
0115 [qe,me,dummy,~,e0,dummy,dummy,mc2,clum] = pc_dke_yp;
0116
0117 equil.pTe = betath2*mc2*ones(size(equil.pTe));
0118
0119 equil.zZi = [1,1,1,Zi];
0120 equil.pzni = [0;0;0;1/Zi]*equil.pne;
0121
0122 epsi = alpha*betath2;
0123
0124 xnre_init = 0;
0125
0126 ohm = ohm_flat(equil,epsi);
0127
0128 ohm.xnre_init = xnre_init;
0129
0130 dkeparam.pn_S = linspace(0,pnmax_S,np_S);
0131 dkeparam.nmhu_S = nmhu_S;
0132 dkeparam.psin_S = psin_S;
0133 dkeparam.rho_S = rho_S;
0134 dkeparam.mfactor = mfactor;
0135
0136
0137
0138 fitparam.mode_equil = 1;
0139 fitparam.nharm = NaN;
0140 fitparam.ngridresample = 1001;
0141 fitparam.method = 'spline';
0142
0143 equil.equil_fit = fitequil_yp(equil,fitparam.mode_equil,fitparam.method,fitparam.ngridresample,fitparam.nharm);
0144
0145 [Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa,XXsinksource,dke_warnings] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,'',transpfaste,'',[],[]);
0146
0147 RR_an = RR_rosenbluth_en(alpha, Zi, mksa.ne_ref, mksa.lnc_e_ref, equilDKE.ap*equilDKE.xrho/equilDKE.Rp);
0148
0149
0150 Rfrac = Znorm(end).x_Rfrac_0_fsav;
0151
0152 xnre = cell2mat(dke_out.xnorm_rep);
0153
0154 RRAint = Znorm(1,end).xRRAint./xnre(end-1);
0155 RRAinttot = Znorm(1,end).xRRAtot./xnre(end-1);
0156 RR = dke_out.XxRR_fsav{end};
0157 RR = RR(end,:);
0158
0159
0160 for it = 1:(length(xnre)-1)
0161 gr(it) = (xnre(it+1) - xnre(it))/xnre(it)/dkeparam.dtn;
0162 end
0163 figure;graph1D_jd(1:(length(xnre)-1),gr,0,0,'iteration','growth rate (s^-1)','Numerical growth rate',NaN,NaN,NaN,'-','o','b',1)
0164 hold on
0165
0166
0167
0168 if dkeparam.avalanche_mode == 1
0169 pnext = pnmax_S*f_pmax;
0170 gamma_max = sqrt((pnmax_S*mksa.betath_ref)^2+1);
0171 gamma_ext = sqrt((pnext*mksa.betath_ref)^2+1);
0172
0173
0174
0175
0176 dtn_min = me*clum*(sqrt(gamma_ext^2-1)-sqrt(gamma_max^2-1))/(qe*mksa.Edreicer_ref*epsi)*mksa.nhu_ref;
0177
0178
0179 gam = gamma_max:0.01:(gamma_max+10);
0180 dt_acc = me*clum*(sqrt(gam.^2-1)-sqrt(gamma_max^2-1))/(qe*mksa.Edreicer_ref*epsi)*mksa.nhu_ref;
0181 titl=['(ro): gamma @ p_{max} = ',num2str(pnmax_S),'p_{th}'];
0182 figure;graph1D_jd(gam,dt_acc,0,0,'gamma','dt_n Dreicer',titl,NaN,NaN,NaN,'-','none','b',2)
0183 hold on
0184 graph1D_jd(gamma_ext,dtn_min,0,0,'','','',NaN, NaN,NaN,'none','o','r',3);
0185 hold off
0186 disp([' Mininmum time step dtn for dreicer acc from rest to gamma(p_max) = : ',num2str(gamma_max),' is tau*nhu_ref = ',num2str(dtn_min)])
0187 end
0188
0189 if length(rho_S) == 1
0190
0191 [logXf0_cyl_ref,ppar_cyl_ref,dppar_cyl_ref,pperp_cyl_ref,dpperp_cyl_ref] = s2c_dke_yp(log(dke_out.XXf0{end}),momentumDKE.pn,momentumDKE.mhu,0.1);
0192 Xf0_cyl_ref = exp(logXf0_cyl_ref);
0193
0194 logXfinit_cyl_ref = s2c_dke_yp(log(dke_out.XXfinit),momentumDKE.pn,momentumDKE.mhu,0.1);
0195 Xfinit_cyl_ref = exp(logXfinit_cyl_ref);
0196
0197 Xppar_cyl_ref = ones(length(pperp_cyl_ref),1)*ppar_cyl_ref(:)';
0198 Xpperp_cyl_ref = pperp_cyl_ref(:)*ones(1,length(ppar_cyl_ref));
0199 Xp_cyl_ref = sqrt(Xppar_cyl_ref.*Xppar_cyl_ref + Xpperp_cyl_ref.*Xpperp_cyl_ref);
0200
0201 Xf0_cyl_ref = Xf0_cyl_ref.*(Xf0_cyl_ref>0);
0202 Xf0_cyl_ref = Xf0_cyl_ref.*(Xp_cyl_ref<=max(ppar_cyl_ref));
0203 Xf0_cyl_ref(isnan(Xf0_cyl_ref)) = 0;
0204
0205 Xfinit_cyl_ref = Xfinit_cyl_ref.*(Xfinit_cyl_ref>0);
0206 Xfinit_cyl_ref = Xfinit_cyl_ref.*(Xp_cyl_ref<=max(ppar_cyl_ref));
0207 Xfinit_cyl_ref(isnan(Xfinit_cyl_ref)) = 0;
0208
0209
0210
0211 Xmask = abs(Xf0_cyl_ref) < eps;
0212
0213 pnmax = max(momentumDKE.pn_S);
0214 pnmax_0 = min(min(Xp_cyl_ref(Xmask)));
0215
0216 Xmask = Xp_cyl_ref >= pnmax;
0217
0218 Xf0_cyl_ref(Xmask) = 0;
0219 Xfinit_cyl_ref(Xmask) = 0;
0220
0221 figure(1),clf
0222
0223 x1 = ppar_cyl_ref;
0224 xlab1 = 'p_{||}/p_{Te}';
0225 xlim1 = [-pnmax,pnmax];
0226
0227 x2 = pperp_cyl_ref;
0228 xlab2 = 'p_{\perp}/p_{Te}';
0229 xlim2 = [0,pnmax];
0230
0231 leg = {'f_M','f'};
0232
0233 y1 = Xfinit_cyl_ref;
0234 y2 = Xf0_cyl_ref;
0235
0236 y9 = sqrt(pnmax^2 - x1.^2);
0237
0238 figure;
0239 graph2D_jd(x1,x2,y1','','','',xlim1,xlim2,0,mksa.betath_ref,[0:0.5:pnmax],0,'-','b',0.5,20+14i,1,max(max(y1)));
0240 hold on
0241 graph2D_jd(x1,x2,y2','','','',xlim1,xlim2,0,mksa.betath_ref,[0:0.5:pnmax],0,'-','r',2,20+14i,1,max(max(y1)));
0242 hold off
0243
0244 graph1D_jd(x1,y9,0,0,xlab1,xlab2,'',NaN,xlim1,xlim2,'-','none','k',2,20+14i,gca,0.9,0.7,0.7);
0245
0246 axis('equal');axis([xlim1,xlim2]);
0247 legend(leg);
0248 end
0249
0250 disp('Simulation parameters : ')
0251 disp(['coll_mode = ',num2str(coll_mode),' ; Te/mc2 = ',num2str(betath2),' ; E/Ec = ',num2str(alpha),' ; E/ED = ',num2str(alpha*betath2),' ; Zi = ',num2str(Zi)])
0252 disp(['NR limit : pc/pT = ',num2str(1/sqrt(alpha*betath2)),' ; pmax/pc = ',num2str(pnmax_S*sqrt(alpha*betath2))])
0253 disp(['Relativ. : pc/pT = ',num2str(1/sqrt((alpha - 1)*betath2)),' ; pmax/pc = ',num2str(pnmax_S*sqrt((alpha - 1)*betath2))])
0254 disp(' ')
0255 disp(['--> LUKE RR (normalized to ne and tauc) : ',num2str(RR)])
0256 disp('----------------------')
0257
0258
0259
0260 diary off
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271 figure
0272 graph1D_jd((1:dkeparam.dtn:dkeparam.tn),xnre(:),0,0,'t_n','n_{re}/n_{tot}','',NaN,NaN,NaN,'-','none','b',2)
0273 figure
0274 grDA = diff(xnre(:))'./dkeparam.dtn./(1-xnre(1:(end-1)));
0275 graph1D_jd(xnre(1:(end-1)),grDA,0,0,'n_r','1/(1-n_r)dn_r/dt_n','',NaN,NaN,NaN,'-','none','b',2)
0276 grA = (grDA(end)-grDA(end-20))/(xnre(end)-xnre(end-20));
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290 end