0001 function imake_makeequil_EFIT_jd(workdir,equil,opt_gui)
0002
0003 if nargin < 3,
0004 opt_gui = 1;
0005 end
0006
0007
0008
0009 equilstr = equil.id;
0010 equilstr(equilstr == '.') = 'p';
0011
0012 [data_file,data_path] = iputfile_jd(opt_gui,'make_equil*.m','Please provide a name for the make_wave script',[workdir,'make_equil_',equilstr,'_',wave.id,'.m']);
0013
0014 if data_file == 0,
0015 disp('-----> No make_equil script name specified.');
0016 return
0017 end
0018
0019 filename = [data_path,data_file];
0020
0021
0022
0023 s = {};
0024 s = [s,{'% Script for generating EQUIL structure from external structure with eqdsk data'}];
0025 s = [s,{'%'}];
0026 s = [s,{'% This script is automatically generated by imake_equil_jd.'}];
0027 s = [s,{'% by J. Decker (joan.decker@cea.fr) and Y. Peysson (yves.peysson@cea.fr)'}];
0028 s = [s,{'%'}];
0029 s = [s,{'clear all'}];
0030 s = [s,{'clear mex'}];
0031 s = [s,{'clear functions'}];
0032 s = [s,{'close all'}];
0033 s = [s,{'%'}];
0034 s = [s,{['id_equil = ''',equil.id,''';']}];
0035 s = [s,{'%'}];
0036 s = [s,{'% Path parameters'}];
0037 s = [s,{'%'}];
0038 s = [s,{'id_dkepath = '''';%For all paths used by DKE solver'}];
0039 s = [s,{'path_dkepath = '''';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path'}];
0040 s = [s,{'%'}];
0041 s = [s,{'% External structure'}];
0042 s = [s,{'%'}];
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 s = [s,{['id_external = ''',equil.equil_id,''';%For plasma equilibrium']}];
0058 s = [s,{'path_external = '''';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path'}];
0059 s = [s,{'%'}];
0060 s = [s,{'% initial ray conditions'}];
0061 s = [s,{'%'}];
0062 s = [s,{['ids_rayinit = {''',wave.rayinit.id,'''};']}];
0063 s = [s,{'paths_rayinit = {''''};'}];
0064 s = [s,{'%'}];
0065 s = [s,{'% C3PO computing parameters'}];
0066 s = [s,{'%'}];
0067 s = [s,{['C3POparam.clustermode.main_C3PO_jd.mode = ',num2str(wave.C3POparam.clustermode.main_C3PO_jd.mode),';%MatLab distributed computing environment disabled (0), enabled with the dedicated toolbox (1), enabled with a private method (2)for the function main_C3PO_jd.m (MDC toolbox must be installed for option 1)']}];
0068 s = [s,{['C3POparam.clustermode.main_C3PO_jd.timeout = ',num2str(wave.C3POparam.clustermode.main_C3PO_jd.timeout),';%MatLab distributed computing environment time out (s). after time out is reached, calculations are performed in a sequential mode on a single processor']}];
0069 s = [s,{['C3POparam.clustermode.main_C3PO_jd.size = ',num2str(wave.C3POparam.clustermode.main_C3PO_jd.size),';%MatLab distributed computing environment cluster size. Can be Inf is all the processors of the cluster are free for distributed calculations']}];
0070 s = [s,{'%'}];
0071 s = [s,{'% Display parameters'}];
0072 s = [s,{'%'}];
0073 s = [s,{['C3POdisplay.ray = ',num2str(wave.display.ray),';']}];
0074 s = [s,{['C3POdisplay.equilibrium = ',num2str(wave.display.equilibrium),';']}];
0075 s = [s,{['C3POdisplay.p_opt = ',num2str(wave.display.p_opt),';%Printing or saving option of the figures']}];
0076 s = [s,{'%'}];
0077 s = [s,{'% Wave parameters'}];
0078 s = [s,{'%'}];
0079 s = [s,{['waveparam.mmode = ',num2str(wave.waveparam.mmode),';%cold plasma mode [1] : (-1) m (1) p, p is the slow mode when kperp > 0 (ex : LH slow wave)']}];
0080 s = [s,{['waveparam.kmode = ',num2str(wave.waveparam.kmode),';%(0:cold,1:warm,2:hot;3:weak realtivistic,4:full relativistic)']}];
0081 s = [s,{'%'}];
0082 s = [s,{'%Option parameter for FLR effects and cross-comparison between old FP code: '}];
0083 s = [s,{'% - (0): all FLR effects'}];
0084 s = [s,{'% - (1): small FLR effects and 1/vpar dependence'}];
0085 s = [s,{'% - (2): small FLR effects and no 1/vpar dependence and old grid technique for DQL calculations (Karney, Shoucri) (see rfdiff_dke_jd)'}];
0086 s = [s,{'%'}];
0087 s = [s,{['waveparam.opt_rf = ',num2str(wave.waveparam.opt_rf),';']}];
0088 s = [s,{'%'}];
0089 s = [s,{['waveparam.dsmin = ',num2str(wave.waveparam.dsmin),';%minimum size for ray fragments']}];
0090 s = [s,{'%'}];
0091 s = [s,{['waveparam.nd = ',num2str(wave.waveparam.nd),';%Number of transverse distance positions for beamlets']}];
0092 s = [s,{['waveparam.nchi = ',num2str(wave.waveparam.nchi),';%Number of angular positions for beamlets']}];
0093 s = [s,{'%'}];
0094 s = [s,{['n_rf_list = [',num2str(wave.waveparam.n_rf_list),'];']}];
0095 s = [s,{'%'}];
0096 s = [s,{'% -------------------------------------------------------------------------'}];
0097 s = [s,{'%'}];
0098 s = [s,{'% Global parameters for the vectorial magnetic equilibrium'}];
0099 s = [s,{'%'}];
0100 s = [s,{'% Equilibrium parameters for the ray-tracing'}];
0101 s = [s,{'%'}];
0102 s = [s,{['fitparam.mode_equil = ',num2str(wave.fitparam.mode_equil),';%Magnetic equilibrium grid type: (1): (psi-theta), (2): (x-y)']}];
0103 s = [s,{['fitparam.method = ''',wave.fitparam.method,''';%nearest,spline,pchip']}];
0104 s = [s,{['fitparam.nharm = ',num2str(wave.fitparam.nharm),';%Number of harmonics in the magnetic equilibrium interpolation (less than ntheta_equil/2)']}];
0105 s = [s,{['fitparam.ngridresample = ',num2str(wave.fitparam.ngridresample),';%Number of grid points for resampling the radial profile of magnetic equilibrium parameters']}];
0106 s = [s,{['fitparam.opt_load = ',num2str(wave.fitparam.opt_load),';%Reload existing vectorial magnetic equilibrium (1) or overwrite it (0).']}];
0107 s = [s,{'%'}];
0108 s = [s,{'% Global parameters for the ray-tracing'}];
0109 s = [s,{'%'}];
0110 s = [s,{['rayparam.testmode = ',num2str(wave.rayparam.testmode),';']}];
0111 s = [s,{['rayparam.tensortype = ',num2str(wave.rayparam.tensortype),';%(0:cold,1:warm,2:hot;3:weak realtivistic,4:full relativistic)']}];
0112 s = [s,{['rayparam.t0 = ',num2str(wave.rayparam.t0),';']}];
0113 s = [s,{['rayparam.tfinal = ',num2str(wave.rayparam.tfinal),';']}];
0114 s = [s,{['rayparam.dt0 = ',num2str(wave.rayparam.dt0),';']}];
0115 s = [s,{['rayparam.dS = ',num2str(wave.rayparam.dS),';']}];
0116 s = [s,{['rayparam.tol = ',num2str(wave.rayparam.tol),';%when tolerance is increased (less accurate calculation of D=0), tfinal must be increased accordingly']}];
0117 s = [s,{['rayparam.kmax = ',num2str(wave.rayparam.kmax),';']}];
0118 s = [s,{['rayparam.ncyclharm = ',num2str(wave.rayparam.ncyclharm),';%number of cyclotron harmonics (just for hot and relativistic dielectric tensors)']}];
0119 s = [s,{['rayparam.reflection = ',num2str(wave.rayparam.reflection),';%1:Enforce wave reflection at plasma boundary, 0: the code calculates itself if the ray must leave of not the plasma']}];
0120 s = [s,{['rayparam.rel_opt = ',num2str(wave.rayparam.rel_opt),';%option for (1) relativistic or (0) non-relativistic calculations']}];
0121 s = [s,{['rayparam.nperp =',num2str(wave.rayparam.nperp),';%number of points in pperp integration for damping calculations']}];
0122 s = [s,{['rayparam.pperpmax = ',num2str(wave.rayparam.pperpmax),';%maximum value of pperp in damping calculations']}];
0123 s = [s,{['rayparam.tau_lim = ',num2str(wave.rayparam.tau_lim),';%value of optical depth beyond which the wave is considered absorbed']}];
0124 s = [s,{['rayparam.kextra = ',num2str(wave.rayparam.kextra),';']}];
0125 s = [s,{'%'}];
0126 s = [s,{'% -------------------------------------------------------------------------'}];
0127 s = [s,{'%'}];
0128 s = [s,{'% Load structures'}];
0129 s = [s,{'%'}];
0130 s = [s,{'[equil,rayinits,dkepath] = load_structures_yp(''equil'',id_equil,path_equil,''rayinits'',ids_rayinit,paths_rayinit,''dkepath'',id_dkepath,path_dkepath);'}];
0131 s = [s,{'%'}];
0132 s = [s,{'% -------------------------------------------------------------------------'}];
0133 s = [s,{'%'}];
0134 s = [s,{'% C3P0 ray tracing'}];
0135 s = [s,{'%'}];
0136 s = [s,{'wave = main_C3PO_jd(id_wave,equil,rayinits{1},waveparam,fitparam,rayparam,C3POdisplay,C3POparam);'}];
0137 s = [s,{'%'}];
0138 s = [s,{'% Wave processing and relativistic linear damping'}];
0139 s = [s,{'%'}];
0140 s = [s,{'wave = wave_process_jd(equil,wave,n_rf_list);'}];
0141 s = [s,{'%'}];
0142 s = [s,{'wave.rayinit = rayinits{1};'}];
0143 s = [s,{'wave.fitparam = fitparam;'}];
0144 s = [s,{'wave.rayparam = rayparam;'}];
0145 s = [s,{'wave.display = C3POdisplay;'}];
0146 s = [s,{'wave.C3POparam = C3POparam;'}];
0147 s = [s,{'%'}];
0148 s = [s,{'waveparam.n_rf_list = n_rf_list;'}];
0149 s = [s,{'wave.waveparam = waveparam;'}];
0150 s = [s,{'%'}];
0151 s = [s,{'save_str = [''WAVE_'',id_equil,''_'',id_wave,''.mat''];'}];
0152 s = [s,{'eval([''save '',save_str,'' wave'']);'}];
0153 s = [s,{'%'}];
0154 s = [s,{'info_dke_yp(2,''Wave parameters saved'');'}];
0155 s = [s,{'%'}];
0156
0157 fid = fopen(filename,'w');
0158
0159 for is = 1:length(s),
0160 fprintf(fid,'%s\n',s{is});
0161 end
0162
0163 fclose(fid);
0164 disp(['-----> The make_wave script ',filename,' has been created.']);
0165
0166