imake_wave_AMR_jd

PURPOSE ^

SYNOPSIS ^

function wave = imake_wave_AMR_jd(basestr,equil,launch,workdir,opt_gui)

DESCRIPTION ^

 This function makes the WAVE file from AMR ray-tracing output
 
 by J. Decker (CEA-DRFC) <joan.decker@cea.fr>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function wave = imake_wave_AMR_jd(basestr,equil,launch,workdir,opt_gui)
0002 %
0003 % This function makes the WAVE file from AMR ray-tracing output
0004 %
0005 % by J. Decker (CEA-DRFC) <joan.decker@cea.fr>
0006 %
0007 wave = '';
0008 %
0009 % The following notations are necessary to write and read proper output files
0010 %
0011 % 6-digit shot number SSSSSS with leading zeros
0012 %
0013 istru = find(equil.id == '_');
0014 if length(istru) >= 2 && strcmp(equil.id(1:istru(1)-1),basestr),
0015     shotnum = equil.id(istru(1)+1:istru(2)-1);
0016     if length(istru) >= 3,
0017         shotime = equil.id(istru(2)+1:istru(3)-1);
0018     else
0019         shotime = equil.id(istru(2)+1:end);
0020     end
0021 else           
0022     disp('-----> Shot number information missing');
0023     return
0024 end
0025 shotnum = [repmat('0',[1,6-length(shotnum)]),shotnum];
0026 %
0027 % Time in fixed format T.TTT
0028 %
0029 shotime = num2str(str2num(shotime),'%1.3f');
0030 %
0031 if isempty(launch),    % Read the existing data file
0032     %
0033     launch.type = 'EC';
0034     %
0035     AMR_simul_path = igetdir_jd(opt_gui,'Please select the AMR simulation folder',workdir);
0036     %
0037     AMR_output_path = [AMR_simul_path,'output/luke/'];
0038     %
0039  else    % Run AMR
0040     %
0041     AMR_script_path = getenv('AMR');
0042     if isempty(AMR_script_path),
0043         AMR_script_path = workdir;
0044     end
0045     %
0046     AMR_script_path = igetdir_jd(opt_gui,'Please select the AMR code folder',AMR_script_path);
0047     AMR_simul_path = igetdir_jd(opt_gui,'Please select the AMR simulation folder',workdir);
0048     %
0049     launch.AMR_script_path = AMR_script_path;
0050     launch.AMR_simul_path = AMR_simul_path;
0051     %
0052     nprz = 101;
0053     extfacR = 0.1;
0054     extfacZ = 0.02;
0055     %
0056     AMR_input_path = [AMR_simul_path,'input/'];
0057     %
0058     if ~exist(AMR_input_path,'dir'),
0059         %
0060         mkdir(AMR_input_path)
0061         %
0062     end
0063     %
0064     equil_id = [num2str(shotnum),'_',shotime];
0065     %
0066     make_equil_RZ_AMR_jd(equil_id,equil,AMR_input_path,nprz,extfacR,extfacZ);
0067     [AMRcfg_file,launch] = make_input_AMR(basestr,equil,launch,AMR_script_path,AMR_simul_path,opt_gui);
0068     %
0069     sd = pwd;
0070     cd(AMR_simul_path)
0071     unix(['python ',AMR_script_path,'ebe6.py ',AMRcfg_file]);
0072     cd(sd);
0073     %
0074     AMR_output_path = [AMR_simul_path,'output/luke/'];
0075     %
0076 end
0077 %
0078 scan_plot_opt = input_dke_yp('Do you want to plot the conversion efficiency scan [y/n]','y',{'y','n'},'',[1,1]);
0079 if scan_plot_opt == 'y'
0080     if exist([AMR_simul_path,'ebe_run/output/conv_eff_0000.dat'],'file');
0081         read_AMR_outputs(AMR_simul_path,1,2);
0082     else
0083         disp(['No conv_eff_0000.dat file in ' AMR_simul_path 'ebe_run/output/ .']);
0084     end
0085 end
0086 %
0087 filename_wavedata = ['luke_rays_*_',shotnum,'_',shotime,'.dat'];
0088 %
0089 [AMR_output_file,AMR_output_path] = igetfile_jd(opt_gui,filename_wavedata,['Please select the AMR output ''',filename_wavedata,''' file'],AMR_output_path);
0090 %
0091 if AMR_output_file == 0,
0092     return
0093 end
0094 %
0095 wavedata = load([AMR_output_path,AMR_output_file],'-ascii');
0096 %
0097 antenna.num = wavedata(1,2);
0098 antenna.conf = wavedata(1,3);
0099 %
0100 antnumbase = num2str(antenna.num);
0101 antnum = ['0'*ones(1,2-length(antnumbase)),antnumbase];
0102 %
0103 antconfbase = num2str(antenna.conf);
0104 antconf = ['0'*ones(1,4-length(antconfbase)),antconfbase];
0105 %
0106 waveparam.filestr = [antnum,'_',antconf,'_',shotnum,'_',shotime];
0107 %
0108 if str2double(shotime) ~= wavedata(1,1),
0109     disp('-----> The shot time is not compatible with equilibrium')
0110     return
0111 end
0112 %
0113 ny = size(wavedata,1);
0114 %
0115 dNpar = input('Spectral width (NaN if calculated from beam size) [NaN]:');
0116 if isempty(dNpar),
0117     dNpar = NaN;
0118 end
0119 if ~isnumeric(dNpar),
0120     disp('-----> Invalid Spectral width');
0121     return
0122 end
0123 %
0124 kmode = input('Plasma model for wave propagation :\n (0:cold, 1:kinetic, 2:R2D2 (requires IMSL), 4:electrostatic) [4] :');
0125 if isempty(kmode),
0126     kmode = 4;
0127 end
0128 if ~isnumeric(kmode) || ~any(kmode == 0:4),
0129     disp('-----> Invalid plasma model option');
0130     return
0131 end
0132 %
0133 opt_rf = input('FLR effects : (0:all, 1:small) [0] :');
0134 if isempty(opt_rf),
0135     opt_rf = 0;
0136 end
0137 if ~isnumeric(opt_rf) || ~any(opt_rf == 0:1),
0138     disp('-----> Invalid FLR effects option');
0139     return
0140 end
0141 %
0142 dsmin = input_dke_yp('Minimum length of ray fragments:',0,[0;Inf],'',[1,1]);
0143 %
0144 if ny == 1,
0145     %
0146     nd_in = 1;
0147     nchi_in = 1;
0148     %
0149     nd = input(['Number of transverse distance positions for beamlets: [',num2str(nd_in),'] :']);
0150     if isempty(nd),
0151         nd = nd_in;
0152     end
0153     if ~isnumeric(nd),
0154         disp('-----> Invalid choice');
0155         return
0156     end
0157     %
0158     nchi = input(['Number of angular positions for beamlets: [',num2str(nchi_in),'] :']);
0159     if isempty(nchi),
0160         nchi = nchi_in;
0161     end
0162     if ~isnumeric(nchi),
0163         disp('-----> Invalid choice');
0164         return
0165     end
0166     %
0167 else
0168     nd = 1;
0169     nchi = 1;
0170 end
0171 %
0172 wave_id_o = ['AMR_',antnum,'_',antconf];
0173 %
0174 wave_id = input(['Please provide an id for the wave [',wave_id_o,'] : '],'s');
0175 if isempty(wave_id),
0176     wave_id = wave_id_o;
0177 end
0178 %
0179 waveparam.id = wave_id;
0180 waveparam.AMR_output_path = AMR_output_path;
0181 %
0182 waveparam.dNpar = dNpar;
0183 waveparam.dsmin = dsmin;
0184 waveparam.kmode = kmode;
0185 waveparam.opt_rf = opt_rf;
0186 %
0187 waveparam.nd = nd;
0188 waveparam.nchi = nchi;
0189 %
0190 wave = proc_rays_AMR_jd(wavedata,waveparam,equil);
0191 wave.launch = launch;
0192 %

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