run_cronos_C3PO_npar0_lh

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 clear all
0002 clear mex
0003 clear functions
0004 close all
0005 warning off
0006 pause(1)
0007 dbstop if error
0008 %
0009 % Script for TORE-SUPRA LH discharge #32299 only
0010 %
0011 root_dir = '';%empty or pwd if local or  /local/peysson/Simulations/Yves/DKE/FLUCT/ when calculations are done on cephee cluster (local or remote)
0012 %
0013 % Perturbation of the launched npar for the LH wave only (simulate possible diffraction of the LH wave in the SOL by edge density fluctuations)
0014 %
0015 scenario = 'Npar0_fluct';
0016 %
0017 load ('before_luke@TS_32299_100.0117.mat','equil');%data file from cronos
0018 %
0019 % WARNING: time definitions in LUKE with or without fluctuations
0020 %
0021 %if imag(tn) > 0 : dkeparam.tn = tn/Nfluct -> as an imaginary number, dkeparam.tn prescribes the number of fluctuation iterations
0022 %if imag(tn) == 0 : dkeparam.tn = tn -> as a real number, dkeparam.tn specifies the final time explicitly
0023 %if imag(dtn) > 0: dkeparam.dtn = dtn*Nfluct -> as an imaginary number, dkeparam.dtn prescribes the number of internal time steps
0024 %if imag(dtn) == 0: dkeparam.dtn = dtn -> as a real number, dkeparam.dtn prescribes the number of internal time steps
0025 %
0026 opts.remtimout = 0;% timeout for remote calculations, in minutes. Use (0) to return later and check results by running this script again
0027 opts.rempause = 1/60;%pause between job checks (in minutes) (only for remtimout > 0)
0028 opts.remstart = 0;% (1) start new simulation; (0) check older simulation (only for remtimout = 0)
0029 opts.remnum = 2;% remote profile number. Use 0 for local sequential calculations
0030 opts.remdebug = 0;% remote debugmode
0031 opts.dist = 0;% batch run index in dkepath.remote; (0) for local run, (1) local multicore, (2) remote cephee, (3) remote saturne
0032 opts.save = 0;% save individual results in LUKE_RESULTS files (WARNING : Use absolute simul.path to save locally with local cluster)
0033 opts.backup = 1;%In case of crash, to restart simulation from an intermediate step stored in a *.mat file (<0 for launching simulation from backup, 0 no backup, >0 for performing backup)
0034 %
0035 tn = 100i;%Total normalized integration time. As an imaginary number, dkeparam.tn prescribes the number of fluctuation iterations
0036 display_mode = [0,1,1];%option for display [C3PO, LUKE, time evolution]
0037 p_opt = 2;%option for printing
0038 %
0039 %%%%%%%%%%% WARNING: Nothing below must be modified in case of reload %%%%%%%%%%% %%%%%%%%%%%%%%%
0040 %
0041 Nfluct = [0.381141619674545];%ratio of LUKE internal evolution time to fluctuation time !! set to retrieve old dtn = 2
0042 dtn = 1i;% LUKE internal time step. As an imaginary number, dkeparam.dtn prescribes the number of internal time steps
0043 %
0044 tn_fluct_correlation_npar0_lh = 1.0;%dtn_fluct_npar0_lh = 2.14*tn_fluct_correlation_npar0_lh (if dtn_fluct_npar0_lh is Inf, no fluctuations)
0045 %
0046 gaussian_tail = NaN;%Gaussian distribution for npar0 around npar_antenna given in the launch structure. If gaussian_npar0 is NaN or empty, no fluctuations of this type
0047 fwhm_npar0_in = 0.4;%If fwhm_npar0 is NaN or empty, the width is dnpar_antenna.
0048 %
0049 linear_tail = NaN;%Linear distribution for npar0 from npar_antenna given in the launch structure to Nparmax_tail. If linear_tail is NaN or empty, no fluctuations of this type
0050 calc_tail = 1;%Calculated distribution for npar0 from npar_antenna given in the launch structure to Nparmax_tail. If calc_tail is NaN or empty, no fluctuations of this type
0051 Nparmax_tail_in = NaN;%npar0 extend from npar_antenna to Nparmax_tail. If Nparmax_tail is NaN or empty, it is calculated by the code in main_rayinit_launch_jd.m -> 6.5/sqrt(Te0)
0052 n_tail_in = 5;%number of lobes to describe the tail. If n_tail = 0, no tail up to Nparmax_tail (no used if linear_tail is chosen)
0053 opt_tail_in = NaN;%Final power fraction of the tail @ Nparmax_tail.
0054 P_tail_in = 0.5;%Power fraction in the tail. If NaN, it is calculated from n_tail and opt_tail (no used if linear_tail is chosen)
0055 %
0056 racc = 0.05;%relative accuracy for time averaged power and current calculation
0057 %
0058 % LH wave: positive lobe (co-current)
0059 %
0060 Npar_p = [];%if empty, use the launch power spectrum calculated by CRONOS (negative value)
0061 dNpar_p = [];%if empty, use the launch power spectrum calculated by CRONOS (negative value)
0062 %
0063 % LH wave: negative lobe (counter-current)
0064 %
0065 Npar_m = [];%if empty, use the launch power spectrum calculated by CRONOS (positive value)
0066 dNpar_m = [];%if empty, use the launch power spectrum calculated by CRONOS (positive value)
0067 %
0068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SCAN LOOP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0069 %
0070 ijob = 1;
0071 %
0072 for fwhm_npar0 = fwhm_npar0_in,%scan random width (Gaussian model)
0073     for opt_tail = opt_tail_in,%scan random width (linear or calculated tail model)
0074         for Nparmax_tail = Nparmax_tail_in,%scan upper limit in Npar of the tail (linear or calculated tail model)
0075             for n_tail = n_tail_in,%scan number of lobes in the tail (linear or calculated tail model)
0076                 for P_tail = P_tail_in,%scan power fraction in the tail (linear or calculated tail model)
0077                     %
0078                     if (~isempty(fwhm_npar0) && ~isnan(fwhm_npar0)),
0079                         fluct_ref =  ['fwhm_npar0_lh_',num2str(fwhm_npar0)];
0080                     elseif (~isempty(h_npar0) && ~isnan(h_npar0)),
0081                         if (~isempty(nparmax_npar0) && ~isnan(nparmax_npar0)),
0082                             fluct_ref =  ['h_npar0_lh_',num2str(h_npar0),'_nparmax_npar0_lh_',num2str(h_npar0)];
0083                         else
0084                             fluct_ref =  ['h_npar0_lh_',num2str(h_npar0),'_nparmax_npar0_lh_Landau_Te0'];
0085                         end
0086                     end 
0087                     %
0088                     if isempty(Npar_p),
0089                         shot_ref = ['dtn',num2str(dtn),'_',fluct_ref];
0090                     else
0091                         shot_ref = ['Npar_p',num2str(abs(Npar_p)),'_dtn',num2str(dtn),'_',fluct_ref];
0092                     end
0093                     %
0094                     id_simul = [scenario,'_',shot_ref];
0095                     %
0096                     % Perturbation of the launched npar for the LH wave only (simulate possible diffraction of the LH wave in the SOL by edge density fluctuations)
0097                     %
0098                     fluctuations.npar0_lh.fluct.dtn = 2.14*tn_fluct_correlation_npar0_lh;%Gaussian time correlation model, dtn_fluct_npar0_lh = 2.14*tn_fluct_correlation_npar0_lh (if dtn_fluct_npar0_lh is Inf, no fluctuations)
0099                     %
0100                     fluctuations.npar0_lh.fluct.gaussian_tail = gaussian_tail;%Gaussian distribution for npar0 around npar_antenna given in the launch structure. If gaussian_npar0 is NaN or empty, no fluctuations of this type
0101                     fluctuations.npar0_lh.fluct.fwhm_npar0 = fwhm_npar0;%Gaussian distribution for npar0 around npar_antenna given in the launch structure. If fwhm_npar0 is NaN or empty, the width is dnpar_antenna.
0102                     %
0103                     fluctuations.npar0_lh.fluct.linear_tail = linear_tail;%Linear distribution for npar0 from npar_antenna given in the launch structure to Nparmax_tail. If linear_tail is NaN or empty, no fluctuations of this type
0104                     fluctuations.npar0_lh.fluct.calc_tail = calc_tail;%Calculated distribution for npar0 from npar_antenna given in the launch structure to Nparmax_tail. If calc_tail is NaN or empty, no fluctuations of this type
0105                     fluctuations.npar0_lh.fluct.P_tail = P_tail;%Power fraction in the tail. If NaN, it is calculated from n_tail and opt_tail (no used if linear_tail is chosen)
0106                     fluctuations.npar0_lh.fluct.Nparmax_tail = Nparmax_tail;%npar0 extend from npar_antenna to Nparmax_tail. If Nparmax_tail is NaN or empty, it is calculated by the code in main_rayinit_launch_jd.m -> 6.5/sqrt(Te0)
0107                     fluctuations.npar0_lh.fluct.n_tail = n_tail;%number of lobes to describe the tail. If n_tail = 0, no tail up to Nparmax_tail (no used if linear_tail is chosen)
0108                     fluctuations.npar0_lh.fluct.opt_tail = opt_tail;%Final power fraction of the tail @ Nparmax_tail.
0109                     %
0110                     %%%%%%%%% A MODIFIER - YP %%%%%%%%%%
0111                     %
0112                     if opts.dist == 0,%locally distributed calculations
0113                         %
0114                         [timeid,jobid,dkeparam,dkepath,Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa,XXsinksource] = loop_cronos_C3PO_yp(opts,id_simul,root_dir,Nfluct,tn,dtn,fluctuations,display_mode,Npar_p,Npar_m);                                                                                                                                                                         opt_dist,opt_save,id_simul,root_dir,Nfluct,tn,dtn,fluctuations,display_mode,Npar_p,Npar_m,XXfinit
0115                         %
0116                         % ---------------------------------------------- Save results ----------------------------------------------
0117                         %
0118                         save_file = ['LUKE_RESULTS_',id_simul,'.mat'];
0119                         save([dkeparam.path_simul,save_file]);
0120                         info_dke_yp(2,['Data saved in ',dkeparam.path_simul,save_file]);
0121                         %
0122                         % ---------------------------------------------- Display results ----------------------------------------------
0123                         %
0124                         display_cronos_C3PO(id_simul,equilDKE,ZP0,Zcurr,dkeparam,mksa,racc,p_opt,root_dir)
0125                         %
0126                     else
0127                         [timeid,jobid,dkeparam,dkepath] = loop_cronos_C3PO_yp(opts,id_simul,root_dir,Nfluct,tn,dtn,fluctuations,display_mode,Npar_p,Npar_m);
0128                         %
0129                         job.id_simul{ijob} = id_simul;
0130                         job.id(ijob) = str2num(jobid);
0131                         job.timeid(ijob) = str2num(timeid);
0132                         job.dtn(ijob) = dtn;
0133                         job.hwhm_npar(ijob) = hwhm_npar;
0134                         job.state(ijob) = 0;
0135                         %
0136                         ijob = ijob + 1;
0137                     end  
0138                 end
0139             end
0140         end
0141     end
0142 end
0143 %
0144 if opt_dist > 0,%distributed calculations
0145     job_file = ['LUKE_JOB_',id_simul,'.mat'];
0146     save(job_file,'job','opt_dist','dkepath','dkeparam');
0147     info_dke_yp(2,['Data saved in ',job_file]);
0148 end

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.