0001
0002
0003
0004
0005
0006
0007
0008 clear all
0009 close all
0010 clc
0011
0012
0013
0014 remdebugmode = 0;
0015 remclean = 2;
0016 luke_memory = 12000;
0017 luke_walltime = 1;
0018 enforce = 0;
0019
0020 opt_struct = 0;
0021
0022 opt.save = 1;
0023 opt.localdatadir = 'results';
0024 opt.fields = {'Znorm','Zcurr','ZP0','zS','dke_out','radialDKE','equilDKE','equil','momentumDKE','gridDKE','Zmomcoef','Zbouncecoef','Zmripple','mksa','XXsinksource'};
0025 opt.proc = struct;
0026 opt.backup = 0;
0027 opt.waves = 0;
0028 opt.saveinputs = 0;
0029
0030 svnremoteupdate = 0;
0031
0032 rho_S = 51;
0033
0034 euitm.loadlocalfile = 1;
0035 euitm.savelocalfile = 1;
0036
0037
0038
0039 remoteprofile = 'EFDA_ITM';
0040 scheduler = 'direct';
0041 profilename = 'yvesp';
0042 duplicate = 'true';
0043
0044
0045
0046 ray_display = 0;
0047 display_mode = 0;
0048 ir_display = -1;
0049 p_opt = -1;
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 mds_ver = '4.10a';
0068
0069 machine = 'test';
0070 shot = 2;
0071 run= 601;
0072 run_out= 602;
0073 timeslice = NaN;
0074 iter = 1;
0075 occurrence_out = 0;
0076
0077 time_interp = 1;
0078
0079 CPOs = {'equilibrium','coreprof','antennas'};
0080
0081 occurrence_eq = 0;
0082 occurrence_cp = 0;
0083 occurrence_an = 0;
0084
0085
0086
0087 CPO_occurrences = [occurrence_eq,occurrence_cp,occurrence_an];
0088
0089 dataname = dataname_ITM(machine,shot,run,timeslice,time_interp);
0090 filename = [pwd,'/LUKE_RESULTS_',dataname,'.mat'];
0091
0092 if exist(filename,'file'),
0093 cleansim = input_dke_yp(['Do you to clean the existing simulation: ',dataname,' (y/n)'],'n',{'y','n'});
0094 disp(' ')
0095 if cleansim == 'y',
0096 delete(filename)
0097 end
0098 end
0099
0100 if ~exist(filename,'file'),
0101
0102 dkepath = setpath_luke_jd('');
0103
0104 if ~isempty(dkepath.remote),
0105 remopt = input_dke_yp(['Do you want to transfer the distributed calculation to a remote host (y/n)'],'n',{'y','n'});
0106 disp(' ')
0107 else
0108 remopt = 'n';
0109 end
0110
0111 if remopt == 'y',
0112 remnum = iselect_jd(dkepath.profilestr,'Please select the host for the distributed calculation ?',0,struct,1);
0113 disp(' ')
0114 dist_mode = NaN;
0115 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);
0116 disp(' ')
0117
0118 remtimout = input_dke_yp(['Timeout for remote calculations, in minutes. Use (0) to return later and check results by running this script again'],0,0:1000);
0119 disp(' ')
0120
0121 if remtimout > 0,
0122 rempause = input_dke_yp(['Pause between job checks (in minutes)'],1,1:10);
0123 else
0124 rempause = 1;
0125 end
0126
0127 else
0128 remnum = 0;
0129 remtimout = input_dke_yp(['Timeout for remote calculations, in minutes.'],100,10:1000);
0130 disp(' ')
0131
0132 rempause = input_dke_yp(['Pause between job checks (in minutes)'],1,1:10);
0133 disp(' ')
0134
0135 dist_mode = iselect_jd(dkepath.distprofiles,'Please select a mode for the distribution from the local host ?',0,struct,1);
0136 disp(' ')
0137 if dist_mode > 3,
0138 mdce_mode = 3 - dist_mode;
0139 else
0140 mdce_mode = dist_mode - 1;
0141 end
0142 end
0143
0144 remstart = 0;
0145
0146 opts.remnum = remnum;
0147 opts.remmdce = mdce_mode;
0148 opts.remtimout = remtimout;
0149 opts.rempause = rempause;
0150 opts.remstart = remstart;
0151 opts.remdebugmode = remdebugmode;
0152 opts.remclean = remclean;
0153 opts.luke_memory = luke_memory;
0154 opts.luke_walltime = luke_walltime;
0155 opts.enforce = enforce;
0156
0157 opts.opt_struct = opt_struct;
0158
0159 opts.opt.save = opt.save;
0160 opts.opt.localdatadir = opt.localdatadir;
0161 opts.opt.fields = opt.fields;
0162 opts.opt.proc = opt.proc;
0163 opts.opt.backup = opt.backup;
0164 opts.opt.waves = opt.waves;
0165 opts.opt.saveinputs = opt.saveinputs;
0166
0167 opts.svnremoteupdate = svnremoteupdate;
0168
0169 opts.rho_S = rho_S;
0170
0171 opts.euitm.loadlocalfile = euitm.loadlocalfile;
0172 opts.euitm.savelocalfile = euitm.savelocalfile;
0173
0174 opts.opt.ray_display = ray_display;
0175 opts.opt.display_mode = display_mode;
0176 opts.opt.ir_display = ir_display;
0177 opts.opt.p_opt = p_opt;
0178
0179 disp('*************************************')
0180 disp([' ---> remunm = ',int2str(remnum)])
0181 disp([' ---> mdce_mode = ',int2str(mdce_mode)])
0182 disp('*************************************')
0183
0184 else
0185 temp_luke_results = load(['LUKE_RESULTS_',dataname,'.mat']);
0186
0187 opts = temp_luke_results.opts;
0188 dkepath = temp_luke_results.dkepath;
0189
0190 if isfield(temp_luke_results,'data_proc')
0191 disp(['WARNING: the file LUKE_RESULTS_',dataname,'.mat must be deleted or renamed first to start a new simulation.']);
0192 clear('temp_luke_results');
0193 end
0194
0195 end
0196
0197 disp('---------------------------------------------')
0198 if opts.remnum > 0
0199 disp(['Computer used for calculations --> ',dkepath.profilestr{opts.remnum}]);
0200 else
0201 disp('Local computer used for calculations');
0202 end
0203 disp(['Distributed computing mode --> ',int2str(opts.remmdce)]);
0204 disp('---------------------------------------------')
0205
0206 cd([dkepath.luke_root,'Project_DKE/Modules/ITM'])
0207
0208 [s_host,w_host] = unix('hostname -f');
0209
0210
0211
0212 if ~length(strfind(w_host,'itm')),
0213 [remote,profilestr] = load_remoteprofiles_jd(remoteprofile,false,false,scheduler,profilename,duplicate);
0214 job = matstandardjob_jd('runmat');
0215 if exist('opts') && isfield(opts,'remdebugmode') && opts.remdebugmode,
0216 remote.debugmode = 1;
0217 end
0218 else
0219 remote = [];
0220 job = [];
0221 end
0222
0223 if isfield(opts,'svnremoteupdate') && opts.svnremoteupdate,
0224
0225 [err_svn,~,c_svn,s_svn,w_svn] = matremote_jd('itmsvnupdate',{},remote,job);
0226
0227 if ~isempty(err_svn),
0228 disp('WARNING: SVN update of the ITM tools for LUKE calculations failed')
0229 else
0230 disp(['Successful SVN update of the ITM tools for LUKE calculations: ',w_svn{1},w_svn{2}]),
0231 end
0232 end
0233
0234 if ~isfield(opts,'euitm') || ~isfield(opts.euitm,'savelocalfile') || opts.euitm.savelocalfile ~= 1,
0235
0236 if ~exist('machine_mds','var') || ~exist('username_mds','var') || ~exist('ver_mds','var'),
0237 [err_mds,~,machine_mds,username_mds,ver_mds] = matremote_jd('which_MDSdatabase',{},remote,job);
0238
0239 if ~isempty(err_mds),
0240 error(['ERROR: ITM database not recognized -> machine: ',machine_mds,', user: ',username_mds,', datastructure version: ',ver_mds]);
0241 else
0242 disp(['ITM database well recognized -> machine: ',machine_mds,', user: ',username_mds,', datastructure version: ',ver_mds]);
0243 end
0244 end
0245
0246 if ~strcmp(machine,machine_mds),disp('WARNING: inconsistent machine name between script and MDS+ database.');end
0247
0248 [err_database,~,flag_database] = matremote_jd('database_recreate_ITM',{'shot','run_out'},remote,job);
0249
0250 if ~isempty(err_database),
0251 disp('WARNING: output MDS database creation failed. Data saved locally')
0252 opts.euitm.savelocalfile = 1;
0253 else
0254 disp('Output MDS database creation successfuly created.')
0255 end
0256 end
0257
0258 [err_waves,waves] = itm_starwars(mds_ver,machine,shot,run,timeslice,time_interp,CPOs,CPO_occurrences,run_out,iter,occurrence_out,opts);
0259
0260 if isstruct(waves),
0261
0262 if ~exist('opts') || ~isfield(opts,'euitm') || ~isfield(opts.euitm,'savelocalfile') || opts.euitm.savelocalfile ~= 1,
0263 [err_waves,~,waves_euitm] = matremote_jd('check_write_waves_ITM',{length(remote),shot,run_out},remote,job);
0264 else
0265 waves_euitm = '';
0266 end
0267
0268 load(['LUKE_RESULTS_',dataname,'.mat'],'data_proc');
0269
0270 for it = 1:length(waves),
0271 figure;
0272 graph1D_jd(waves(it).coherentwave(1).grid_1d.psi,waves(it).coherentwave(1).profiles_1d.powd_tot,0,0,'','','',NaN,NaN,NaN,'-','none','r',2);hold on
0273
0274 if isstruct(waves_euitm),
0275 graph1D_jd(waves_euitm(it).coherentwave(1).grid_1d.psi,waves_euitm(it).coherentwave(1).profiles_1d.powd_tot,0,0,'','','',NaN,NaN,NaN,'-','none','b',2);hold on
0276 end
0277
0278 disp('--------------')
0279 disp(['Line-averaged electron density (it = ',int2str(it),') -> ',num2str(data_proc{it}.scalar.jne/1e20),' (10+20 m-3)']);
0280 disp(['Major radius (it = ',int2str(it),') -> ',num2str(data_proc{it}.scalar.Rp),' (m)']);
0281
0282 disp(['RF absorbed power (it = ',int2str(it),') -> ',num2str(data_proc{it}.scalar.p0_rf_2piRp*2*pi*data_proc{1}.scalar.Rp),' (MW)']);
0283 disp(['RF current (it = ',int2str(it),') -> ',num2str(data_proc{it}.scalar.I_tot),' (MA)']);
0284 disp(['RF current drive efficiency (it = ',int2str(it),') -> ',num2str(data_proc{it}.scalar.EtaRFRp),' (10+19 A.m.W-1)']);
0285
0286 end
0287
0288 if ~exist('opts') || ~isfield(opts,'euitm') || ~isfield(opts.euitm,'savelocalfile') || opts.euitm.savelocalfile == 0,
0289 if exist(['MDSDATA_euitm_',dataname,'.mat'],'file'),
0290 delete(['MDSDATA_euitm_',dataname,'.mat'],'file'),
0291 end
0292 end
0293
0294 else
0295 disp(err_waves);
0296 end