0001 function rundke_Zi_remote(remtimout,link_mode,opt_save,display_mode,plot_results)
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 if nargin < 5,
0030 plot_results = false;
0031 end
0032
0033 if nargin < 4,
0034 display_mode = 1;
0035 end
0036
0037 if nargin < 3,
0038 opt_save = 0;
0039 end
0040
0041 if nargin < 2 || (~isempty(link_mode) && (~isnumeric(link_mode) || ~isscalar(link_mode) || ~any(link_mode == [-1:2]))),
0042 link_mode = NaN;
0043 end
0044
0045 if nargin < 1,
0046 remtimout = 0;
0047 end
0048
0049 permission = test_permissions_yp;
0050
0051 if ~permission
0052 disp('Please move the script to a local folder where you have write permission before to run it')
0053 return;
0054 end
0055
0056 rempause = 1/60;
0057
0058 debugmode = 0;
0059 cleanmode = 2;
0060 luke_memory = 2000;
0061 luke_walltime = 1;
0062 enforce = 0;
0063
0064 opt.save = opt_save;
0065
0066 mdce_opt = 0;
0067
0068 p_opt = -1;
0069
0070 localdatadir = 'LUKE_RESULTS_files_Zi_remote/';
0071
0072
0073
0074 id_simul = 'LH_karney_Zi_remote';
0075 path_simul = '';
0076
0077 psin_S = [];
0078 rho_S = [0.5];
0079
0080 id_path = '';
0081 path_path = '';
0082
0083 id_equil = 'TScyl';
0084 path_equil = '';
0085
0086 id_dkeparam = 'UNIFORM10010020';
0087 path_dkeparam = '';
0088
0089 id_display = 'NO_DISPLAY';
0090 path_display = '';
0091
0092
0093
0094
0095
0096 [dkepath,equil,dkeparam,dkedisplay] = load_structures_yp('dkepath',id_path,path_path,'equil',id_equil,path_equil,'dkeparam',id_dkeparam,path_dkeparam,'dkedisplay',id_display,path_display);
0097
0098
0099
0100 wavestruct.omega_lh = [4]*2*pi*1e9;
0101
0102
0103
0104 wavestruct.opt_lh = 2;
0105
0106
0107
0108
0109 wavestruct.norm_ref = 1;
0110
0111 wavestruct.yvparmin_lh = [3];
0112 wavestruct.yvparmax_lh = [5];
0113
0114 wavestruct.yNparmin_lh = [NaN];
0115 wavestruct.yNparmax_lh = [NaN];
0116 wavestruct.yNpar_lh = [NaN];
0117 wavestruct.ydNpar_lh = [NaN];
0118
0119
0120 wavestruct.yD0_in_c_lh = [1];
0121
0122 wavestruct.yD0_in_lh_prof = [0];
0123 wavestruct.ypeak_lh = [NaN];
0124 wavestruct.ywidth_lh = [NaN];
0125
0126 wavestruct.ythetab_lh = [0]*pi/180;
0127
0128
0129
0130
0131 if exist('dmumpsmex');dkeparam.invproc = -2;end
0132
0133 dkeparam.boundary_mode_f = 0;
0134 dkeparam.norm_mode_f = 1;
0135 dkeparam.tn = [50000,100000];
0136 dkeparam.rt_mode = 1;
0137
0138 dkeparam.np_S = 201;
0139 dkeparam.nmhu_S = 201;
0140
0141 dkeparam.rho_S = rho_S;
0142 dkeparam.psin_S = psin_S;
0143
0144 dkeparam.clustermode.coll_dke_jd.scheduler.mode = mdce_opt;
0145 dkeparam.clustermode.eecoll_dke_yp.scheduler.mode = mdce_opt;
0146
0147 betath = 0.001;
0148
0149 [~,~,~,~,~,~,~,mc2] = pc_dke_yp;
0150
0151 equil.pTe = betath^2*mc2*ones(size(equil.pTe));
0152 equil.pzTi = betath^2*mc2*ones(size(equil.pzTi));
0153
0154
0155 opt.fields = {'Zcurr','ZP0'};
0156
0157 Zi_list = [1,100];
0158 coll_mode_list = 0:2;
0159
0160 nZi = length(Zi_list);
0161 ncoll = length(coll_mode_list);
0162
0163
0164
0165 filename = [path_simul,'LUKE_RESULTS_',id_equil,'_',id_simul,'.mat'];
0166
0167
0168
0169 if nargin == 0 && exist(filename,'file'),
0170
0171 load(filename,'lukestructs','remtimout','link_mode','plot_results','remnum','dist_mode','mdce_mode');
0172
0173 else
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183 if ~isempty(dkepath.remote),
0184 remopt = input_dke_yp(['Do you want to transfer the distributed calculation to a remote host (y/n)'],'n',{'y','n'});
0185 disp(' ')
0186 else
0187 remopt = 'n';
0188 end
0189
0190 if remopt == 'y',
0191 remnum = iselect_jd(dkepath.profilestr,'Please select the host for the distributed calculation ?',0,struct,1);
0192 disp(' ')
0193 dist_mode = NaN;
0194 mdce_mode = input_dke_yp(['Please select a mode for the distribution on host ',dkepath.profilestr{remnum},':\n(0) sequential \n(1) jobcomputing \n(2) parcomputing \n(3) remcomputing \n'],0,0:3);
0195 else
0196 remnum = 0;
0197 dist_mode = iselect_jd(dkepath.distprofiles,'Please select a mode for the distribution from the local host ?',0,struct,1);
0198 if dist_mode > 3,
0199 mdce_mode = 3 - dist_mode;
0200 else
0201 mdce_mode = dist_mode - 1;
0202 end
0203 end
0204
0205 dkepath.clustermode.run_lukert.scheduler.remnum = remnum;
0206 dkepath.clustermode.run_lukert.scheduler.mode = mdce_mode;
0207 dkepath.clustermode.run_lukert.scheduler.remtimout = remtimout;
0208 dkepath.clustermode.run_lukert.scheduler.rempause = rempause;
0209 dkepath.clustermode.run_lukert.scheduler.memory = luke_memory;
0210 dkepath.clustermode.run_lukert.scheduler.walltime = luke_walltime;
0211 dkepath.clustermode.run_lukert.scheduler.debugmode = debugmode;
0212 dkepath.clustermode.run_lukert.scheduler.display = display_mode;
0213 dkepath.clustermode.run_lukert.scheduler.cleanmode = cleanmode;
0214 dkepath.clustermode.run_lukert.scheduler.enforce = enforce;
0215 if opt.save,
0216 dkepath.clustermode.run_lukert.scheduler.localdatadir = localdatadir;
0217 if exist(localdatadir,'dir') && length(dir(localdatadir)) > 2,
0218 delete([localdatadir,'*']);
0219 end
0220 end
0221
0222
0223
0224 lukestructs = cell(ncoll,nZi);
0225
0226 for iZi = 1:nZi,
0227 for icoll = 1:ncoll,
0228
0229 Zi = Zi_list(iZi);
0230 equil.zZi = [1,1,1,Zi];
0231 equil.pzni = [0;0;0;1/Zi]*equil.pne;
0232
0233 waves{1} = make_idealLHwave_jd(equil,wavestruct);
0234
0235 dkeparam.coll_mode = coll_mode_list(icoll);
0236
0237
0238
0239 lukestructs{icoll,iZi}.simul.path = path_simul;
0240 lukestructs{icoll,iZi}.simul.locid = [id_simul,'_coll_',num2str(coll_mode_list(icoll)),'_Zi_',num2str(Zi)];
0241 lukestructs{icoll,iZi}.equil = equil;
0242 lukestructs{icoll,iZi}.dkeparam = dkeparam;
0243 lukestructs{icoll,iZi}.dkedisplay = dkedisplay;
0244 lukestructs{icoll,iZi}.waves = waves;
0245 lukestructs{icoll,iZi}.opt = opt;
0246
0247 end
0248 end
0249 end
0250
0251 lukestructs = run_lukert(lukestructs,dkepath);
0252
0253 j = NaN(ncoll,nZi);
0254 P = NaN(ncoll,nZi);
0255
0256 flag_running = true(ncoll,nZi);
0257 flag_error = true(ncoll,nZi);;
0258 luke_warning = cell(ncoll,nZi);
0259
0260 for iZi = 1:nZi,
0261 for icoll = 1:ncoll,
0262 if isfield(lukestructs{icoll,iZi},'output'),
0263
0264 j(icoll,iZi) = lukestructs{icoll,iZi}.output.Zcurr.x_0;
0265 P(icoll,iZi) = lukestructs{icoll,iZi}.output.ZP0.x_rf_fsav;
0266
0267 flag_running(icoll,iZi) = false;
0268 flag_error(icoll,iZi) = false;
0269
0270 if isfield(lukestructs{icoll,iZi},'warning')
0271 luke_warning{icoll,iZi} = [' **** WARNING : ',lukestructs{icoll,iZi}.warning];
0272 end
0273 elseif isfield(lukestructs{icoll,iZi},'err'),
0274 flag_running(icoll,iZi) = false;
0275 flag_error(icoll,iZi) = true;
0276 end
0277 end
0278 end
0279
0280 eta = j./P;
0281
0282 j_nr_k = NaN(ncoll,nZi);
0283 P_nr_k = NaN(ncoll,nZi);
0284 eta_nr_k = NaN(ncoll,nZi);
0285
0286 j_nr_k(1,1) = 0.05759;
0287 P_nr_k(1,1) = 0.004012;
0288 eta_nr_k(1,1) = 14.35;
0289
0290 j_nr_k(3,1) = 0.07092;
0291 P_nr_k(3,1) = 0.004294;
0292 eta_nr_k(3,1) = 16.52;
0293
0294 eta_0_nr_Karney = eta_nr_k(1,1)*6./(5 + Zi_list);
0295 eta_2_nr_Karney = eta_nr_k(3,1)*6./(5 + Zi_list);
0296
0297
0298
0299 if ~any(flag_running(:)) && plot_results,
0300
0301 figure(1),clf
0302
0303
0304 leg = {'Linearized','High v limit','Maxwellian'};
0305 xlim = [0,max(Zi_list)];
0306 ylim = [0,0.1];
0307 xlab = 'Z_i';
0308 ylab = 'j';
0309 tit = '';
0310 siz = 20+14i;
0311
0312 graph1D_jd(Zi_list,j(3,:),0,0,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0313 graph1D_jd(Zi_list,j(2,:),0,0,'','','',NaN,xlim,ylim,'-','none','b',2,siz,gca);
0314 graph1D_jd(Zi_list,j(1,:),0,0,'','','',leg,xlim,ylim,'-','none','g',2,siz,gca);
0315
0316
0317
0318 set(gca,'ytick',[0:0.2:1]*ylim(2))
0319 set(gca,'xtick',[0:0.2:1]*xlim(2))
0320
0321 figure(2),clf
0322
0323 ylim = [0,0.02];
0324 ylab = 'P';
0325
0326 graph1D_jd(Zi_list,P(3,:),0,0,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0327 graph1D_jd(Zi_list,P(2,:),0,0,'','','',NaN,xlim,ylim,'-','none','b',2,siz,gca);
0328 graph1D_jd(Zi_list,P(1,:),0,0,'','','',leg,xlim,ylim,'-','none','g',2,siz,gca);
0329
0330
0331
0332 set(gca,'ytick',[0:0.2:1]*ylim(2))
0333 set(gca,'xtick',[0:0.2:1]*xlim(2))
0334
0335 figure(3),clf
0336
0337 ylim = [0,20];
0338 ylab = 'j/P';
0339
0340 graph1D_jd(Zi_list,eta(3,:),0,0,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0341 graph1D_jd(Zi_list,eta(2,:),0,0,'','','',NaN,xlim,ylim,'-','none','b',2,siz,gca);
0342 graph1D_jd(Zi_list,eta(1,:),0,0,'','','',leg,xlim,ylim,'-','none','g',2,siz,gca);
0343 graph1D_jd(Zi_list,eta_2_nr_Karney,0,0,'','','',NaN,xlim,ylim,'--','none','b',0.5,siz,gca);
0344 graph1D_jd(Zi_list,eta_0_nr_Karney,0,0,'','','',NaN,xlim,ylim,'--','none','r',0.5,siz,gca);
0345
0346 set(gca,'ytick',[0:0.2:1]*ylim(2))
0347 set(gca,'xtick',[0:0.2:1]*xlim(2))
0348
0349 print_jd(p_opt,'fig_j_Zi','./figures',1)
0350 print_jd(p_opt,'fig_P_Zi','./figures',2)
0351 print_jd(p_opt,'fig_eta_Zi','./figures',3)
0352
0353 end
0354
0355
0356
0357 format
0358
0359 if ~isempty(link_mode) && ~isnan(link_mode) && link_mode >= 0,
0360 link_modestr = ['_link_mode_',num2str(link_mode)];
0361 elseif ~isempty(link_mode) && link_mode == -1,
0362 link_modestr = '_noremote';
0363 else
0364 link_modestr = '';
0365 end
0366
0367 diaryname = ['res_karney_Zi_remote_',datestr(now,29),'_remnum_',num2str(remnum),'_mdce_',num2str(mdce_mode),link_modestr,'.log'];
0368
0369 if input_dke_yp(['Do you want to save the results in the log file ',diaryname,' ? (y/n)'],'y',{'y','n'}) == 'y',
0370
0371 if exist(diaryname,'file'),
0372 delete(diaryname);
0373 end
0374
0375 diary(diaryname);
0376
0377 else
0378 diaryname = '';
0379 end
0380
0381 disp(' ')
0382 if remnum == 0,
0383 disp(['Calculation distributed locally with the MDCE profile : ',dkepath.distprofiles{dist_mode}]);
0384 else
0385 disp(['Calculation distributed on remote host : ',dkepath.profilestr{remnum},' with MDCE mode ',num2str(mdce_mode)]);
0386 end
0387 disp(' ')
0388
0389
0390 disp('----------------------')
0391 disp(['Comparison LUKE/Karney - Non relativistic case (3,5,1) - with tn = ',int2str(dkeparam.tn),', dtn = ',int2str(dkeparam.dtn),' and nit_f = ',int2str(dkeparam.nit_f)])
0392 disp('----------------------')
0393
0394 for iZi = [1,nZi],
0395 for icoll = 1:ncoll,
0396 casestr = ['Zi = ',num2str(Zi_list(iZi)),' ; coll mode = ',num2str(coll_mode_list(icoll))];
0397 if flag_running(icoll,iZi),
0398 disp([casestr,' : running'])
0399 elseif ~isnan(j(icoll,iZi)),
0400 disp([casestr,' : j = ',num2str(j(icoll,iZi)),'/',num2str(j_nr_k(icoll,iZi)),' ; P = ',num2str(P(icoll,iZi)),'/',num2str(P_nr_k(icoll,iZi)),' ; j/P = ',num2str(eta(icoll,iZi)),'/',num2str(eta_nr_k(icoll,iZi)),luke_warning{icoll,iZi}])
0401 else
0402 disp([casestr,' : failed'])
0403 end
0404 end
0405 end
0406
0407 if ~isempty(diaryname),
0408 diary off
0409 end
0410
0411
0412
0413 if remtimout == 0,
0414 if ~any(flag_running(:)) && ~any(flag_error(:)),
0415 if exist(filename)
0416 delete(filename);
0417 end
0418 else
0419 if any(flag_error(:)),
0420 save(filename);
0421 info_dke_yp(2,['Data saved in ',filename]);
0422 end
0423 end
0424 end