0001 function rundke_metis_LH(basestr,shotnum,shotimes,locpath_simul,locid_simul,configs,opt,dkepath,dkeparam,dkedisplay,equil,ohm,transpfaste_in,ripple,rayparam,waveparam,C3POparam,scheduler_run_lukert)
0002
0003 if nargin < 18,
0004 scheduler_run_lukert = struct;
0005 end
0006 if nargin < 17,
0007 C3POparam = struct;
0008 end
0009 if nargin < 16,
0010 waveparam = struct;
0011 end
0012 if nargin < 15,
0013 rayparam = struct;
0014 end
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
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 if ~iscell(locpath_simul),
0063 path_simul = [basestr,filesep,shotnum,filesep,locpath_simul];
0064 else
0065 path_simul = [locpath_simul{1},basestr,filesep,shotnum,filesep,locpath_simul{2}];
0066 end
0067
0068 shotimes = select_shotimes_jd(['before_luke@',basestr,'_',shotnum,'_'],'.mat',path_simul,shotimes);
0069 nshots = length(shotimes);
0070
0071 dkepath = conc_struct_jd(load_structures_yp('dkepath','',''),dkepath);
0072
0073
0074
0075 if transpfaste_in.Dr0 > 0,
0076
0077
0078
0079 transpfaste.Dr0 = 0;
0080 transpfaste.pDr = 0;
0081 transpfaste.Dr_model = 0;
0082 transpfaste.Vr0 = 0;
0083 transpfaste.pVr = 0;
0084 transpfaste.Vr_model = 0;
0085 transpfaste.vparmin = 3.5;
0086 transpfaste.norm_ref = 1;
0087
0088 transpfaste = conc_struct_jd(transpfaste,transpfaste_in);
0089
0090 transpfaste.id = ['TR_',num2str(transpfaste.Dr_model),'_Dr0_',num2str(transpfaste.Dr0),'_pDr_',num2str(transpfaste.pDr)];
0091 else
0092 transpfaste = struct;
0093 end
0094
0095
0096
0097 wavestructs = {};
0098 nconf = length(configs);
0099
0100 for ic = 1:nconf,
0101
0102 config = configs(ic);
0103
0104 if isfield(config,'include') & config.include == 0,
0105 continue
0106 end
0107
0108
0109
0110 if ~isfield(config,'rZ0'),
0111 if isnan(config.nrZ0),
0112 opt_ny = 1;
0113 if real(config.opt_aloha) >= 1,
0114 config.nrZ0 = 2;
0115 else
0116 config.nrZ0 = 1;
0117 end
0118 else
0119 opt_ny = 0;
0120 end
0121
0122 n2 = fix(config.nrZ0/2);
0123 if config.type == 1,
0124 rZ0min = 0.035;
0125 rZ0max = 0.195;
0126 elseif config.type == 2,
0127 rZ0min = 0.039;
0128 rZ0max = 0.285;
0129 else
0130 error('Antenna configuration not recognized')
0131 end
0132
0133 if n2 >= 1,
0134 rZ0 = linspace(rZ0min,rZ0max,n2+1);
0135 rZ0 = (rZ0(1:end-1) + rZ0(2:end))/2;
0136 else
0137 rZ0 = [];
0138 end
0139
0140 if rem(config.nrZ0,2) == 0,
0141 rZ0 = [-fliplr(rZ0),rZ0];
0142 else
0143 rZ0 = [-fliplr(rZ0),0,rZ0];
0144 end
0145 else
0146 rZ0 = config.rZ0;
0147 end
0148
0149 locwavestructs = {};
0150
0151 for ishot = 1:nshots,
0152
0153 launch = struct;
0154
0155 if isfield(config,'tail') && ~isempty(fieldnames(config.tail)),
0156 launch.tail = config.tail;
0157 end
0158
0159 if real(config.opt_aloha) == 0,
0160
0161 if isfield(config,'bNpar0') && ~any(isnan(config.bNpar0)),
0162 launch.bNpar0 = config.bNpar0;
0163 end
0164 if isfield(config,'bdNpar0') && ~any(isnan(config.bdNpar0)),
0165 launch.bdNpar0 = config.bdNpar0;
0166 end
0167 if isfield(config,'bPlhtot') && ~any(isnan(config.bPlhtot)),
0168 launch.bPlhtot = config.bPlhtot;
0169 end
0170 launch.rZ0 = rZ0;
0171
0172 launch.id = make_launchid_jd(config);
0173
0174 locwavestructs{1}(ishot).launch = launch;
0175 locwavestructs{1}(ishot).id = ['C3PO_',launch.id];
0176
0177 elseif real(config.opt_aloha) >= 1,
0178
0179 if isfield(config,'locid_aloha'),
0180
0181 if imag(config.opt_aloha) == 0,
0182 aloha_str = ['ALOHA_',basestr,'_',shotnum,'_',shotimes{ishot},config.locid_aloha,'.mat'];
0183 else
0184 aloha_str = ['ALOHA_',basestr,'_',shotnum,config.locid_aloha,'.mat'];
0185 end
0186
0187 aloha = load([path_simul,config.path_aloha,filesep,aloha_str]);
0188
0189
0190
0191 if isfield(config,'aloha'),
0192 [bNtor0,bdNtor0,bPlhtor,param_out] = proc_aloha_spec_jd(aloha.antenna.nz,NaN,real(aloha.antenna.dP_nz),1,config.aloha(1),0,config.aloha(1));
0193 else
0194 if isfield(config,'aloha_dir'),
0195 Pin = 1 + config.aloha_dir*1i;
0196 else
0197 Pin = 1;
0198 end
0199
0200 [bNtor0,bdNtor0,bPlhtor,param_out] = proc_aloha_spec_jd(aloha.antenna.nz,NaN,real(aloha.antenna.dP_nz),Pin,config.aloha_param(1),0,0);
0201 end
0202
0203 config.aloha = conc_struct_jd(config.aloha,param_out);
0204
0205
0206
0207 launch.id = make_launchid_jd(config);
0208
0209 if opt_ny == 1,
0210 if isfield(config,'aloha'),
0211 [bNpol0,bdNpol0,bPlhpol] = proc_aloha_spec_jd(aloha.antenna.ny,NaN,sum(real(aloha.antenna.dP.')),1,config.aloha(2),0,config.aloha(2));
0212 else
0213 [bNpol0,bdNpol0,bPlhpol] = proc_aloha_spec_jd(aloha.antenna.ny,NaN,sum(real(aloha.antenna.dP.')),1,config.aloha_param(2),0,0);
0214 end
0215 else
0216 bNpol0 = 0;
0217
0218 bdNpol0 = 0;
0219
0220 bPlhpol = 1;
0221 end
0222
0223
0224
0225 launch.bNpar0 = [];
0226
0227 launch.bdNpar0 = [];
0228
0229 launch.bPlhtot = [];
0230
0231 for iy = 1:length(bNtor0),
0232 launch.bNpar0 = [launch.bNpar0,1i*bNtor0(iy) + bNpol0];
0233
0234
0235
0236
0237
0238
0239
0240 launch.bdNpar0 = [launch.bdNpar0,bdNtor0(iy)*ones(1,length(bdNpol0))];
0241
0242 launch.bPlhtot = [launch.bPlhtot,bPlhtor(iy)*bPlhpol];
0243 end
0244
0245
0246
0247 metisdata = load([path_simul,filesep,'before_luke@',basestr,'_',shotnum,'_',shotimes{ishot},'.mat']);
0248
0249
0250 launch.bNpar0 = launch.bNpar0*(-sign(metisdata.equil.psi_apRp(end)));
0251 launch.aloha = aloha;
0252
0253 if nconf == 1 && real(config.opt_aloha) == 1,
0254
0255 plh = metisdata.cons.plh;
0256
0257 launch.bPlhtot = launch.bPlhtot*plh;
0258
0259 else
0260
0261 filename = [path_simul,'GPHYB_',shotnum,'.mat'];
0262
0263 if exist(filename,'file'),
0264
0265 load(filename,'tplh','tbase')
0266
0267 else
0268
0269 [tplh,tbase] = tsbase(str2double(shotnum),'GPHYB');
0270
0271 end
0272
0273 xplh = 1e6*interp1(tbase(:,1),tplh,str2double(shotimes{ishot}));
0274 if any(xplh < 0) || (real(config.opt_aloha) == 2 && abs(xplh(end) - metisdata.cons.plh)/metisdata.cons.plh > 0.01),
0275 disp('warning : total power from database is different from metis cons')
0276 keyboard
0277 end
0278
0279 plh = xplh(ic);
0280
0281 launch.bPlhtot = launch.bPlhtot*plh;
0282
0283 end
0284
0285 locwavestructs{1}(ishot).launch = launch;
0286
0287 locwavestructs{1}(ishot).id = ['C3PO_',launch.id];
0288
0289 locwavestructs{1}(ishot).launch.rZ0 = rZ0;
0290
0291 elseif isfield(config,'locid_aloha_b') && isfield(config,'locid_aloha_h'),
0292
0293 if imag(config.opt_aloha) == 0,
0294 aloha_str_b = ['ALOHA_',basestr,'_',shotnum,'_',shotimes{ishot},config.locid_aloha_b,'.mat'];
0295 aloha_str_h = ['ALOHA_',basestr,'_',shotnum,'_',shotimes{ishot},config.locid_aloha_h,'.mat'];
0296 else
0297 aloha_str_b = ['ALOHA_',basestr,'_',shotnum,config.locid_aloha_b,'.mat'];
0298 aloha_str_h = ['ALOHA_',basestr,'_',shotnum,config.locid_aloha_h,'.mat'];
0299 end
0300
0301 aloha_b = load([path_simul,config.path_aloha,filesep,aloha_str_b]);
0302 aloha_h = load([path_simul,config.path_aloha,filesep,aloha_str_h]);
0303
0304
0305
0306 launch_b = launch;
0307 launch_h = launch;
0308
0309
0310
0311 if isfield(config,'aloha'),
0312 [bNtor0_b,bdNtor0_b,bPlhtor_b,param_out_b] = proc_aloha_spec_jd(aloha_b.antenna.nz,NaN,real(aloha_b.antenna.dP_nz),1,config.aloha(1),0,config.aloha(1));
0313 [bNtor0_h,bdNtor0_h,bPlhtor_h,param_out_h] = proc_aloha_spec_jd(aloha_h.antenna.nz,NaN,real(aloha_h.antenna.dP_nz),1,config.aloha(1),0,config.aloha(1));
0314 else
0315 if isfield(config,'aloha_dir'),
0316 Pin = 1 + config.aloha_dir*1i;
0317 else
0318 Pin = 1;
0319 end
0320
0321 [bNtor0_b,bdNtor0_b,bPlhtor_b,param_out_b] = proc_aloha_spec_jd(aloha_b.antenna.nz,NaN,real(aloha_b.antenna.dP_nz),Pin,config.aloha_param(1),0,0);
0322 [bNtor0_h,bdNtor0_h,bPlhtor_h,param_out_h] = proc_aloha_spec_jd(aloha_h.antenna.nz,NaN,real(aloha_h.antenna.dP_nz),Pin,config.aloha_param(1),0,0);
0323 end
0324
0325 config_b = rmfield(config,{'locid_aloha_b','locid_aloha_h'});
0326 config_h = rmfield(config,{'locid_aloha_b','locid_aloha_h'});
0327
0328 config_b.locid_aloha = config.locid_aloha_b;
0329 config_h.locid_aloha = config.locid_aloha_h;
0330
0331 config_b.aloha = conc_struct_jd(config.aloha,param_out_b);
0332 config_h.aloha = conc_struct_jd(config.aloha,param_out_h);
0333
0334
0335
0336 launch_b.id = make_launchid_jd(config_b);
0337 launch_h.id = make_launchid_jd(config_h);
0338
0339 if opt_ny == 1,
0340 if isfield(config,'aloha'),
0341 [bNpol0_b,bdNpol0_b,bPlhpol_b] = proc_aloha_spec_jd(aloha_b.antenna.ny,NaN,sum(real(aloha_b.antenna.dP.')),1,config.aloha(2),0,config.aloha(2));
0342 [bNpol0_h,bdNpol0_h,bPlhpol_h] = proc_aloha_spec_jd(aloha_h.antenna.ny,NaN,sum(real(aloha_h.antenna.dP.')),1,config.aloha(2),0,config.aloha(2));
0343 else
0344 [bNpol0_b,bdNpol0_b,bPlhpol_b] = proc_aloha_spec_jd(aloha_b.antenna.ny,NaN,sum(real(aloha_b.antenna.dP.')),1,config.aloha_param(2),0,0);
0345 [bNpol0_h,bdNpol0_h,bPlhpol_h] = proc_aloha_spec_jd(aloha_h.antenna.ny,NaN,sum(real(aloha_h.antenna.dP.')),1,config.aloha_param(2),0,0);
0346 end
0347 else
0348 bNpol0_b = 0;
0349 bNpol0_h = 0;
0350
0351 bdNpol0_b = 0;
0352 bdNpol0_h = 0;
0353
0354 bPlhpol_b = 1;
0355 bPlhpol_h = 1;
0356 end
0357
0358
0359
0360 launch_b.bNpar0 = [];
0361 launch_h.bNpar0 = [];
0362
0363 launch_b.bdNpar0 = [];
0364 launch_h.bdNpar0 = [];
0365
0366 launch_b.bPlhtot = [];
0367 launch_h.bPlhtot = [];
0368
0369 for iy = 1:length(bNtor0_b),
0370 launch_b.bNpar0 = [launch_b.bNpar0,1i*bNtor0_b(iy) + bNpol0_b];
0371 launch_h.bNpar0 = [launch_h.bNpar0,1i*bNtor0_h(iy) + bNpol0_h];
0372
0373
0374
0375
0376
0377
0378
0379
0380 launch_b.bdNpar0 = [launch_b.bdNpar0,bdNtor0_b(iy)*ones(1,length(bdNpol0_b))];
0381 launch_h.bdNpar0 = [launch_h.bdNpar0,bdNtor0_h(iy)*ones(1,length(bdNpol0_h))];
0382
0383 launch_b.bPlhtot = [launch_b.bPlhtot,bPlhtor_b(iy)*bPlhpol_b];
0384 launch_h.bPlhtot = [launch_h.bPlhtot,bPlhtor_h(iy)*bPlhpol_h];
0385 end
0386
0387
0388
0389 metisdata = load([path_simul,filesep,'before_luke@',basestr,'_',shotnum,'_',shotimes{ishot},'.mat']);
0390
0391
0392 launch_b.bNpar0 = launch_b.bNpar0*(-sign(metisdata.equil.psi_apRp(end)));
0393 launch_b.aloha = aloha_b;
0394
0395
0396 launch_h.bNpar0 = launch_h.bNpar0*(-sign(metisdata.equil.psi_apRp(end)));
0397 launch_h.aloha = aloha_h;
0398
0399 if nconf == 1 && real(config.opt_aloha) == 1,
0400
0401 plh = metisdata.cons.plh/2;
0402
0403 launch_b.bPlhtot = launch_b.bPlhtot*plh;
0404 launch_h.bPlhtot = launch_h.bPlhtot*plh;
0405
0406 else
0407
0408 filename = [path_simul,'GPHYB_',shotnum,'.mat'];
0409
0410 if exist(filename,'file'),
0411
0412 load(filename,'tplh','tbase')
0413
0414 else
0415
0416 [tplh,tbase] = tsbase(str2double(shotnum),'GPHYB');
0417
0418 end
0419
0420 xplh = 1e6*interp1(tbase(:,1),tplh,str2double(shotimes{ishot}));
0421 if real(config.opt_aloha) == 2 && abs(xplh(end) - metisdata.cons.plh)/metisdata.cons.plh > 0.01,
0422 disp('warning : total power from database is different from metis cons')
0423 keyboard
0424 end
0425
0426 plh = xplh(ic)/2;
0427
0428 launch_b.bPlhtot = launch_b.bPlhtot*plh;
0429 launch_h.bPlhtot = launch_h.bPlhtot*plh;
0430
0431 end
0432
0433 locwavestructs{1}(ishot).launch = launch_b;
0434 locwavestructs{2}(ishot).launch = launch_h;
0435
0436 locwavestructs{1}(ishot).id = ['C3PO_',launch_b.id];
0437 locwavestructs{2}(ishot).id = ['C3PO_',launch_h.id];
0438
0439 locwavestructs{1}(ishot).launch.rZ0 = rZ0(rZ0 <= 0);
0440 locwavestructs{2}(ishot).launch.rZ0 = rZ0(rZ0 >= 0);
0441
0442 else
0443
0444 error('aloha module division not consistent')
0445
0446 end
0447 end
0448
0449 end
0450
0451 wavestructs = [wavestructs,locwavestructs];
0452
0453 end
0454
0455 fnames = fieldnames(waveparam);
0456 nfields = length(fnames);
0457 for ifield = 1:nfields,
0458 locid_simul = [locid_simul,'_',fnames{ifield},'_',num2str(waveparam.(fnames{ifield}))];
0459 end
0460
0461 for iw = 1:length(wavestructs),
0462 for ishot = 1:nshots,
0463 wavestructs{iw}(ishot).rayparam = rayparam;
0464 wavestructs{iw}(ishot).waveparam = waveparam;
0465 wavestructs{iw}(ishot).C3POparam = C3POparam;
0466 end
0467 end
0468
0469
0470
0471
0472
0473
0474
0475
0476 rundke_metis(path_simul,locid_simul,basestr,shotnum,shotimes,opt,dkepath,wavestructs,equil,dkeparam,dkedisplay,ohm,transpfaste,ripple,0,scheduler_run_lukert)
0477
0478 end
0479
0480 function id_launch = make_launchid_jd(config)
0481
0482
0483
0484 id_launch = 'LH';
0485
0486 if isfield(config,'id') && ~isempty(config.id),
0487 id_launch = [id_launch,'_',config.id];
0488 return
0489 end
0490
0491
0492
0493
0494
0495 if isfield(config,'locid'),
0496 id_launch = [id_launch,'_',config.locid];
0497 elseif real(config.opt_aloha) >= 1,
0498
0499 id_launch = [id_launch,'_nr_',num2str(config.nrZ0),'_nl_',num2str(config.aloha.nlobes),'_dir_',num2str(config.aloha.dir),'_md_',num2str(config.aloha.mode),...
0500 config.locid_aloha];
0501
0502 elseif ~isnan(config.bNpar0),
0503 bNpar0str = '';
0504 bdNpar0str = '';
0505 bPlhtotstr = '';
0506 for ib = 1:length(config.bNpar0),
0507 bNpar0str = [bNpar0str,'_',num2str(config.bNpar0(ib))];
0508 bdNpar0str = [bdNpar0str,'_',num2str(config.bdNpar0(ib))];
0509 bPlhtotstr = [bPlhtotstr,'_',num2str(config.bPlhtot(ib)/1e6)];
0510 end
0511
0512 id_launch = [id_launch,'_N0',bNpar0str,'_dN0',bdNpar0str,'_P',bPlhtotstr];
0513 end
0514
0515
0516
0517 if isfield(config,'tail'),
0518 locid_simul_tail = make_tail_simulid_jd(config.tail);
0519 if ~isempty(locid_simul_tail),
0520 id_launch = [id_launch,'_',locid_simul_tail];
0521 end
0522 end
0523
0524 end
0525
0526