0001 function fproc_runaway_scan(scanvar,scanval,scanstr,scanlab,RR,mksa,Ec,f,tn,tRR,tnorm,fgrid,alpha,betath2,wpr,Zi,opt,grid,id_equil,rho_S,graph,p_opt,id_simul_scan)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 nscan = length(scanval);
0047
0048 snorm.re = NaN(1,nscan);
0049 snorm.ri = NaN(1,nscan);
0050 snorm.rtot = NaN(1,nscan);
0051 snorm.b = NaN(1,nscan);
0052 snorm.tot = NaN(1,nscan);
0053
0054 sRR.re = NaN(1,nscan);
0055 sRR.ri = NaN(1,nscan);
0056 sRR.rtot = NaN(1,nscan);
0057
0058 spnmin = NaN(1,nscan);
0059 spnmax = NaN(1,nscan);
0060 sEcmin = NaN(1,nscan);
0061 sEcmax = NaN(1,nscan);
0062
0063 salpha = NaN(1,nscan);
0064 sbetath2 = NaN(1,nscan);
0065
0066 spnmax_S = NaN(1,nscan);
0067 spnmax_S_tail = NaN(1,nscan);
0068
0069 spnmax_f = NaN(1,nscan);
0070 spnmin_f = NaN(1,nscan);
0071
0072 sfpar = cell(1,nscan);
0073
0074 for iscan = 1:nscan,
0075
0076 snorm.re(iscan) = tnorm{iscan}.re(end);
0077 snorm.ri(iscan) = tnorm{iscan}.ri(end);
0078 snorm.rtot(iscan) = tnorm{iscan}.re(end) + tnorm{iscan}.ri(end);
0079 snorm.b(iscan) = tnorm{iscan}.b(end);
0080 snorm.tot(iscan) = tnorm{iscan}.tot(end);
0081
0082 sRR.re(iscan) = tRR{iscan}.re(end);
0083 sRR.ri(iscan) = tRR{iscan}.ri(end);
0084 sRR.rtot(iscan) = tRR{iscan}.re(end) + tRR{iscan}.ri(end);
0085
0086 sfpar{iscan} = f{iscan}{end}(:,end).';
0087 np = length(sfpar{iscan});
0088 ipparnan = find(sfpar{iscan} < 0,1);
0089 if ~isempty(ipparnan),
0090 sfpar{iscan}(ipparnan:end) = NaN;
0091 end
0092 ipparmin = find(diff(sfpar{iscan}) > 0,1);
0093 if ~isempty(ipparmin),
0094 spnmin(iscan) = fgrid{iscan}.pn(ipparmin);
0095 sEcmin(iscan) = Ec{iscan}(ipparmin);
0096
0097 ipparmax = find(diff(sfpar{iscan}) < 0 & 1:np-1 > ipparmin,1);
0098 if ~isempty(ipparmax),
0099 spnmax(iscan) = fgrid{iscan}.pn(ipparmax);
0100 sEcmax(iscan) = Ec{iscan}(ipparmax);
0101 end
0102 end
0103 if strcmp(scanvar,'alpha'),
0104 salpha(iscan) = scanval(iscan);
0105 else
0106 salpha(iscan) = alpha;
0107 end
0108 if strcmp(scanvar,'betath2'),
0109 sbetath2(iscan) = scanval(iscan);
0110 else
0111 sbetath2(iscan) = betath2;
0112 end
0113
0114 if strcmp(scanvar,'grid.pnmax_S'),
0115 spnmax_S(iscan) = scanval(iscan);
0116 else
0117 spnmax_S(iscan) = grid.pnmax_S;
0118 end
0119 if strcmp(scanvar,'grid.pnmax_S_tail'),
0120 spnmax_S_tail(iscan) = scanval(iscan);
0121 else
0122 spnmax_S_tail(iscan) = grid.pnmax_S_tail;
0123 end
0124 spnmax_f(iscan) = max(fgrid{iscan}.pn);
0125 spnmin_f(iscan) = min(fgrid{iscan}.pn);
0126 end
0127
0128 spc = 1./sqrt((salpha - 1).*sbetath2);
0129 sgammac = sqrt(salpha./(salpha - 1));
0130
0131 [~,~,~,~,~,~,~,mc2] = pc_dke_yp;
0132 sEcc = 1e-3*mc2*(sgammac - 1);
0133
0134 if grid.np_tail > 0,
0135 if imag(grid.pnmax_S_tail) == 0,
0136 spnmax_S = spnmax_S_tail;
0137 else
0138 spnmax_S = spnmax_S.*imag(spnmax_S_tail);
0139 end
0140 end
0141
0142 sgammamax_S = sqrt(1 + spnmax_S.^2.*sbetath2);
0143 sEcmax_S = 1e-3*mc2*(sgammamax_S - 1);
0144
0145 sgammamax_f = sqrt(1 + spnmax_f.^2.*sbetath2);
0146 sEcmax_f = 1e-3*mc2*(sgammamax_f - 1);
0147
0148 sgammamin_f = sqrt(1 + spnmin_f.^2.*sbetath2);
0149 sEcmin_f = 1e-3*mc2*(sgammamin_f - 1);
0150
0151 siz = 20+14i;
0152 tit = '';
0153 if ~isfield(opt,'color') || opt.color,
0154 colors = {'b','r',[0,0.75,0],[0.75,0,0.75],[0,0.75,0.75],[0.75,0.75,0],'k'};
0155
0156 styles = {'-','-','-','-','-','-','-'};
0157 sizes = [2,2,2,2,2,2,2];
0158 colstr = '_col';
0159 else
0160 colors = {'k','k','k','k','k','k','k','k','k'};
0161 styles = {'-','--','-.','-','--','-.'};
0162 colstr = '';
0163 sizes = [2,0.5,0.5,0.5,2];
0164 end
0165
0166 if ~isfield(graph,'x'),
0167 graph.x = scanval;
0168 end
0169 if isfield(graph,'xlim'),
0170 xlim = graph.xlim;
0171 else
0172 xlim = NaN;
0173 end
0174 if isfield(graph,'xlog'),
0175 xlog = graph.xlog;
0176 else
0177 xlog = 0;
0178 end
0179 if isfield(graph,'xtick'),
0180 xtick = graph.xtick;
0181 else
0182 xtick = graph.x;
0183 end
0184 if ~isfield(graph,'xmask'),
0185 graph.xmask = 1:nscan;
0186 end
0187
0188 if ~isfield(graph,'re'),
0189 graph.re = true;
0190 end
0191
0192 if isfield(graph,'scanunits') && ~isempty(graph.scanunits),
0193 unitstr1 = [' (',graph.scanunits,')'];
0194 unitstr2 = [' ',graph.scanunits];
0195 else
0196 unitstr1 = '';
0197 unitstr2 = '';
0198 end
0199
0200 figure(1),clf
0201
0202 xlab = [scanlab,unitstr1];
0203 ylab = 'n/n_e';
0204 if isfield(graph,'ylim_norm'),
0205 ylim = graph.ylim_norm;
0206 else
0207 ylim = 10.^[-9,1];
0208 graph.ytick_norm = 10.^(-8:2:0);
0209 end
0210 if graph.re,
0211 leg = {'ext. RE','int. RE','tot. RE'};
0212
0213 graph1D_jd(graph.x(graph.xmask),snorm.re(graph.xmask),xlog,1,'','','',NaN,xlim,ylim,styles{1},'d',colors{2},sizes(1),siz,gca);
0214 graph1D_jd(graph.x(graph.xmask),snorm.ri(graph.xmask),xlog,1,'','','',NaN,xlim,ylim,styles{2},'*',colors{3},sizes(1),siz,gca);
0215 graph1D_jd(graph.x(graph.xmask),snorm.rtot(graph.xmask),xlog,1,'','','',NaN,xlim,ylim,styles{4},'o',colors{5},sizes(2),siz,gca);
0216 else
0217 leg = {'runaways'};
0218
0219 graph1D_jd(graph.x(graph.xmask),snorm.rtot(graph.xmask),xlog,1,'','','',NaN,xlim,ylim,styles{4},'o',colors{5},sizes(2),siz,gca);
0220 end
0221 leg = [leg,'bulk','total'];
0222 graph1D_jd(graph.x(graph.xmask),snorm.b(graph.xmask),xlog,1,'','','',NaN,xlim,ylim,styles{4},'s',colors{4},sizes(2),siz,gca);
0223 graph1D_jd(graph.x(graph.xmask),snorm.tot(graph.xmask),xlog,1,xlab,ylab,tit,leg,xlim,ylim,styles{5},'x',colors{1},sizes(1),siz,gca,0.9,0.7,0.7);
0224
0225 if ~isnan(xtick),
0226 set(gca,'xtick',xtick)
0227 end
0228
0229 if isfield(graph,'ytick_norm'),
0230 set(gca,'ytick',graph.ytick_norm)
0231 end
0232 if xlog,
0233 set(gca,'XMinorGrid','off')
0234 set(gca,'XMinorTick','off')
0235 end
0236 set(gca,'YMinorGrid','off')
0237 set(gca,'YMinorTick','on')
0238
0239 figure(2),clf
0240
0241 ylab = '\Gamma_R\tau_c';
0242 if isfield(graph,'ylim_gamma'),
0243 ylim = graph.ylim_gamma;
0244 else
0245 ylim = 10.^[-12,-2];
0246 graph.ytick_gamma = 10.^(-12:2:-2);
0247 end
0248
0249 leg = {'ext. RR','int. RR','total RR'};
0250
0251 graph1D_jd(graph.x,sRR.re,xlog,1,'','','',NaN,xlim,ylim,'none','s','r',2,siz,gca);
0252 graph1D_jd(graph.x,sRR.ri,xlog,1,'','','',NaN,xlim,ylim,'none','s','b',2,siz,gca);
0253 graph1D_jd(graph.x,sRR.rtot,xlog,1,xlab,ylab,tit,leg,xlim,ylim,'none','s','k',2,siz,gca,0.9,0.7,0.7);
0254 graph1D_jd(graph.x,-sRR.re,xlog,1,'','','',NaN,xlim,ylim,'none','o','r',2,siz,gca);
0255 graph1D_jd(graph.x,-sRR.ri,xlog,1,'','','',NaN,xlim,ylim,'none','o','b',2,siz,gca);
0256 graph1D_jd(graph.x,-sRR.rtot,xlog,1,'','','',NaN,xlim,ylim,'none','o','k',2,siz,gca);
0257
0258 if ~isnan(xtick),
0259 set(gca,'xtick',xtick)
0260 end
0261
0262 if isfield(graph,'ytick_gamma'),
0263 set(gca,'ytick',graph.ytick_gamma)
0264 end
0265 if xlog,
0266 set(gca,'XMinorGrid','off')
0267 set(gca,'XMinorTick','off')
0268 end
0269 set(gca,'YMinorGrid','off')
0270 set(gca,'YMinorTick','on')
0271
0272 figure(3),clf
0273
0274 ylab = 'p/p_T';
0275 if isfield(graph,'ylim_p'),
0276 ylim = graph.ylim_p;
0277 else
0278 ylim = [0,max(spnmax_S)*1.1];
0279 end
0280
0281 leg = {'critical','grid','minimum','maximum'};
0282
0283 graph1D_jd(graph.x,spc,xlog,0,'','','',NaN,xlim,ylim,'-','s','r',2,siz,gca);
0284 graph1D_jd(graph.x,spnmax_S,xlog,0,'','','',NaN,xlim,ylim,'-','o','k',2,siz,gca);
0285 graph1D_jd(graph.x,spnmin,xlog,0,'','','',NaN,xlim,ylim,'-','d','b',2,siz,gca);
0286 graph1D_jd(graph.x,spnmax,xlog,0,xlab,ylab,tit,leg,xlim,ylim,'-','x','m',2,siz,gca,0.9,0.7,0.7);
0287
0288 if ~isnan(xtick),
0289 set(gca,'xtick',xtick)
0290 end
0291
0292 if isfield(graph,'ytick_p'),
0293 set(gca,'ytick',graph.ytick_p)
0294 end
0295 if xlog,
0296 set(gca,'XMinorGrid','off')
0297 set(gca,'XMinorTick','off')
0298 end
0299
0300 figure(4),clf
0301
0302 ylab = 'p/(mc)';
0303 if isfield(graph,'ylim_pc'),
0304 ylim = graph.ylim_pc;
0305 else
0306 ylim = NaN;
0307 end
0308
0309 leg = NaN;
0310
0311 graph1D_jd(graph.x,spnmax.*sqrt(sbetath2),xlog,0,xlab,ylab,tit,leg,xlim,ylim,'-','s','b',2,siz,gca,0.9,0.7,0.7);
0312
0313 if ~isnan(xtick),
0314 set(gca,'xtick',xtick)
0315 end
0316
0317 if isfield(graph,'ytick_pc'),
0318 set(gca,'ytick',graph.ytick_pc)
0319 end
0320 if xlog,
0321 set(gca,'XMinorGrid','off')
0322 set(gca,'XMinorTick','off')
0323 end
0324
0325 figure(5),clf
0326
0327 ylab = 'E_c (keV)';
0328 if isfield(graph,'ylim_ec'),
0329 ylim = graph.ylim_ec;
0330 else
0331 ylim = [0,max(sEcmax_S)*1.1];
0332 end
0333
0334 leg = {'critical','grid','minimum','maximum'};
0335
0336 graph1D_jd(graph.x,sEcc,xlog,0,'','','',NaN,xlim,ylim,'-','s','r',2,siz,gca);
0337 graph1D_jd(graph.x,sEcmax_S,xlog,0,'','','',NaN,xlim,ylim,'-','o','k',2,siz,gca);
0338 graph1D_jd(graph.x,sEcmin,xlog,0,'','','',NaN,xlim,ylim,'-','d','b',2,siz,gca);
0339 graph1D_jd(graph.x,sEcmax,xlog,0,xlab,ylab,tit,leg,xlim,ylim,'-','x','m',2,siz,gca,0.9,0.7,0.7);
0340
0341 if ~isnan(xtick),
0342 set(gca,'xtick',xtick)
0343 end
0344
0345 if isfield(graph,'ytick_ec'),
0346 set(gca,'ytick',graph.ytick_ec)
0347 end
0348 if xlog,
0349 set(gca,'XMinorGrid','off')
0350 set(gca,'XMinorTick','off')
0351 end
0352
0353 print_jd(p_opt,['fig_',id_simul_scan,'_nr',colstr],['./figures',filesep,scanstr],1)
0354 print_jd(p_opt,['fig_',id_simul_scan,'_rr',colstr],['./figures',filesep,scanstr],2)
0355 print_jd(p_opt,['fig_',id_simul_scan,'_p',colstr],['./figures',filesep,scanstr],3)
0356 print_jd(p_opt,['fig_',id_simul_scan,'_pmax',colstr],['./figures',filesep,scanstr],4)
0357 print_jd(p_opt,['fig_',id_simul_scan,'_Ec',colstr],['./figures',filesep,scanstr],5)
0358
0359 if isfield(graph,'iscandisp'),
0360
0361 figure(6),clf
0362
0363 xlab = '$\mathcal{E}_k$ (MeV)';
0364 ylab = '$f(\mathcal{E}_k,\xi = 1)$';
0365
0366 if ~isfield(graph,'xlog_f'),
0367 graph.xlog_f = false;
0368 end
0369
0370 if ~isfield(graph,'xlim_f'),
0371 if graph.xlog_f,
0372 graph.xlim_f = [min(sEcmin_f),max(sEcmax_f)];
0373 else
0374 graph.xlim_f = [0,max(sEcmax_f)];
0375 end
0376 end
0377
0378 if isfield(graph,'ylim_f'),
0379 ylim = graph.ylim_f;
0380 else
0381 ylim = [eps,2];
0382 graph.ytick_f = 10.^(-18:2:2);
0383 end
0384
0385 nscandisp = length(graph.iscandisp);
0386
0387 leg = cell(1,nscandisp);
0388
0389 for iiscan = 1:nscandisp-1,
0390 if isfield(graph,'scanformat'),
0391 legstr = num2str(graph.x(graph.iscandisp(iiscan)),graph.scanformat);
0392 else
0393 legstr = num2str(graph.x(graph.iscandisp(iiscan)));
0394 end
0395 leg{iiscan} = [scanlab,' = ',legstr,unitstr2];
0396 graph1D_jd(Ec{graph.iscandisp(iiscan)},sfpar{graph.iscandisp(iiscan)},graph.xlog_f,1,'','','',NaN,graph.xlim_f,ylim,styles{iiscan},'none',colors{iiscan},sizes(iiscan),siz);
0397 end
0398 if isfield(graph,'scanformat'),
0399 legstr = num2str(graph.x(graph.iscandisp(nscandisp)),graph.scanformat);
0400 else
0401 legstr = num2str(graph.x(graph.iscandisp(nscandisp)));
0402 end
0403 leg{nscandisp} = [scanlab,' = ',legstr,unitstr2];
0404 graph1D_jd(Ec{graph.iscandisp(nscandisp)},sfpar{graph.iscandisp(nscandisp)},graph.xlog_f,1,xlab,ylab,tit,leg,graph.xlim_f,ylim,styles{nscandisp},'none',colors{nscandisp},sizes(nscandisp),siz,gca,0.9,0.7,0.7);
0405
0406 if isfield(graph,'xtick_f'),
0407 set(gca,'xtick',graph.xtick_f)
0408 end
0409 if isfield(graph,'ytick_f'),
0410 set(gca,'ytick',graph.ytick_f)
0411 end
0412 set(gca,'XMinorGrid','off')
0413 set(gca,'XMinorTick','on')
0414 set(gca,'YMinorGrid','off')
0415 set(gca,'YMinorTick','on')
0416 set(get(gca,'xlabel'),'interpreter','latex')
0417 set(get(gca,'ylabel'),'interpreter','latex')
0418
0419 print_jd(p_opt,['fig_',id_simul_scan,'_f',colstr],['./figures',filesep,scanstr],6)
0420
0421 figure(7),clf
0422
0423 xlab = 't/\tau_c';
0424 ylab = 'n/n_e';
0425 if isfield(graph,'xlim_tn'),
0426 xlim = graph.xlim_tn;
0427 else
0428 xlim = NaN;
0429 end
0430 if isfield(graph,'ylim_norm'),
0431 ylim = graph.ylim_norm;
0432 else
0433 ylim = 10.^[-9,1];
0434 graph.ytick_norm = 10.^(-8:2:0);
0435 end
0436
0437 nscandisp = length(graph.iscandisp);
0438
0439 leg = cell(1,nscandisp);
0440
0441 for iiscan = 1:nscandisp-1,
0442 if isfield(graph,'scanformat'),
0443 legstr = num2str(graph.x(graph.iscandisp(iiscan)),graph.scanformat);
0444 else
0445 legstr = num2str(graph.x(graph.iscandisp(iiscan)));
0446 end
0447 leg{iiscan} = [scanlab,' = ',legstr,unitstr2];
0448 graph1D_jd(tn{graph.iscandisp(iiscan)},tnorm{graph.iscandisp(iiscan)}.ri + tnorm{graph.iscandisp(iiscan)}.re,1,1,'','','',NaN,xlim,ylim,styles{iiscan},'none',colors{iiscan},sizes(iiscan),siz);
0449 end
0450 if isfield(graph,'scanformat'),
0451 legstr = num2str(graph.x(graph.iscandisp(nscandisp)),graph.scanformat);
0452 else
0453 legstr = num2str(graph.x(graph.iscandisp(nscandisp)));
0454 end
0455 leg{nscandisp} = [scanlab,' = ',legstr,unitstr2];
0456 graph1D_jd(tn{graph.iscandisp(nscandisp)},tnorm{graph.iscandisp(nscandisp)}.ri + tnorm{graph.iscandisp(nscandisp)}.re,1,1,xlab,ylab,tit,leg,xlim,ylim,styles{nscandisp},'none',colors{nscandisp},sizes(nscandisp),siz,gca,0.9,0.7,0.7);
0457
0458 if isfield(graph,'xtick_tn'),
0459 set(gca,'xtick',graph.xtick_tn)
0460 end
0461 if isfield(graph,'ytick_norm'),
0462 set(gca,'ytick',graph.ytick_norm)
0463 end
0464 set(gca,'XMinorGrid','off')
0465 set(gca,'XMinorTick','on')
0466 set(gca,'YMinorGrid','off')
0467 set(gca,'YMinorTick','on')
0468
0469
0470
0471 print_jd(p_opt,['fig_',id_simul_scan,'_tn',colstr],['./figures',filesep,scanstr],7)
0472
0473 end
0474