0001 function graph_wave_jd(equil,waves,nr_dep,opt,rho_disp,ymask,xvar,yabs,colors,styles)
0002
0003
0004
0005
0006
0007 opt.abs_step = 0.01;
0008
0009 if nargin < 10
0010 styles = {'-','-','-','-','-','-'};
0011 end
0012 if nargin < 9
0013 colors = {'b','r','g','m','c','y'};
0014 end
0015 if nargin < 8
0016 yabs = NaN;
0017 end
0018 if nargin < 7 || isempty(xvar)
0019 xvar = input_dke_yp('Option for rho definition : ''g'' (geometric), ''p'' (poloidal flux), ''t'' (toroidal flux), ''v'' (volumic rho)','g',{'g','p','t','v'},'',[1,1]);
0020 end
0021 if nargin < 6
0022 ymask = NaN;
0023 end
0024 if nargin < 5
0025 rho_disp = 0:0.1:1;
0026 end
0027 if nargin < 4,
0028 opt = struct;
0029 end
0030 if nargin < 3,
0031 nr_dep = 40;
0032 end
0033
0034 if ~isfield(opt,'vessel_opt'),
0035 opt.vessel_opt = 'n';
0036 end
0037 if ~isfield(opt,'TeNpar'),
0038 opt.TeNpar = 1;
0039 end
0040 if ~isfield(opt,'abs_max'),
0041 opt.abs_max = input_dke_yp('Option for ray trajectories : 0 (full trajectory), 1 (cut when damped @ 99.9%), 0 <value < 1 (cut when remaining power fraction is below value) ',1,[0;1],'',[1,1]);
0042 end
0043 if ~isfield(opt,'mode'),
0044 opt.mode = input_dke_yp('Option for showing ray polarization (n/y)','n',{'n','y'});
0045 end
0046 if ~isfield(opt,'print'),
0047 opt.print = input_dke_yp('Option for output figures : -1 (nothing), 0 (print), 1 (print and save), 2 (save)',-1,-1:2,'',[1,1]);
0048 end
0049
0050 if ~isfield(waves{1},'colldamp'),
0051 if isfield(waves{1}.rayparam,'colldamp'),
0052 waves{1}.colldamp = waves{1}.rayparam.colldamp;
0053 end
0054 end
0055
0056 nw = length(waves);
0057
0058 if ~iscell(ymask),
0059 ymask = '';
0060 for iw = 1:nw,
0061 ymask{iw} = 1:length(waves{iw}.rays);
0062 end
0063 end
0064
0065 nymask = zeros(1,nw);
0066
0067 for iw = 1:nw,
0068 nymask(iw) = length(ymask{iw});
0069
0070 if opt.TeNpar && waves{iw}.omega_rf/(2*pi*1e9) < 10,
0071
0072 waves{iw}.opt_TeNpar = 1;
0073
0074 else
0075
0076 waves{iw}.opt_TeNpar = 0;
0077
0078 end
0079 end
0080
0081 if ~isfield(opt,'luke'),
0082 opt.luke = false;
0083 end
0084
0085 [qe,me,mp,mn,e0,mu0,re,mc2,clum] = pc_dke_yp;
0086
0087 method = 'cubic';
0088
0089
0090
0091
0092
0093
0094
0095 Rp = equil.Rp;
0096 Zp = equil.Zp;
0097 ptx = equil.ptx;
0098 pty = equil.pty;
0099
0100
0101
0102 theta = equil.theta;
0103 psi_apRp = equil.psi_apRp;
0104
0105
0106 psin = psi_apRp/psi_apRp(end);
0107
0108 ap = ptx(end,1);
0109
0110 prho_g = ptx(:,1)/ap;
0111
0112 equilDKE = equilibrium_jd(equil);
0113
0114 if xvar == 'g',
0115 prho = prho_g;
0116 plab = 'r/a';
0117 elseif xvar == 'p',
0118 prho = sqrt(psin);
0119 plab = '\rho_{\psi_P}';
0120 elseif xvar == 't',
0121 prho = equilDKE.xrhoT;
0122 plab = '\rho_{\psi_T}';
0123 elseif xvar == 'v',
0124 prho = equilDKE.xrhoV;
0125 plab = '\rho_V';
0126 end
0127
0128
0129
0130
0131 ptx_disp = interp1(prho,ptx,rho_disp,method);
0132 pty_disp = interp1(prho,pty,rho_disp,method);
0133
0134 xmin = min(min(ptx));
0135 xmax = max(max(ptx));
0136 ymin = min(min(pty));
0137 ymax = max(max(pty));
0138
0139 PHI_disp = linspace(0,2*pi,361);
0140 X_disp = [(Rp + xmin)*cos(PHI_disp);(Rp + xmax)*cos(PHI_disp)];
0141 Y_disp = [(Rp + xmin)*sin(PHI_disp);(Rp + xmax)*sin(PHI_disp)];
0142
0143 Xmin = min(min(X_disp));
0144 Xmax = max(max(X_disp));
0145 Ymin = min(min(Y_disp));
0146 Ymax = max(max(Y_disp));
0147
0148
0149
0150 iy = 0;
0151 rays = '';
0152 legpol = {'SW','FW'};
0153
0154 for iw = 1:nw,
0155 ibb = 0;
0156 for ib = ymask{iw},
0157 ibb = ibb + 1;
0158 iy = iy + 1;
0159 rays{iy} = waves{iw}.rays{ib};
0160
0161 rays{iy}.omega_rf = waves{iw}.omega_rf;
0162 rays{iy}.color = colors{mod(iw-1,length(colors))+1};
0163 rays{iy}.style = styles{mod(iw-1,length(styles))+1};
0164 rays{iy}.sX = (Rp + rays{iy}.sx).*cos(-rays{iy}.sphi);
0165 rays{iy}.sY = (Rp + rays{iy}.sx).*sin(-rays{iy}.sphi);
0166
0167 rays{iy}.ns = length(rays{iy}.ss);
0168
0169 if iscell(yabs),
0170 rays{iy}.mask_abs_lin = 1:rays{iy}.ns >= yabs{iw}(1,ibb) & 1:rays{iy}.ns <= yabs{iw}(2,ibb);
0171 else
0172 rays{iy}.mask_abs_lin = false(1,rays{iy}.ns);
0173 end
0174 rays{iy}.mask_abs = rays{iy}.mask_abs_lin;
0175
0176 if 1,
0177 rays{iy}.refs = '';
0178 rays{iy}.mask_pass = {true(1,rays{iy}.ns)};
0179 else
0180
0181 legpol = {'O','X'};
0182 rays{iy}.mask_pass = {};
0183 is0 = 1;
0184
0185 for iref = 1:length(rays{iy}.rayinits),
0186
0187 rayinit = rays{iy}.rayinits{iref};
0188
0189 launch = rayinit.launch;
0190
0191 rays{iy}.refs{iref}.x = launch.yR_L - Rp;
0192 rays{iy}.refs{iref}.y = launch.yZ_L - Zp;
0193 rays{iy}.refs{iref}.phi = launch.yphi_L;
0194
0195 while isfield(launch,'launch_back') && ~isempty(launch.launch_back),
0196
0197 launch = launch.launch_back;
0198
0199 rays{iy}.refs{iref}.x = [launch.yR_L - Rp,rays{iy}.refs{iref}.x];
0200 rays{iy}.refs{iref}.y = [launch.yZ_L - Zp,rays{iy}.refs{iref}.y];
0201 rays{iy}.refs{iref}.phi = [launch.yphi_L,rays{iy}.refs{iref}.phi];
0202
0203 end
0204
0205 is = find(rays{iy}.ss == rayinit.ss0);
0206
0207 if is > 1 && is < length(rays{iy}.ss),
0208
0209 rays{iy}.refs{iref}.x = [rays{iy}.sx(is),rays{iy}.refs{iref}.x,rays{iy}.sx(is+1)];
0210 rays{iy}.refs{iref}.y = [rays{iy}.sy(is),rays{iy}.refs{iref}.y,rays{iy}.sy(is+1)];
0211 rays{iy}.refs{iref}.phi = [rays{iy}.sphi(is),rays{iy}.refs{iref}.phi,rays{iy}.sphi(is+1)];
0212
0213 rays{iy}.mask_pass = [rays{iy}.mask_pass,1:rays{iy}.ns >= is0 & 1:rays{iy}.ns <= is];
0214 is0 = is + 1;
0215
0216 elseif is == 1,
0217
0218 rays{iy}.refs{iref}.x = [rays{iy}.refs{iref}.x,rays{iy}.sx(is)];
0219 rays{iy}.refs{iref}.y = [rays{iy}.refs{iref}.y,rays{iy}.sy(is)];
0220 rays{iy}.refs{iref}.phi = [rays{iy}.refs{iref}.phi,rays{iy}.sphi(is)];
0221
0222 else
0223
0224 rays{iy}.refs{iref}.x = [rays{iy}.sx(is),rays{iy}.refs{iref}.x];
0225 rays{iy}.refs{iref}.y = [rays{iy}.sy(is),rays{iy}.refs{iref}.y];
0226 rays{iy}.refs{iref}.phi = [rays{iy}.sphi(is),rays{iy}.refs{iref}.phi];
0227
0228 rays{iy}.mask_pass = [rays{iy}.mask_pass,1:rays{iy}.ns >= is0 & 1:rays{iy}.ns <= is];
0229
0230 end
0231
0232 rays{iy}.refs{iref}.R = rays{iy}.refs{iref}.x + Rp;
0233 rays{iy}.refs{iref}.Z = rays{iy}.refs{iref}.y + Zp;
0234 rays{iy}.refs{iref}.X = rays{iy}.refs{iref}.R.*cos(-rays{iy}.refs{iref}.phi);
0235 rays{iy}.refs{iref}.Y = rays{iy}.refs{iref}.R.*sin(-rays{iy}.refs{iref}.phi);
0236
0237 xmin = min([xmin,rays{iy}.refs{iref}.x]);
0238 xmax = max([xmax,rays{iy}.refs{iref}.x]);
0239 ymin = min([ymin,rays{iy}.refs{iref}.y]);
0240 ymax = max([ymax,rays{iy}.refs{iref}.y]);
0241
0242 Xmin = min([Xmin,rays{iy}.refs{iref}.X]);
0243 Xmax = max([Xmax,rays{iy}.refs{iref}.X]);
0244 Ymin = min([Ymin,rays{iy}.refs{iref}.Y]);
0245 Ymax = max([Ymax,rays{iy}.refs{iref}.Y]);
0246
0247 end
0248
0249 end
0250
0251 end
0252 end
0253 ny = iy;
0254
0255
0256
0257 yrho_abs_lin = NaN(1,ny);
0258 yPtot_abs_lin = NaN(1,ny);
0259 yNpar_abs_lin = NaN(1,ny);
0260
0261 yrho_abs_lin_coll = NaN(1,ny);
0262 yPtot_abs_lin_coll = NaN(1,ny);
0263 yNpar_abs_lin_coll = NaN(1,ny);
0264
0265 yrho_abs_coll_luke = NaN(1,ny);
0266 yPtot_abs_coll_luke = NaN(1,ny);
0267 yNpar_abs_coll_luke = NaN(1,ny);
0268
0269 yrho_abs = NaN(1,ny);
0270 yPtot_abs = NaN(1,ny);
0271 yNpar_abs = NaN(1,ny);
0272
0273 dPdrho_lin = 0;
0274 dPdrho_lin_coll = 0;
0275 dPdrho_coll_luke = 0;
0276 dPdrho = 0;
0277
0278 if opt.abs_max == 1,
0279 opt.abs_max = 1e-3;
0280 end
0281
0282 if ~isfield(opt,'disp_rays'),
0283 opt.disp_rays = input_dke_yp('Option for showing ray absorption (n/y)','n',{'n','y'});
0284 end
0285
0286 for iy = 1:ny,
0287
0288 ns = length(rays{iy}.ss);
0289
0290 rays{iy}.is_abs_max_lin = ns;
0291 rays{iy}.is_abs_max_lin_coll = ns;
0292 rays{iy}.is_abs_max_coll_luke = ns;
0293 rays{iy}.is_abs_lin = NaN;
0294 rays{iy}.dP_lin_normdrho = NaN;
0295 rays{iy}.dP_lin_coll_normdrho = NaN;
0296 rays{iy}.dP_coll_luke_normdrho = NaN;
0297 yrho_abs_lin(iy) = NaN;
0298 yNpar_abs_lin(iy) = NaN;
0299 yPtot_abs_lin(iy) = NaN;
0300 yrho_abs_lin_coll(iy) = NaN;
0301 yNpar_abs_lin_coll(iy) = NaN;
0302 yPtot_abs_lin_coll(iy) = NaN;
0303 yrho_abs_coll_luke(iy) = NaN;
0304 yNpar_abs_coll_luke(iy) = NaN;
0305 yPtot_abs_coll_luke(iy) = NaN;
0306
0307 rhog_dep = NaN;
0308
0309 if opt.disp_rays == 'y',
0310 figure(1000+iy),clf;
0311 else
0312 if ishandle(figure(1000+iy)),
0313 close(figure(1000+iy));
0314 end
0315 end
0316
0317 if isfield(rays{iy},'sP_2piRp_lin'),
0318
0319 sP_2piRp_lin_norm = rays{iy}.sP_2piRp_lin/rays{iy}.sP_2piRp_lin(1);
0320 sdP_2piRp_ds_lin_norm = rays{iy}.sdP_2piRp_ds_lin/max(rays{iy}.sdP_2piRp_ds_lin+eps).*(1 - sP_2piRp_lin_norm(end)/sP_2piRp_lin_norm(1));
0321 if ~iscell(yabs),
0322 rays{iy}.mask_abs_lin = sdP_2piRp_ds_lin_norm > opt.abs_step;
0323 end
0324 if opt.abs_max > 0,
0325 rays{iy}.is_abs_max_lin = min([ns,find(sP_2piRp_lin_norm < opt.abs_max)]);
0326 else
0327 rays{iy}.is_abs_max_lin = ns;
0328 end
0329
0330 if isfield(opt,'mode') && opt.mode == 'y',
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340 spmode = rays{iy}.spmode(1:rays{iy}.is_abs_max_lin);
0341
0342 rays{iy}.mask_p_lin{1} = 1:rays{iy}.ns == 1;
0343 rays{iy}.mask_m_lin{1} = 1:rays{iy}.ns == 1;
0344
0345 imc_list = 1+[0,find(spmode(2:end) ~= spmode(1:end-1)),rays{iy}.is_abs_max_lin];
0346
0347 pmode = spmode(1);
0348
0349 for imc = 1:length(imc_list)-1,
0350
0351 mask_mc = 1:rays{iy}.ns >= imc_list(imc) & 1:rays{iy}.ns < imc_list(imc+1);
0352
0353 if pmode == 1,
0354 rays{iy}.mask_p_lin = [rays{iy}.mask_p_lin,mask_mc];
0355 else
0356 rays{iy}.mask_m_lin = [rays{iy}.mask_m_lin,mask_mc];
0357 end
0358
0359 pmode = ~pmode;
0360
0361 end
0362
0363 else
0364
0365 rays{iy}.mask_p_lin = NaN;
0366 rays{iy}.mask_m_lin = NaN;
0367
0368 end
0369
0370 rays{iy}.is_abs_lin = min(find(sdP_2piRp_ds_lin_norm == max(sdP_2piRp_ds_lin_norm)));
0371
0372 yrho_abs_lin(iy) = rays{iy}.srho(rays{iy}.is_abs_lin);
0373 yNpar_abs_lin(iy) = real(rays{iy}.sNpar(rays{iy}.is_abs_lin));
0374 yPtot_abs_lin(iy) = 1 - sP_2piRp_lin_norm(end);
0375
0376 [rays{iy}.dP_lin_normdrho,rhog_dep] = radialdampingprofile_jd(rays{iy}.srho,rays{iy}.sP_2piRp_lin/rays{iy}.sP_2piRp_lin(1),nr_dep);
0377
0378 dPdrho_lin = dPdrho_lin + rays{iy}.dP_lin_normdrho*rays{iy}.P0_2piRp*2*pi*Rp;
0379
0380 if opt.disp_rays == 'y',
0381 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0382 graph1D_jd(rays{iy}.ss,rays{iy}.sP_2piRp_lin*2*pi*equil.Rp,0,0,'ray length (m)','Power (W)',['ray #',int2str(iy),', N_{||0} = ',num2str(real(rays{iy}.sNpar(1)))],NaN,'','','--','none','r',2);
0383 else
0384 graph1D_jd(rays{iy}.ss,rays{iy}.sP_2piRp_lin*2*pi*equil.Rp,0,0,'ray length (m)','Power (W)',['ray #',int2str(iy),', N_{||0} = ',num2str(real(rays{iy}.sNpar(1)))],NaN,'','','-','none','r',2);
0385 end
0386
0387 legend('Linear absorption (RLA)','Location','SouthWest')
0388 end
0389
0390 end
0391
0392 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0393
0394 sP_2piRp_lin_coll_norm = rays{iy}.sP_2piRp_lin_coll/rays{iy}.sP_2piRp_lin_coll(1);
0395 sdP_2piRp_ds_lin_coll_norm = rays{iy}.sdP_2piRp_ds_lin_coll/max(rays{iy}.sdP_2piRp_ds_lin_coll+eps).*(1 - sP_2piRp_lin_coll_norm(end)/sP_2piRp_lin_coll_norm(1));
0396 if ~iscell(yabs),
0397 rays{iy}.mask_abs_lin_coll = sdP_2piRp_ds_lin_coll_norm > opt.abs_step;
0398 end
0399 if opt.abs_max > 0,
0400 rays{iy}.is_abs_max_lin_coll = min([ns,find(sP_2piRp_lin_coll_norm < opt.abs_max)]);
0401 else
0402 rays{iy}.is_abs_max_lin_coll = ns;
0403 end
0404
0405 if isfield(opt,'mode') && opt.mode == 'y',
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415 spmode = rays{iy}.spmode(1:rays{iy}.is_abs_max_lin_coll);
0416
0417 rays{iy}.mask_p_lin_coll{1} = 1;
0418 rays{iy}.mask_m_lin_coll{1} = 1;
0419
0420 imc_list = 1+[0,find(spmode(2:end) ~= spmode(1:end-1)),rays{iy}.is_abs_max_lin_coll];
0421
0422 pmode = spmode(1);
0423
0424 for imc = 1:length(imc_list)-1,
0425
0426 mask_mc = imc_list(imc):(imc_list(imc+1) - 1);
0427
0428 if pmode == 1,
0429 rays{iy}.mask_p_lin_coll = [rays{iy}.mask_p_lin_coll,mask_mc];
0430 else
0431 rays{iy}.mask_m_lin_coll = [rays{iy}.mask_m_lin_coll,mask_mc];
0432 end
0433
0434 pmode = ~pmode;
0435
0436 end
0437
0438 else
0439
0440 rays{iy}.mask_p_lin_coll = NaN;
0441 rays{iy}.mask_m_lin_coll = NaN;
0442
0443 end
0444
0445 rays{iy}.is_abs_lin_coll = min(find(sdP_2piRp_ds_lin_coll_norm == max(sdP_2piRp_ds_lin_coll_norm)));
0446
0447 yrho_abs_lin_coll(iy) = rays{iy}.srho(rays{iy}.is_abs_lin_coll);
0448 yNpar_abs_lin_coll(iy) = real(rays{iy}.sNpar(rays{iy}.is_abs_lin_coll));
0449 yPtot_abs_lin_coll(iy) = 1 - sP_2piRp_lin_coll_norm(end);
0450
0451 [rays{iy}.dP_lin_coll_normdrho,rhog_dep] = radialdampingprofile_jd(rays{iy}.srho,rays{iy}.sP_2piRp_lin_coll/rays{iy}.sP_2piRp_lin_coll(1),nr_dep);
0452
0453 dPdrho_lin_coll = dPdrho_lin_coll + rays{iy}.dP_lin_coll_normdrho*rays{iy}.P0_2piRp*2*pi*Rp;
0454
0455 if opt.disp_rays == 'y',
0456 hold on,graph1D_jd(rays{iy}.ss,rays{iy}.sP_2piRp_lin_coll*2*pi*equil.Rp,0,0,'ray length (m)','Power (W)',['ray #',int2str(iy),', N_{||0} = ',num2str(real(rays{iy}.sNpar(1)))],NaN,'','','-','none','r',2);
0457
0458 legend('Linear absorption (RLA)','Linear absorption (RLA + NRCA)','Location','SouthWest');
0459 end
0460
0461 else
0462
0463 rays{iy}.is_abs_max_lin_coll = ns;
0464 rays{iy}.is_abs_lin_coll = NaN;
0465 rays{iy}.dP_normdrho_lin_coll = NaN;
0466 yrho_abs_lin_coll(iy) = NaN;
0467 yNpar_abs_lin_coll(iy) = NaN;
0468 yPtot_abs_lin_coll(iy) = NaN;
0469
0470 end
0471
0472 if opt.luke && isfield(rays{iy},'sP_2piRp'),
0473 sP_2piRp_norm = rays{iy}.sP_2piRp{end}/rays{iy}.sP_2piRp{end}(1);
0474 sdP_2piRp_ds_norm = rays{iy}.sdP_2piRp_ds{end}/max(rays{iy}.sdP_2piRp_ds{end}+eps).*(1 - sP_2piRp_norm(end)/sP_2piRp_norm(1));
0475 if ~iscell(yabs),
0476 rays{iy}.mask_abs = sdP_2piRp_ds_norm > opt.abs_step;
0477 end
0478 if opt.abs_max > 0,
0479 rays{iy}.is_abs_max = min([ns,find(sP_2piRp_norm < opt.abs_max)]);
0480 else
0481 rays{iy}.is_abs_max = ns;
0482 end
0483
0484 if isfield(opt,'mode') && opt.mode == 'y',
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494 spmode = rays{iy}.spmode(1:rays{iy}.is_abs_max);
0495
0496 rays{iy}.mask_p{1} = 1;
0497 rays{iy}.mask_m{1} = 1;
0498
0499 imc_list = 1+[0,find(spmode(2:end) ~= spmode(1:end-1)),rays{iy}.is_abs_max];
0500
0501 pmode = spmode(1);
0502
0503 for imc = 1:length(imc_list)-1,
0504
0505 mask_mc = imc_list(imc):(imc_list(imc+1) - 1);
0506
0507 if pmode == 1,
0508 rays{iy}.mask_p = [rays{iy}.mask_p,mask_mc];
0509 else
0510 rays{iy}.mask_m = [rays{iy}.mask_m,mask_mc];
0511 end
0512
0513 pmode = ~pmode;
0514
0515 end
0516
0517 else
0518
0519 rays{iy}.mask_p = NaN;
0520 rays{iy}.mask_m = NaN;
0521
0522 end
0523
0524 rays{iy}.is_abs = min(find(sdP_2piRp_ds_norm == max(sdP_2piRp_ds_norm)));
0525
0526 yrho_abs(iy) = rays{iy}.srho(rays{iy}.is_abs);
0527 yNpar_abs(iy) = real(rays{iy}.sNpar(rays{iy}.is_abs));
0528 yPtot_abs(iy) = 1 - sP_2piRp_norm(end);
0529
0530 rays{iy}.dP_normdrho = radialdampingprofile_jd(rays{iy}.srho,rays{iy}.sP_2piRp{end}/rays{iy}.sP_2piRp{end}(1),nr_dep);
0531
0532 dPdrho = dPdrho + rays{iy}.dP_normdrho*rays{iy}.P0_2piRp*2*pi*Rp;
0533
0534 if opt.disp_rays == 'y',
0535 if ~(isfield(waves{1},'colldamp') && waves{1}.colldamp == 1),
0536 hold on,graph1D_jd(rays{iy}.ss,rays{iy}.sP_2piRp{1}*2*pi*equil.Rp,0,0,'ray length (m)','Power (W)',['ray #',int2str(iy),', N_{||0} = ',num2str(real(rays{iy}.sNpar(1)))],NaN,'','','--','none','k',2);
0537 legend('Linear absorption (RLA)','LUKE quasilinear absorption (RLA)','Location','SouthWest');
0538 end
0539 end
0540
0541 else
0542
0543 rays{iy}.is_abs_max = ns;
0544 rays{iy}.is_abs = NaN;
0545 rays{iy}.dP_normdrho = NaN;
0546 yrho_abs(iy) = NaN;
0547 yNpar_abs(iy) = NaN;
0548 yPtot_abs(iy) = NaN;
0549
0550 end
0551
0552 if opt.luke && isfield(waves{1},'colldamp') && waves{1}.colldamp == 1 && isfield(rays{iy},'sP_2piRp_coll_luke'),
0553 sP_2piRp_coll_luke_norm = rays{iy}.sP_2piRp_coll_luke{end}/rays{iy}.sP_2piRp_coll_luke{end}(1);
0554 sdP_2piRp_coll_luke_ds_norm = rays{iy}.sdP_2piRp_coll_luke_ds{end}/max(rays{iy}.sdP_2piRp_coll_luke_ds{end}+eps).*(1 - sP_2piRp_coll_luke_norm(end)/sP_2piRp_coll_luke_norm(1));
0555 if ~iscell(yabs),
0556 rays{iy}.mask_abs_coll_luke = sdP_2piRp_coll_luke_ds_norm > opt.abs_step;
0557 end
0558 if opt.abs_max > 0,
0559 rays{iy}.is_abs_max_coll_luke = min([ns,find(sP_2piRp_coll_luke_norm < opt.abs_max)]);
0560 else
0561 rays{iy}.is_abs_max_coll_luke = ns;
0562 end
0563
0564 if isfield(opt,'mode') && opt.mode == 'y',
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574 spmode = rays{iy}.spmode(1:rays{iy}.is_abs_max_coll_luke);
0575
0576 rays{iy}.mask_p_coll_luke{1} = 1;
0577 rays{iy}.mask_m_coll_luke{1} = 1;
0578
0579 imc_list = 1+[0,find(spmode(2:end) ~= spmode(1:end-1)),rays{iy}.is_abs_max_coll_luke];
0580
0581 pmode = spmode(1);
0582
0583 for imc = 1:length(imc_list)-1,
0584
0585 mask_mc = imc_list(imc):(imc_list(imc+1) - 1);
0586
0587 if pmode == 1,
0588 rays{iy}.mask_p_coll_luke = [rays{iy}.mask_p_coll_luke,mask_mc];
0589 else
0590 rays{iy}.mask_m_coll_luke = [rays{iy}.mask_m_coll_luke,mask_mc];
0591 end
0592
0593 pmode = ~pmode;
0594
0595 end
0596
0597 else
0598
0599 rays{iy}.mask_p_coll_luke = NaN;
0600 rays{iy}.mask_m_coll_luke = NaN;
0601
0602 end
0603
0604 rays{iy}.is_abs_coll_luke = min(find(sdP_2piRp_coll_luke_ds_norm == max(sdP_2piRp_coll_luke_ds_norm)));
0605
0606 yrho_abs_coll_luke(iy) = rays{iy}.srho(rays{iy}.is_abs_coll_luke);
0607 yNpar_abs_coll_luke(iy) = real(rays{iy}.sNpar(rays{iy}.is_abs_coll_luke));
0608 yPtot_abs_coll_luke(iy) = 1 - sP_2piRp_coll_luke_norm(end);
0609
0610 [rays{iy}.dP_coll_luke_normdrho,rhog_dep] = radialdampingprofile_jd(rays{iy}.srho,rays{iy}.sP_2piRp_coll_luke{end}/rays{iy}.sP_2piRp_coll_luke{end}(1),nr_dep);
0611
0612 rays{iy}.dP_coll_luke_normdrho = radialdampingprofile_jd(rays{iy}.srho,rays{iy}.sP_2piRp_coll_luke{end}/rays{iy}.sP_2piRp_coll_luke{end}(1),nr_dep);
0613
0614 dPdrho_coll_luke = dPdrho_coll_luke + rays{iy}.dP_coll_luke_normdrho*rays{iy}.P0_2piRp*2*pi*Rp;
0615
0616 if opt.disp_rays == 'y',
0617 hold on,graph1D_jd(rays{iy}.ss,rays{iy}.sP_2piRp_coll_luke{1}*2*pi*equil.Rp,0,0,'ray length (m)','Power (W)',['ray #',int2str(iy),', N_{||0} = ',num2str(real(rays{iy}.sNpar(1)))],NaN,'','','-','none','k',2);
0618
0619 legend('Linear absorption (RLA)','Linear absorption (RLA + NRCA)','LUKE quasilinear absorption (RLA + NRCA)','Location','SouthWest');
0620 end
0621
0622 else
0623
0624 rays{iy}.sP_2piRp_coll_luke = NaN;
0625 rays{iy}.is_abs_max_coll_luke = ns;
0626 rays{iy}.is_abs_coll_luke = NaN;
0627 rays{iy}.dP_normdrho_coll_luke = NaN;
0628 rays{iy}.mask_abs_coll_luke = NaN;
0629 yrho_abs_coll_luke(iy) = NaN;
0630 yNpar_abs_coll_luke(iy) = NaN;
0631 yPtot_abs_coll_luke(iy) = NaN;
0632
0633
0634 end
0635
0636 if opt.disp_rays == 'y',
0637 if opt.luke,
0638 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0639 disp(['Ray # ',num2str(iy),': fraction of power absorbed (LUKE: quasilinear, RLA + NRCA): ',num2str(round(yPtot_abs_coll_luke(iy)*100)),' %'])
0640 else
0641 disp(['Ray # ',num2str(iy),': fraction of power absorbed (LUKE: quasilinear, RLA): ',num2str(round(yPtot_abs(iy)*100)),' %'])
0642 end
0643 end
0644
0645 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0646 disp(['Ray # ',num2str(iy),': fraction of power absorbed (C3PO: linear, RLA + NRCA): ',num2str(round(yPtot_abs_lin_coll(iy)*100)),' %'])
0647 else
0648 disp(['Ray # ',num2str(iy),': fraction of power absorbed (C3PO: linear, RLA): ',num2str(round(yPtot_abs_lin(iy)*100)),' %'])
0649 end
0650 end
0651
0652 end
0653
0654 if sum(dPdrho) == 0,
0655 opt.luke = false;
0656 end
0657
0658 rho_dep = interp1(prho_g,prho,rhog_dep);
0659
0660 drhog_dep = diff([0,(rhog_dep(1:end-1) + rhog_dep(2:end))/2,1]);
0661 drho_dep = diff([0,(rho_dep(1:end-1) + rho_dep(2:end))/2,1]);
0662
0663 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0664 dPdrho_lin = dPdrho_lin.*drhog_dep./drho_dep;
0665 dPdrho_lin_coll = dPdrho_lin_coll.*drhog_dep./drho_dep;
0666 dPdrho_coll_luke = dPdrho_coll_luke.*drhog_dep./drho_dep;
0667 else
0668 dPdrho_lin = dPdrho_lin.*drhog_dep./drho_dep;
0669 dPdrho_lin_coll = zeros(size(dPdrho_lin));
0670 dPdrho_coll_luke = zeros(size(dPdrho_lin));
0671 end
0672
0673 dPdrho = dPdrho.*drhog_dep./drho_dep;
0674
0675
0676
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867
0868
0869
0870
0871
0872
0873
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888 style = '-';
0889 style2 = 'none';
0890 style3 = '--';
0891 marker = 'none';
0892 marker1 = '+';
0893 marker2 = '.';
0894 marker3 = 'o';
0895 color1 = 'r';
0896 color2 = 'b';
0897 color3 = 'm';
0898 color4 = 'g';
0899 color5 = 'k';
0900
0901 colors = {color1,color2,color3,color4};
0902 ncols = length(colors);
0903
0904 width1 = 2;
0905 width2 = 0.5+16i;
0906
0907 if ~isfield(opt,'font'),
0908 opt.font = 20+14i;
0909 end
0910
0911 if ~isfield(opt,'axs'),
0912 figure(1),clf,set(1,'name','Poloidal trajectories')
0913 ax = gca;
0914 red = 0.9;
0915 lspace = 0.7;
0916 bspace = 0.7;
0917 else
0918 ax = opt.axs(1);
0919 red = 1;
0920 lspace = NaN;
0921 bspace = NaN;
0922 end
0923
0924 if any(strfind(equil.id,'TCV')) && strcmp(opt.vessel_opt,'y')
0925 tcvview('avt');
0926 tcvview('color','t',[0.75 0.75 0.75]);
0927 title('');
0928 hold on;
0929 Rpdisp = Rp;
0930 Zpdisp = Zp;
0931
0932 legpol = NaN;
0933 else
0934 Rpdisp = 0;
0935 Zpdisp = 0;
0936
0937 end
0938
0939 xlim = [xmin + Rpdisp,xmax + Rpdisp];
0940 ylim = [ymin + Zpdisp,ymax + Zpdisp];
0941 xlab = 'x (m)';
0942 ylab = 'y (m)';
0943 tit = '';
0944
0945 for iy = 1:ny,
0946
0947 if opt.luke,
0948
0949 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max;
0950 mask_abs =rays{iy}.mask_abs;
0951
0952 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0953 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_coll_luke;
0954 mask_abs =rays{iy}.mask_abs_coll_luke;
0955 end
0956
0957 else
0958 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin;
0959 mask_abs = rays{iy}.mask_abs_lin;
0960
0961 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0962 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin_coll;
0963 mask_abs =rays{iy}.mask_abs_lin_coll;
0964 end
0965
0966 end
0967
0968 for ipass = 1:length(rays{iy}.mask_pass),
0969
0970 if isfield(opt,'mode') && opt.mode == 'y',
0971
0972 if opt.luke,
0973 mask_p = rays{iy}.mask_p;
0974 mask_m = rays{iy}.mask_m;
0975
0976 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0977 mask_p = rays{iy}.mask_p_coll_luke;
0978 mask_m = rays{iy}.mask_m_coll_luke;
0979 end
0980 else
0981 mask_p = rays{iy}.mask_p_lin;
0982 mask_m = rays{iy}.mask_m_lin;
0983
0984 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
0985 mask_p = rays{iy}.mask_p_lin_coll;
0986 mask_m = rays{iy}.mask_m_lin_coll;
0987 end
0988 end
0989
0990 graph1D_jd(rays{iy}.sx(mask_p{1} & rays{iy}.mask_pass{ipass}) + Rpdisp,rays{iy}.sy(mask_p{1} & rays{iy}.mask_pass{ipass}) + Zpdisp,0,0,'','','',NaN,xlim,ylim,style,marker,rays{iy}.color,width1,opt.font,ax);
0991 graph1D_jd(rays{iy}.sx(mask_m{1} & rays{iy}.mask_pass{ipass}) + Rpdisp,rays{iy}.sy(mask_m{1} & rays{iy}.mask_pass{ipass}) + Zpdisp,0,0,'','','',legpol,xlim,ylim,style3,marker,rays{iy}.color,width1,opt.font,ax);
0992 for ip = 2:length(mask_p),
0993 graph1D_jd(rays{iy}.sx(mask_p{ip} & rays{iy}.mask_pass{ipass}) + Rpdisp,rays{iy}.sy(mask_p{ip} & rays{iy}.mask_pass{ipass}) + Zpdisp,0,0,'','','',NaN,xlim,ylim,style,marker,rays{iy}.color,width1,opt.font,ax);
0994 end
0995 for im = 2:length(mask_m),
0996 graph1D_jd(rays{iy}.sx(mask_m{im} & rays{iy}.mask_pass{ipass}) + Rpdisp,rays{iy}.sy(mask_m{im} & rays{iy}.mask_pass{ipass}) + Zpdisp,0,0,'','','',NaN,xlim,ylim,style3,marker,rays{iy}.color,width1,opt.font,ax);
0997 end
0998 else
0999 graph1D_jd(rays{iy}.sx(mask_max & rays{iy}.mask_pass{ipass}) + Rpdisp,rays{iy}.sy(mask_max & rays{iy}.mask_pass{ipass}) + Zpdisp,0,0,'','','',NaN,xlim,ylim,rays{iy}.style,marker,rays{iy}.color,width1,opt.font,ax);
1000 end
1001 end
1002
1003 graph1D_jd(rays{iy}.sx(mask_max & mask_abs) + Rpdisp,rays{iy}.sy(mask_max & mask_abs) + Zpdisp,0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font,ax);
1004
1005 if ~isempty(rays{iy}.refs),
1006 for iref = 1:length(rays{iy}.refs),
1007 graph1D_jd(rays{iy}.refs{iref}.x + Rpdisp,rays{iy}.refs{iref}.y + Zpdisp,0,0,'','','',NaN,xlim,ylim,style,marker3,rays{iy}.color,width2,opt.font,ax);
1008 end
1009 end
1010 end
1011 [ax] = graph1D_jd(ptx_disp' + Rpdisp,pty_disp' + Zpdisp,0,0,xlab,ylab,tit,NaN,xlim,ylim,style,marker,color5,width2,opt.font,ax,red,lspace,bspace);
1012 if 0,
1013 [ax] = graph2D_jd(R + Rpdisp,Z + Zpdisp,yres','','','',xlim,ylim,0,NaN,[1:10],0,style,color5,width1,opt.font,ax);
1014 end
1015 axis(ax,'equal');
1016 axis(ax,[xlim,ylim]);
1017 if any(strfind(equil.id,'TCV')) && strcmp(opt.vessel_opt,'y')
1018 axis(ax,'auto');
1019 set(ax,'XTick',[0:0.2:1.4],'YTick',[-0.8:0.2:0.8]);
1020 end
1021
1022 figname = [waves{1}.equil_id,'-'];
1023 for ii = 1:length(waves)
1024 figname = [figname,waves{ii}.id,'-'];
1025 end
1026 print_jd(opt.print,[figname,'Pol_traj'],'figures_WAVE');
1027
1028 if isfield(opt,'pol') && opt.pol == 1,
1029 return
1030 end
1031
1032 if ~isfield(opt,'axs'),
1033 figure(2),clf,set(2,'name','Toroidal trajectories')
1034 ax = gca;
1035 else
1036 ax = opt.axs(2);
1037 end
1038
1039 xlim = [Xmin,Xmax];
1040 ylim = [Ymin,Ymax];
1041 xlab = 'X (m)';
1042 ylab = 'Y (m)';
1043 tit = '';
1044
1045 for iy = 1:ny,
1046
1047 if opt.luke,
1048
1049 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max;
1050 mask_abs =rays{iy}.mask_abs;
1051
1052 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1053 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_coll_luke;
1054 mask_abs =rays{iy}.mask_abs_coll_luke;
1055 end
1056
1057 else
1058 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin;
1059 mask_abs = rays{iy}.mask_abs_lin;
1060
1061 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1062 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin_coll;
1063 mask_abs =rays{iy}.mask_abs_lin_coll;
1064 end
1065
1066 end
1067
1068 if isfield(opt,'mode') && opt.mode == 'y',
1069
1070 if opt.luke,
1071 mask_p = rays{iy}.mask_p;
1072 mask_m = rays{iy}.mask_m;
1073
1074 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1075 mask_p = rays{iy}.mask_p_coll_luke;
1076 mask_m = rays{iy}.mask_m_coll_luke;
1077 end
1078 else
1079 mask_p = rays{iy}.mask_p_lin;
1080 mask_m = rays{iy}.mask_m_lin;
1081
1082 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1083 mask_p = rays{iy}.mask_p_lin_coll;
1084 mask_m = rays{iy}.mask_m_lin_coll;
1085 end
1086 end
1087
1088 graph1D_jd(rays{iy}.sX(mask_p{1}),rays{iy}.sY(mask_p{1}),0,0,'','','',NaN,xlim,ylim,style,marker,rays{iy}.color,width1,opt.font,ax);
1089 graph1D_jd(rays{iy}.sX(mask_m{1}),rays{iy}.sY(mask_m{1}),0,0,'','','',legpol,xlim,ylim,style3,marker,rays{iy}.color,width1,opt.font,ax);
1090 for ip = 2:length(mask_p),
1091 graph1D_jd(rays{iy}.sX(mask_p{ip}),rays{iy}.sY(mask_p{ip}),0,0,'','','',NaN,xlim,ylim,style,marker,rays{iy}.color,width1,opt.font,ax);
1092 end
1093 for im = 2:length(mask_m),
1094 graph1D_jd(rays{iy}.sX(mask_m{im}),rays{iy}.sY(mask_m{im}),0,0,'','','',NaN,xlim,ylim,style3,marker,rays{iy}.color,width1,opt.font,ax);
1095 end
1096 else
1097 graph1D_jd(rays{iy}.sX(mask_max),rays{iy}.sY(mask_max),0,0,'','','',NaN,xlim,ylim,style,marker,rays{iy}.color,width1,opt.font,ax);
1098 end
1099
1100 graph1D_jd(rays{iy}.sX(mask_max & mask_abs),rays{iy}.sY(mask_max & mask_abs),0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font,ax);
1101 if ~isempty(rays{iy}.refs),
1102 for iref = 1:length(rays{iy}.refs),
1103 graph1D_jd(rays{iy}.refs{iref}.X,rays{iy}.refs{iref}.Y,0,0,'','','',NaN,xlim,ylim,style,marker3,rays{iy}.color,width2,opt.font,ax);
1104 end
1105 end
1106 end
1107 [ax] = graph1D_jd(X_disp',Y_disp',0,0,xlab,ylab,tit,NaN,xlim,ylim,style,marker,color5,width2,opt.font,ax,red,lspace,bspace);
1108 axis(ax,'equal');
1109 axis(ax,[xlim,ylim]);
1110
1111 print_jd(opt.print,[figname,'Tor_traj'],'figures_WAVE');
1112
1113 smax = 0;
1114
1115 Spmax = 0;
1116 for iy = 1:ny,
1117 smax = max(smax,rays{iy}.ss(end));
1118
1119 Spmax = max([Spmax,abs(rays{iy}.sphi_xyz(1,:))]);
1120 end
1121
1122 if ~isfield(opt,'axs'),
1123 figure(3),clf,set(3,'name','Radius of deposition peak')
1124 xlim = [0,ny+1];
1125 ylim = [0,1];
1126 xlab = 'ray #';
1127 ylab = '\rho^{abs}';
1128 tit = '';
1129
1130 if opt.luke,
1131 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1132 graph1D_jd(1:ny,yrho_abs_coll_luke,0,0,'','','',NaN,xlim,ylim,style2,marker3,color1,width1);
1133 leg = {'LUKE (RLA + NRCA)','C3PO (RLA + NRCA)'};
1134 else
1135 graph1D_jd(1:ny,yrho_abs,0,0,'','','',NaN,xlim,ylim,style2,marker3,color1,width1);
1136 leg = {'LUKE (RLA)','C3PO (RLA)'};
1137 end
1138 else
1139 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1140 leg = {'C3PO (RLA + NRCA)'};
1141 else
1142 leg = {'C3PO (RLA)'};
1143 end
1144 end
1145
1146 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1147 graph1D_jd(1:ny,yrho_abs_lin_coll,0,0,xlab,ylab,tit,leg,xlim,ylim,style2,marker1,color2,width1,opt.font,gca,red,lspace,bspace);
1148 else
1149 graph1D_jd(1:ny,yrho_abs_lin,0,0,xlab,ylab,tit,leg,xlim,ylim,style2,marker1,color2,width1,opt.font,gca,red,lspace,bspace);
1150 end
1151
1152 print_jd(opt.print,[figname,'Rad_dep_peak'],'figures_WAVE');
1153
1154 figure(4),clf,set(4,'name','n// of deposition peak')
1155 xlim = [0,ny+1];
1156 ylim = NaN;
1157 xlab = 'ray #';
1158 ylab = 'n_{||}^{abs}';
1159 tit = '';
1160
1161 if opt.luke,
1162 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1163 graph1D_jd(1:ny,real(yNpar_abs_coll_luke),0,0,'','','',NaN,xlim,ylim,style2,marker3,color1,width1);
1164 else
1165 graph1D_jd(1:ny,real(yNpar_abs),0,0,'','','',NaN,xlim,ylim,style2,marker3,color1,width1);
1166 end
1167 end
1168
1169 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1170 graph1D_jd(1:ny,real(yNpar_abs_lin_coll),0,0,xlab,ylab,tit,leg,xlim,ylim,style2,marker1,color2,width1,opt.font,gca,red,lspace,bspace);
1171 else
1172 graph1D_jd(1:ny,real(yNpar_abs_lin),0,0,xlab,ylab,tit,leg,xlim,ylim,style2,marker1,color2,width1,opt.font,gca,red,lspace,bspace);
1173 end
1174
1175 print_jd(opt.print,[figname,'Npar_dep_peak'],'figures_WAVE');
1176 end
1177
1178 if ~isfield(opt,'axs'),
1179 figure(5),clf,set(5,'name','Total deposition profile')
1180 ax = gca;
1181 ylim = NaN;
1182 else
1183 ax = opt.axs(3);
1184 leg = NaN;
1185 if sum(dPdrho_lin_coll) ~= 0,
1186 ylim = [0,max(dPdrho_lin_coll/1e6)]*1.2;
1187 else
1188 ylim = [0,max(dPdrho_lin/1e6)]*1.2;
1189 end
1190 end
1191
1192 xlim = [0,1];
1193 xlab = plab;
1194 ylab = 'dPd\rho (MW)';
1195 tit = '';
1196
1197 if opt.luke,
1198 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1199 graph1D_jd(rho_dep,dPdrho_coll_luke/1e6,0,0,'','','',NaN,xlim,ylim,style,marker3,color1,width1,opt.font,ax);
1200 else
1201 graph1D_jd(rho_dep,dPdrho/1e6,0,0,'','','',NaN,xlim,ylim,style,marker3,color1,width1,opt.font,ax);
1202 end
1203 end
1204
1205 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1206 graph1D_jd(rho_dep,dPdrho_lin_coll/1e6,0,0,xlab,ylab,tit,leg,xlim,ylim,style3,marker1,color2,width1,opt.font,ax,red,lspace,bspace);
1207 else
1208 graph1D_jd(rho_dep,dPdrho_lin/1e6,0,0,xlab,ylab,tit,leg,xlim,ylim,style3,marker1,color2,width1,opt.font,ax,red,lspace,bspace);
1209 end
1210
1211 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1 && opt.luke,
1212 if ~isfield(opt,'axs'),
1213 figure(6),clf,set(6,'name','Total deposition profile (quasilinear, LUKE)')
1214 ax = gca;
1215 ylim = NaN;
1216 else
1217 ax = opt.axs(3);
1218 leg = NaN;
1219 if sum(dPdrho_coll_luke) ~= 0,
1220 ylim = [0,max(dPdrho_coll_luke/1e6)]*1.2;
1221 end
1222 end
1223
1224 xlim = [0,1];
1225 xlab = plab;
1226 ylab = 'dPd\rho (MW)';
1227 tit = '';
1228 leg = {'LUKE (RLA + NRCA)','LUKE (RLA)'};
1229
1230 graph1D_jd(rho_dep,dPdrho_coll_luke/1e6,0,0,'','','',NaN,xlim,ylim,style,marker3,color1,width1,opt.font,ax);
1231 graph1D_jd(rho_dep,dPdrho/1e6,0,0,xlab,ylab,tit,leg,xlim,ylim,style3,marker3,color2,width1,opt.font,ax,red,lspace,bspace);
1232
1233 else
1234 if ishandle(figure(6))
1235 close(figure(6))
1236 end
1237 end
1238
1239 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1240 if ~isfield(opt,'axs'),
1241 figure(7),clf,set(7,'name','Total deposition profile (linear, C3PO)')
1242 ax = gca;
1243 ylim = NaN;
1244 else
1245 ax = opt.axs(3);
1246 leg = NaN;
1247 if sum(dPdrho_lin_coll) ~= 0,
1248 ylim = [0,max(dPdrho_lin_coll/1e6)]*1.2;
1249 end
1250 end
1251
1252 xlim = [0,1];
1253 xlab = plab;
1254 ylab = 'dPd\rho (MW)';
1255 tit = '';
1256 leg = {'C3PO (RLA + NRCA)','C3PO (RLA)'};
1257
1258 graph1D_jd(rho_dep,dPdrho_lin_coll/1e6,0,0,'','','',NaN,xlim,ylim,style,marker3,color1,width1,opt.font,ax);
1259 graph1D_jd(rho_dep,dPdrho_lin/1e6,0,0,xlab,ylab,tit,leg,xlim,ylim,style3,marker3,color2,width1,opt.font,ax,red,lspace,bspace);
1260
1261 else
1262 if ishandle(figure(7))
1263 close(figure(7))
1264 end
1265 end
1266
1267 set(ax,'xtickmode','auto');drawnow;
1268 set(ax,'ytickmode','auto');drawnow;
1269
1270 pause(0.1);
1271
1272 print_jd(opt.print,[figname,'Tot_dep_prof'],'figures_WAVE');
1273
1274
1275
1276 disp(' ')
1277 disp('-----> Display specific ray information')
1278 disp(' ')
1279
1280 iw = NaN;
1281 ibb = NaN;
1282 ib = 0;
1283 iwdef = 1;
1284
1285 if isfield(opt,'nospec') && opt.nospec == 1,
1286 iw = 0;
1287 end
1288
1289 while iw ~= 0 && any(ibb ~= 0)
1290
1291 ib = ib + 1;
1292
1293 iw = input_dke_yp('wave index (0 to return)',iwdef,0:nw,'',[1,1]);
1294
1295 if iw == 0,
1296 continue
1297 end
1298
1299 if (isfield(waves{iw}.rayinit,'type') && strcmp(waves{iw}.rayinit.type,'LH')) || (isfield(waves{iw}.rayinit.launch,'type') && strcmp(waves{iw}.rayinit.launch.type,'LH'))
1300 waves{iw}.rayinit.Rp = Rp;
1301 plot_spectrum_from_launch_jd(waves{iw}.rayinit,NaN,-1,[])
1302
1303 plot_spectrum_from_launch_jd(waves{iw}.rayinit.launch,NaN,-1,[])
1304
1305 end
1306
1307 disp(['-----------------------------------------------------------'])
1308 disp(['Initial Z (m) : ',num2str(waves{iw}.rayinit.launch.rZ0)])
1309 disp(['Initial N_par0 : ',num2str(waves{iw}.rayinit.launch.bNpar0)])
1310 disp(['-----------------------------------------------------------'])
1311 disp(['-----------------------------------------------------------'])
1312
1313 disp(['Index table for each ray. Missing rays have not propagated in the plasma. '])
1314 disp(['-----------------------------------------------------------'])
1315 for iray = 1:length(waves{iw}.rayinit.launch.bNpar0)
1316 disp_ray_launch = ['Npar0 = ',num2str(waves{iw}.rayinit.launch.bNpar0(iray))];
1317 for iz = 1:length(waves{iw}.rayinit.launch.rZ0)
1318 for ibb0 = 1:nymask(iw),
1319 iy0 = sum(nymask(1:iw - 1)) + ibb0;
1320 if abs(waves{iw}.rayinit.launch.bNpar0(iray) - real(rays{iy0}.sNpar(1))) < 0.01,
1321 if abs(waves{iw}.rayinit.launch.rZ0(iz) - rays{iy0}.sy(1)) < 0.01,
1322 disp_ray_launch = [disp_ray_launch,', (#',int2str(ibb0),') ZO = ',num2str(waves{iw}.rayinit.launch.rZ0(iz))];
1323 end
1324 end
1325 end
1326 end
1327 disp(disp_ray_launch);
1328 end
1329 disp(['-----------------------------------------------------------'])
1330
1331 ibb = input_dke_yp('ray indices (0 to return)',1,0:nymask(iw));
1332
1333 if ibb == 0,
1334 continue
1335 end
1336
1337 iwdef = 0;
1338
1339 iy = sum(nymask(1:iw - 1)) + ibb;
1340
1341 rays_disp = rays(iy);
1342 nray = length(rays_disp);
1343
1344 f_opt = input_dke_yp('single figure with subplots (0) or multiple figures (1)',0,0:1,'',[1,1]);
1345
1346 pow_opt = input_dke_yp('Normalized power deposition (0) or absolute power deposition (1)',0,0:1,'',[1,1]);
1347 if opt.luke,
1348 c_opt = input_dke_yp('Also plot C3PO (1) or not (0)',1,0:1,'',[1,1]);
1349 end
1350
1351 figlab = ['wave #',num2str(iw),'; ray #',num2str(ibb)];
1352
1353 if waves{iw}.opt_TeNpar == 1,
1354
1355 NparsTe = input_dke_yp('Value for n//*sqrt(Te)',6.5);
1356
1357 end
1358
1359
1360
1361 setfig(f_opt,ib,1,figlab)
1362
1363 xlim = [xmin,xmax];
1364 ylim = [ymin,ymax];
1365 xlab = 'x (m)';
1366 ylab = 'y (m)';
1367 tit = 'poloidal ray trajectory';
1368
1369 for iray = 1:nray,
1370
1371 ray = rays_disp{iray};
1372
1373 if opt.luke,
1374 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1375 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_coll_luke;
1376 mask_abs = ray.mask_abs_coll_luke;
1377 mask_p = ray.mask_p_coll_luke;
1378 mask_m = ray.mask_m_coll_luke;
1379 else
1380 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max;
1381 mask_abs = ray.mask_abs;
1382 mask_p = ray.mask_p;
1383 mask_m = ray.mask_m;
1384 end
1385 else
1386 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1387 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin_coll;
1388 mask_abs = ray.mask_abs_lin_coll;
1389 mask_p = ray.mask_p_lin_coll;
1390 mask_m = ray.mask_m_lin_coll;
1391 else
1392 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin;
1393 mask_abs = ray.mask_abs_lin;
1394 mask_p = ray.mask_p_lin;
1395 mask_m = ray.mask_m_lin;
1396 end
1397 end
1398
1399 if isfield(opt,'mode') && opt.mode == 'y',
1400
1401 graph1D_jd(ray.sx(mask_p{1}),ray.sy(mask_p{1}),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1402 graph1D_jd(ray.sx(mask_m{1}),ray.sy(mask_m{1}),0,0,'','','',legpol,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1403 for ip = 2:length(mask_p),
1404 graph1D_jd(ray.sx(mask_p{ip}),ray.sy(mask_p{ip}),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1405 end
1406 for im = 2:length(mask_m),
1407 graph1D_jd(ray.sx(mask_m{im}),ray.sy(mask_m{im}),0,0,'','','',NaN,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1408 end
1409 else
1410 graph1D_jd(ray.sx(mask_max),ray.sy(mask_max),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1411 end
1412
1413 graph1D_jd(ray.sx(mask_max & mask_abs),ray.sy(mask_max & mask_abs),0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font);
1414
1415 if ~isempty(ray.refs),
1416 for iref = 1:length(ray.refs),
1417 graph1D_jd(ray.refs{iref}.x,ray.refs{iref}.y,0,0,'','','',NaN,xlim,ylim,style,marker3,color5,width2,opt.font);
1418 end
1419 end
1420
1421 end
1422
1423 graph1D_jd(ptx_disp',pty_disp',0,0,xlab,ylab,tit,NaN,xlim,ylim,style,marker,color5,width2,opt.font);
1424
1425 axis('equal');
1426 axis([xlim,ylim]);
1427
1428
1429
1430 setfig(f_opt,ib,2,figlab)
1431
1432 xlim = [Xmin,Xmax];
1433 ylim = [Ymin,Ymax];
1434 xlab = 'X (m)';
1435 ylab = 'Y (m)';
1436 tit = 'toroidal ray trajectory';
1437
1438 for iray = 1:nray,
1439
1440 ray = rays_disp{iray};
1441
1442 if opt.luke,
1443 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1444 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_coll_luke;
1445 mask_abs = ray.mask_abs_coll_luke;
1446 mask_p = ray.mask_p_coll_luke;
1447 mask_m = ray.mask_m_coll_luke;
1448 else
1449 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max;
1450 mask_abs = ray.mask_abs;
1451 mask_p = ray.mask_p;
1452 mask_m = ray.mask_m;
1453 end
1454 else
1455 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1456 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin_coll;
1457 mask_abs = ray.mask_abs_lin_coll;
1458 mask_p = ray.mask_p_lin_coll;
1459 mask_m = ray.mask_m_lin_coll;
1460 else
1461 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin;
1462 mask_abs = ray.mask_abs_lin;
1463 mask_p = ray.mask_p_lin;
1464 mask_m = ray.mask_m_lin;
1465 end
1466 end
1467
1468 if isfield(opt,'mode') && opt.mode == 'y',
1469 graph1D_jd(ray.sX(mask_p{1}),ray.sY(mask_p{1}),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1470 graph1D_jd(ray.sX(mask_m{1}),ray.sY(mask_m{1}),0,0,'','','',legpol,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1471 for ip = 2:length(mask_p),
1472 graph1D_jd(ray.sX(mask_p{ip}),ray.sY(mask_p{ip}),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1473 end
1474 for im = 2:length(mask_m),
1475 graph1D_jd(ray.sX(mask_m{im}),ray.sY(mask_m{im}),0,0,'','','',NaN,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1476 end
1477 else
1478 graph1D_jd(ray.sX(mask_max),ray.sY(mask_max),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1479 end
1480
1481 graph1D_jd(ray.sX(mask_max & mask_abs),ray.sY(mask_max & mask_abs),0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font);
1482
1483 if ~isempty(ray.refs),
1484 for iref = 1:length(ray.refs),
1485 graph1D_jd(ray.refs{iref}.X,ray.refs{iref}.Y,0,0,'','','',NaN,xlim,ylim,style,marker3,color5,width2,opt.font);
1486 end
1487 end
1488
1489 end
1490
1491 graph1D_jd(X_disp',Y_disp',0,0,xlab,ylab,tit,NaN,xlim,ylim,style,marker,color5,width2,opt.font);
1492
1493 axis('equal');
1494 axis([xlim,ylim]);
1495
1496
1497
1498 setfig(f_opt,ib,3,figlab)
1499
1500 xlim = [0,max(ray.ss(mask_max))];
1501 ylim = [0,ceil(1.5*max(abs(real(ray.sNpar(mask_max)))))];
1502 xlab = 's (m)';
1503 ylab = 'n_{||}';
1504 tit = '';
1505
1506 for iray = 1:nray,
1507
1508 ray = rays_disp{iray};
1509
1510 if opt.luke,
1511 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1512 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_coll_luke;
1513 mask_abs = ray.mask_abs_coll_luke;
1514 mask_p = ray.mask_p_coll_luke;
1515 mask_m = ray.mask_m_coll_luke;
1516 else
1517 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max;
1518 mask_abs = ray.mask_abs;
1519 mask_p = ray.mask_p;
1520 mask_m = ray.mask_m;
1521 end
1522 else
1523 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1524 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin_coll;
1525 mask_abs = ray.mask_abs_lin_coll;
1526 mask_p = ray.mask_p_lin_coll;
1527 mask_m = ray.mask_m_lin_coll;
1528 else
1529 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin;
1530 mask_abs = ray.mask_abs_lin;
1531 mask_p = ray.mask_p_lin;
1532 mask_m = ray.mask_m_lin;
1533 end
1534 end
1535
1536 if isfield(opt,'mode') && opt.mode == 'y',
1537 leg = {'|n_{||}| (SW)','|n_{||}| (FW)'};
1538 graph1D_jd(ray.ss(mask_p{1}),abs(real(ray.sNpar(mask_p{1}))),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1539 graph1D_jd(ray.ss(mask_m{1}),abs(real(ray.sNpar(mask_m{1}))),0,0,'','','',NaN,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1540 else
1541 leg = {'|n_{||}|'};
1542 graph1D_jd(ray.ss(mask_max),abs(real(ray.sNpar(mask_max))),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1543 end
1544
1545 if waves{iw}.opt_TeNpar == 1,
1546 graph1D_jd(ray.ss(mask_max),NparsTe./sqrt(ray.sTe(mask_max)),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width2,opt.font);
1547 leg = [leg,[num2str(NparsTe),'/Te^{1/2}'],'n_{||acc}'];
1548 else
1549 leg = [leg,'n_{||acc}'];
1550 end
1551
1552 if f_opt == 1,
1553 graph1D_jd(ray.ss(mask_max),abs(imag(ray.sNpar(mask_max))),0,0,'','','',NaN,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width2,opt.font);
1554 else
1555 graph1D_jd(ray.ss(mask_max),abs(imag(ray.sNpar(mask_max))),0,0,'','','',NaN,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width2,opt.font);
1556 end
1557
1558 if isfield(opt,'mode') && opt.mode == 'y',
1559 for ip = 2:length(mask_p),
1560 graph1D_jd(ray.ss(mask_p{ip}),abs(real(ray.sNpar(mask_p{ip}))),0,0,'','','',NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1561 end
1562 for im = 2:length(mask_m),
1563 graph1D_jd(ray.ss(mask_m{im}),abs(real(ray.sNpar(mask_m{im}))),0,0,'','','',NaN,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1564 end
1565 end
1566
1567 if iray == 1,
1568 graph1D_jd(ray.ss(mask_max & mask_abs),abs(real(ray.sNpar(mask_max & mask_abs))),0,0,xlab,ylab,tit,leg,xlim,ylim,style2,marker2,color5,width2,opt.font);
1569 else
1570 graph1D_jd(ray.ss(mask_max & mask_abs),abs(real(ray.sNpar(mask_max & mask_abs))),0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font);
1571 end
1572
1573 end
1574
1575
1576
1577 setfig(f_opt,ib,4,figlab)
1578
1579 ylab = 'n_{\perp}';
1580 ylim = NaN;
1581
1582 for iray = 1:nray,
1583
1584 ray = rays_disp{iray};
1585
1586 if opt.luke,
1587 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1588 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_coll_luke;
1589 mask_abs = ray.mask_abs_coll_luke;
1590 mask_p = ray.mask_p_coll_luke;
1591 mask_m = ray.mask_m_coll_luke;
1592 else
1593 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max;
1594 mask_abs = ray.mask_abs;
1595 mask_p = ray.mask_p;
1596 mask_m = ray.mask_m;
1597 end
1598 else
1599 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1600 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin_coll;
1601 mask_abs = ray.mask_abs_lin_coll;
1602 mask_p = ray.mask_p_lin_coll;
1603 mask_m = ray.mask_m_lin_coll;
1604 else
1605 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin;
1606 mask_abs = ray.mask_abs_lin;
1607 mask_p = ray.mask_p_lin;
1608 mask_m = ray.mask_m_lin;
1609 end
1610 end
1611
1612 graph1D_jd(ray.ss,real(ray.sNperp),0,0,xlab,ylab,tit,NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1613 graph1D_jd(ray.ss(mask_abs),real(ray.sNperp(mask_abs)),0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font);
1614
1615 end
1616
1617
1618
1619 setfig(f_opt,ib,5,figlab)
1620
1621 ylab = 'S_{\perp}';
1622
1623 for iray = 1:nray,
1624
1625 ray = rays_disp{iray};
1626
1627 if opt.luke,
1628 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1629 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_coll_luke;
1630 mask_abs = ray.mask_abs_coll_luke;
1631 mask_p = ray.mask_p_coll_luke;
1632 mask_m = ray.mask_m_coll_luke;
1633 else
1634 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max;
1635 mask_abs = ray.mask_abs;
1636 mask_p = ray.mask_p;
1637 mask_m = ray.mask_m;
1638 end
1639 else
1640 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1641 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin_coll;
1642 mask_abs = ray.mask_abs_lin_coll;
1643 mask_p = ray.mask_p_lin_coll;
1644 mask_m = ray.mask_m_lin_coll;
1645 else
1646 mask_max = 1:rays{iy}.ns <= rays{iy}.is_abs_max_lin;
1647 mask_abs = ray.mask_abs_lin;
1648 mask_p = ray.mask_p_lin;
1649 mask_m = ray.mask_m_lin;
1650 end
1651 end
1652
1653
1654 sphi_abs = abs(ray.sphi_xyz(1,:));
1655
1656 graph1D_jd(ray.ss,sphi_abs,0,0,xlab,ylab,tit,NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1657 graph1D_jd(ray.ss(mask_abs),sphi_abs(mask_abs),0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font);
1658
1659 end
1660
1661
1662
1663 setfig(f_opt,ib,6,figlab);
1664
1665 xlim = [0,1];
1666 xlab = plab;
1667 if pow_opt == 0,
1668 ylab = 'dP/d\rho/P_0';
1669 else
1670 ylab = 'dP/d\rho (MW)';
1671 end
1672
1673 for iray = 1:nray,
1674
1675 ray = rays_disp{iray};
1676
1677 if pow_opt == 0,
1678 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1679 dP_drho_disp = ray.dP_coll_luke_normdrho.*drhog_dep./drho_dep;
1680 else
1681 dP_drho_disp = ray.dP_normdrho.*drhog_dep./drho_dep;
1682 end
1683
1684 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1685 dP_lin_drho_disp = ray.dP_lin_coll_normdrho.*drhog_dep./drho_dep;
1686 else
1687 dP_lin_drho_disp = ray.dP_lin_normdrho.*drhog_dep./drho_dep;
1688 end
1689 else
1690 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1691 dP_drho_disp = ray.dP_coll_luke_normdrho*ray.P0_2piRp*2*pi*Rp.*drhog_dep./drho_dep/1e6;
1692 else
1693 dP_drho_disp = ray.dP_normdrho*ray.P0_2piRp*2*pi*Rp.*drhog_dep./drho_dep/1e6;
1694 end
1695
1696 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1697 dP_lin_drho_disp = ray.dP_lin_coll_normdrho*ray.P0_2piRp*2*pi*Rp.*drhog_dep./drho_dep/1e6;
1698 else
1699 dP_lin_drho_disp = ray.dP_lin_normdrho*ray.P0_2piRp*2*pi*Rp.*drhog_dep./drho_dep/1e6;
1700 end
1701 end
1702
1703 if opt.luke,
1704 graph1D_jd(rho_dep,dP_drho_disp,0,0,xlab,ylab,tit,NaN,xlim,ylim,style,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1705 if c_opt == 1,
1706 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1707 leg = {'LUKE (RLA + NRCA)','C3PO (RLA + NRCA)'};
1708 else
1709 leg = {'LUKE (RLA)','C3PO (RLA)'};
1710 end
1711 end
1712 else
1713 if isfield(waves{1},'colldamp') && waves{1}.colldamp == 1,
1714 leg = {'C3PO (RLA + NRCA)'};
1715 else
1716 leg = {'C3PO (RLA)'};
1717 end
1718 end
1719 if opt.luke == 0 || c_opt == 1,
1720 graph1D_jd(rho_dep,dP_lin_drho_disp,0,0,xlab,ylab,tit,leg,xlim,ylim,style3,marker,colors{rem(iray,ncols+1)},width1,opt.font);
1721 end
1722
1723 end
1724
1725
1726
1727 if f_opt && ~isempty(ray.skrho),
1728
1729 setfig(f_opt,ib,7,figlab)
1730
1731 xlim = [0,max(ray.ss(mask_max))];
1732 ylim = [-40,40];
1733 xlab = 's (m)';
1734 ylab = '';
1735 tit = '';
1736 leg = {'n_{\rho}','d\rho/ds (\times 1000)'};
1737
1738 snrho = ray.skrho*clum/ray.omega_rf;
1739 sdrhods = 1000*gradient_jd(ray.ss,ray.srho);
1740
1741 if isfield(opt,'mode') && opt.mode == 'y',
1742 graph1D_jd(ray.ss(mask_p{1}),snrho(mask_p{1}),0,0,'','','',NaN,xlim,ylim,style,marker,color1,width2,opt.font);
1743 graph1D_jd(ray.ss(mask_p{1}),sdrhods(mask_p{1}),0,0,'','','',leg,xlim,ylim,style,marker,color2,width1,opt.font);
1744 for ip = 2:length(mask_p),
1745 graph1D_jd(ray.ss(mask_p{ip}),snrho(mask_p{ip}),0,0,'','','',NaN,xlim,ylim,style,marker,color1,width2,opt.font);
1746 graph1D_jd(ray.ss(mask_p{ip}),sdrhods(mask_p{ip}),0,0,'','','',leg,xlim,ylim,style,marker,color2,width1,opt.font);
1747 end
1748 for im = 1:length(mask_m),
1749 graph1D_jd(ray.ss(mask_m{im}),snrho(mask_m{im}),0,0,'','','',NaN,xlim,ylim,style3,marker,color1,width2,opt.font);
1750 graph1D_jd(ray.ss(mask_m{im}),sdrhods(mask_m{im}),0,0,'','','',NaN,xlim,ylim,style3,marker,color2,width1,opt.font);
1751 end
1752 else
1753 graph1D_jd(ray.ss,snrho,0,0,'','','',NaN,xlim,ylim,style,marker,color1,width2,opt.font);
1754 graph1D_jd(ray.ss,sdrhods,0,0,'','','',leg,xlim,ylim,style,marker,color2,width1,opt.font);
1755 end
1756
1757 graph1D_jd(ray.ss(mask_abs),snrho(mask_abs),0,0,'','','',NaN,xlim,ylim,style2,marker2,color5,width2,opt.font);
1758 graph1D_jd(ray.ss(mask_abs),sdrhods(mask_abs),0,0,xlab,ylab,tit,NaN,xlim,ylim,style2,marker2,color5,width2,opt.font,gca,red,lspace,bspace);
1759
1760 end
1761
1762 if ~f_opt && opt.print >= 0,
1763
1764 figure(2000 + ib - 1);
1765 cpaxlist = copyobj(get(1000 + ib - 1,'children'),2000 + ib - 1);
1766
1767 set(2000 + ib - 1,'position',[0,0,600,900]),
1768 set(cpaxlist(1),'units','normalized','position',[0.65,0.1,0.3,0.2])
1769 set(cpaxlist(2),'units','normalized','position',[0.15,0.1,0.3,0.2])
1770 set(cpaxlist(3),'units','normalized','position',[0.65,0.4,0.3,0.2])
1771 set(cpaxlist(4),'units','normalized','position',[0.35,0.525,0.1,0.1])
1772 set(cpaxlist(5),'units','normalized','position',[0.15,0.4,0.3,0.2])
1773 set(cpaxlist(6),'units','normalized','position',[0.65,0.7,0.3,0.2])
1774 set(cpaxlist(7),'units','normalized','position',[0.15,0.7,0.3,0.2])
1775
1776 print_jd(opt.print,[figname,'Wave_',num2str(iw),'_Ray_',num2str(ibb)],'figures_WAVE');
1777 end
1778
1779 if strcmp(waves{iw}.rayinit.type,'LH')
1780 LH_acces_yp(equil,ray,mask_max,iy);
1781 end
1782 end
1783
1784 end
1785
1786 function setfig(f_opt,ib,ifig,figlab)
1787
1788 if f_opt == 1,
1789
1790 fignum = 10*(ib - 1) + 9 + ifig;
1791 figure(fignum),clf,set(fignum,'name',[figlab,'; fig ',num2str(ifig)])
1792
1793 else
1794
1795 fignum = 1000 + ib - 1;
1796 figure(fignum)
1797 if ifig == 1,
1798 clf,
1799 set(gcf,'resize','on'),
1800 set(gcf,'units','normalized'),
1801
1802 set(gcf,'position',[0,0,1,1]),
1803 set(fignum,'name',figlab)
1804 end
1805
1806 subplot(2,3,ifig),
1807
1808 end
1809
1810 end
1811
1812 function dydx = gradient_jd(x,y)
1813
1814 dydx = zeros(size(y));
1815
1816 dydx(2:end-1) = ...
1817 (1./(x(3:end) - x(2:end-1)) - 1./(x(3:end) - x(1:end-2))).*y(3:end) + ...
1818 (1./(x(2:end-1) - x(1:end-2)) - 1./(x(3:end) - x(2:end-1))).*y(2:end-1) + ...
1819 (1./(x(3:end) - x(1:end-2)) - 1./(x(2:end-1) - x(1:end-2))).*y(1:end-2);
1820
1821 dydx(1) = (y(2) - y(1))/(x(2) - x(1));
1822 dydx(end) = (y(end) - y(end-1))/(x(end) - x(end-1));
1823 end
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005