make_wave_JETliketest_ter

PURPOSE ^

script make_wave_test_RT

SYNOPSIS ^

function [] = make_wave_JETliketest_ter

DESCRIPTION ^

 script make_wave_test_RT

 Parameters for test mode ray-tracing calculations
 This function has a benchmarking purpose only oncerning the (rho,theta) <-> (X,Y) coordinate transformation near the plasma core

 by Y. Peysson (IRFM/CEA) <yves.peysson@cea.fr>, G. Brochard (IRFM/CEA) <>, J. Decker (SPC/EPFL) <joan.decker@epfl.ch>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [] = make_wave_JETliketest_ter
0002 % script make_wave_test_RT
0003 %
0004 % Parameters for test mode ray-tracing calculations
0005 % This function has a benchmarking purpose only oncerning the (rho,theta) <-> (X,Y) coordinate transformation near the plasma core
0006 %
0007 % by Y. Peysson (IRFM/CEA) <yves.peysson@cea.fr>, G. Brochard (IRFM/CEA) <>, J. Decker (SPC/EPFL) <joan.decker@epfl.ch>
0008 %
0009 close all
0010 %
0011 id_wave = 'JETliketest_ter';
0012 flag_analytic = 2;
0013 %
0014 % Path parameters
0015 %
0016 id_dkepath = '';%For all paths used by DKE solver
0017 path_dkepath = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0018 %
0019 % Equilibrium parameters
0020 %
0021 id_equil = 'JETliketest';%For plasma equilibrium
0022 path_equil = '../EQUIL/';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0023 %
0024 % Load structures
0025 %
0026 [equil,dkepath] = load_structures_yp('equil',id_equil,path_equil,'dkepath',id_dkepath,path_dkepath);
0027 %
0028 % =========================================================================
0029 %
0030 % initial ray conditions
0031 %
0032 omega_rf = [3.7]*2*pi*1e9;
0033 %
0034 rho0 = 0.968;
0035 theta0 = 0.0;
0036 phi0 = 0;
0037 %
0038 m0 = 0;
0039 n0 = NaN;
0040 Nphi0 = -1.8;%initial index of refraction
0041 %
0042 dNpar0 = NaN;
0043 P0_2piRp = NaN;
0044 %
0045 % C3PO computing parameters
0046 %
0047 mdce_mode_main_C3PO_jd = 0;%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)
0048 %
0049 % Display parameters
0050 %
0051 C3POdisplay_rt.ray = 1;
0052 C3POdisplay_rt.equilibrium = 0;
0053 C3POdisplay_rt.p_opt = 2;%Printing or saving option of the figures
0054 C3POdisplay_rt.mdce = 0;%for distributed computing
0055 %
0056 C3POdisplay_rtxy.ray = 1;
0057 C3POdisplay_rtxy.equilibrium = 0;
0058 C3POdisplay_rtxy.p_opt = 2;%Printing or saving option of the figures
0059 C3POdisplay_rtxy.mdce = 0;%for distributed computing
0060 %
0061 C3POdisplay_analytic.ray = 0;
0062 C3POdisplay_analytic.equilibrium = 0;
0063 C3POdisplay_analytic.p_opt = 2;%Printing or saving option of the figures
0064 C3POdisplay_analytic.mdce = 0;%for distributed computing
0065 %
0066 % Wave parameters
0067 %
0068 waveparam.mmode = -1;%cold plasma mode [1] : (-1) m (1) p, p is the slow mode when kperp > 0 (ex : LH slow wave)
0069 waveparam.kmode = 0;%(0:cold,1:warm,2:hot;3:weak realtivistic,4:full relativistic)
0070 %
0071 %Option parameter for FLR effects and cross-comparison between old FP code:
0072 %    - (0): all FLR effects
0073 %    - (1): small FLR effects and 1/vpar dependence
0074 %    - (2): small FLR effects and no 1/vpar dependence and old grid technique for DQL calculations (Karney, Shoucri) (see rfdiff_dke_jd)
0075 %
0076 waveparam.opt_rf = NaN;
0077 %
0078 waveparam.dsmin = NaN;%minimum size for ray fragments
0079 %
0080 % -------------------------------------------------------------------------
0081 %
0082 % Global parameters for the vectorial magnetic equilibrium
0083 %
0084 fitparam.mode_equil = 1;%Magnetic equilibrium grid type: (1): (psi-theta), (2): (x-y)
0085 fitparam.nharm = NaN;%Number of harmonics in the magnetic equilibrium interpolation (NaN, Inf or empty, nharm = ntheta-1)
0086 fitparam.ngridresample = 1001;%Number of grid points for resampling the radial profile of magnetic equilibrium parameters
0087 %
0088 % Global parameters for the ray-tracing
0089 %
0090 rayparam.testmode = 0;
0091 rayparam.tensortype = waveparam.kmode;%(0:cold,1:warm,2:hot;3:weak realtivistic,4:full relativistic)
0092 rayparam.t0 = 0;
0093 rayparam.tfinal = 10000;
0094 rayparam.dt0 = 1.e-4;
0095 rayparam.dS = 1.e-4;
0096 rayparam.tol = 1e-12;%when tolerance is increased (less accurate calculation of D=0), tfinal must be increased accordingly
0097 rayparam.kmax = 60000;
0098 rayparam.ncyclharm = 3;%number of cyclotron harmonics (just for hot and relativistic dielectric tensors)
0099 rayparam.reflection = 0;%1:Enforce wave reflection at plasma boundary, 0: the code calculates itself if the ray must leave of not the plasma
0100 rayparam.rel_opt = 1;%option for (1) relativistic or (0) non-relativistic calculations
0101 rayparam.nperp = 1000;%number of points in pperp integration for damping calculations
0102 rayparam.pperpmax = 10;%maximum value of pperp in damping calculations
0103 rayparam.tau_lim = 20;%value of optical depth beyond which the wave is considered absorbed
0104 %
0105 % =========================================================================
0106 %
0107 % C3P0 ray tracing
0108 %
0109 fitparam.method = 'pchip';%nearest,spline,pchip
0110 tstart = tic;
0111 equil_fit = fitequil_yp(equil,fitparam.mode_equil,fitparam.method,fitparam.ngridresample,fitparam.nharm);%Build vectorized magnetic equilibrium structure
0112 telapsed_equil = toc(tstart);
0113 %
0114 info_dke_yp(2,['Vectorial form of the magnetic equilibrium ',equil.id,' is calculated with pchip method.']);
0115 if C3POdisplay_rt.equilibrium,testfitequil_yp(equil,equil_fit);end
0116 %
0117 % Calculation of Npar0 using Nphi0
0118 %
0119 % warning : this is valid only for m=0 cases
0120 %
0121 Bx_a0_fit = ppval(equil_fit.Bx_fit.pp_a0,rho0);
0122 Bx_an_fit = ppval(equil_fit.Bx_fit.pp_an,rho0);
0123 Bx_bn_fit = ppval(equil_fit.Bx_fit.pp_bn,rho0);
0124 %
0125 By_a0_fit = ppval(equil_fit.By_fit.pp_a0,rho0);
0126 By_an_fit = ppval(equil_fit.By_fit.pp_an,rho0);
0127 By_bn_fit = ppval(equil_fit.By_fit.pp_bn,rho0);
0128 %
0129 Bz_a0_fit = ppval(equil_fit.Bz_fit.pp_a0,rho0);
0130 Bz_an_fit = ppval(equil_fit.Bz_fit.pp_an,rho0);
0131 Bz_bn_fit = ppval(equil_fit.Bz_fit.pp_bn,rho0);
0132 %
0133 B_a0_fit = ppval(equil_fit.B_fit.pp_a0,rho0);
0134 B_an_fit = ppval(equil_fit.B_fit.pp_an,rho0);
0135 B_bn_fit = ppval(equil_fit.B_fit.pp_bn,rho0);
0136 %
0137 % Build interpolated magnetic fields
0138 %
0139 [xBx] = calcval_yp(equil_fit,theta0,Bx_a0_fit,Bx_an_fit,Bx_bn_fit);
0140 [xBy] = calcval_yp(equil_fit,theta0,By_a0_fit,By_an_fit,By_bn_fit);
0141 [xBz] = calcval_yp(equil_fit,theta0,Bz_a0_fit,Bz_an_fit,Bz_bn_fit);
0142 [xB] = calcval_yp(equil_fit,theta0,B_a0_fit,B_an_fit,B_bn_fit);
0143 %
0144 xBzn = xBz./xB;
0145 %
0146 Npar0 = Nphi0.*xBzn;
0147 %
0148 rayinit.omega_rf = omega_rf;
0149 rayinit.yrho0 = rho0;%Initial radial position at launch
0150 rayinit.ytheta0 = theta0;%Initial poloidal position at launch
0151 rayinit.yphi0 = phi0;%Initial toroidal position at launch
0152 rayinit.ym0 = m0;%Initial poloidal mode number
0153 rayinit.yn0 = n0;%Initial toroidal mode number
0154 rayinit.yNpar0 = Npar0;%Initial index of refraction
0155 rayinit.ydNpar0 = dNpar0;%initial Ray spectral width
0156 rayinit.yP0_2piRp = P0_2piRp;%Lineic initial power density initial power in the ray (W/m)
0157 %
0158 % --------------------------------------------------------------------------
0159 %
0160 % C3PO computing parameters
0161 %
0162 C3POparam.clustermode.main_C3PO_jd.scheduler.mode = mdce_mode_main_C3PO_jd;%MatLab distributed computing environment
0163 %
0164 % ray-tracing calculations (rho,theta) coordinates only
0165 %
0166 rayparam.metricmode = 1;% 1 : Only curvilinear metric (analytic or numeric); 2 : Both curvilinear and cartesian metric
0167 rayparam.rhoswitch = 0.1;% Radial position at which the switch occurs when metricmode = 2 (default value)
0168 rayparam.deltaswitch = 0.001;% Delta  switch between (rho,theta) <-> (X,Y) to avoid oscillations between modes (default value)
0169 rayparam.substitution_method = 7;%Method of substitution : 1->dichotomy1D, 2->dichotomy2D, 3->newton_numeric1D, 4->newton_numeric2D, 5->newton_analytic1D, 6->newton_analytic2D, 7->newton_mix2D (default value)
0170 %
0171 tstart = tic;
0172 wave_numeric_rt = main_C3PO_jd(dkepath,[id_wave,'_numeric_rt'],equil,equil_fit,rayinit,waveparam,[],rayparam,C3POdisplay_rt,C3POparam,[],[],0);clear mex;clear functions
0173 telapsed_ray_numeric_rt = toc(tstart);
0174 %
0175 info_dke_yp(2,'Ray trajectories calculated (interpolated magnetic equilibrium with pchip method and (rho,theta) coordinates only)');
0176 %
0177 % ray-tracing calculations (rho,theta) <-> (X,Y) conversion in the plasma core
0178 %
0179 rayparam.metricmode = 2;% 1 : Only curvilinear metric; 2 : Both curvilinear and cartesian metric
0180 %
0181 tstart = tic;
0182 wave_numeric_rtxy = main_C3PO_jd(dkepath,[id_wave,'_numeric_rtxy'],equil,equil_fit,rayinit,waveparam,[],rayparam,C3POdisplay_rtxy,C3POparam,[],[],0);clear mex;clear functions
0183 telapsed_ray_numeric_rtxy = toc(tstart);
0184 %
0185 info_dke_yp(2,'Ray trajectories calculated (interpolated magnetic equilibrium with pchip method with (rho,theta) <-> (X,Y) conversion in the plasma core)');
0186 %
0187 tstart = tic;
0188 %
0189 %rayparam.metricmode = 1;% 1 : Only curvilinear metric (analytic or numeric); 2 : Both curvilinear and cartesian metric
0190 %
0191 wave_analytic = main_C3PO_jd(dkepath,[id_wave,'_analytic'],equil,equil_fit,rayinit,waveparam,[],rayparam,C3POdisplay_analytic,C3POparam,[],[],flag_analytic);
0192 telapsed_ray_analytic = toc(tstart);
0193 %
0194 info_dke_yp(2,'Ray trajectories calculated (analytic magnetic equilibrium)');
0195 %
0196 save_str = ['WAVE_',id_wave,'.mat'];
0197 save(save_str,'id_wave','wave_numeric_rt','wave_numeric_rtxy','wave_analytic','equil_fit');
0198 %
0199 info_dke_yp(2,'Wave parameters saved');
0200 %
0201 disp(['Elapsed time (s):',num2str(telapsed_equil),' for interpolating MHD equilibrium (PCHIP interp. technique ']);
0202 %
0203 disp(['Elapsed time (s):',num2str(telapsed_ray_numeric_rt),' for ray calculations with numerical MHD equilibrium (PCHIP interp. technique, (rho,theta) coordinate only))']);
0204 disp(['Elapsed time (s):',num2str(telapsed_ray_numeric_rtxy),' for ray calculations with numerical MHD equilibrium (PCHIP interp. technique (rho,theta) <-> (X,Y) conversion in the plasma core))']);
0205 disp(['Elapsed time (s):',num2str(telapsed_ray_analytic),' for ray calculations with analytical MHD equilibrium']);
0206 %
0207 % --- display results ---
0208 %
0209 waves = {wave_numeric_rt,wave_numeric_rtxy,wave_analytic};
0210 rays = {wave_numeric_rt.rays{1},wave_numeric_rtxy.rays{1},wave_analytic.rays{1}};
0211 %
0212 legs = {['Numeric - ',fitparam.method,'_{rt}'],['Numeric - ',fitparam.method,'_{rt-xy}'],'Analytic_{rt}';...
0213        'Numeric_{rt}','Numeric_{rt-xy}','Analytic_{rt}'};
0214 %
0215 equil_fit = [equil_fit];
0216 %
0217 filename = ['Fig_',id_wave];
0218 %
0219 opt.p_opt = C3POdisplay_rt.p_opt;
0220 opt.ntheta_fit = 65;
0221 opt.nrho_fit = 15;
0222 opt.propvar = 1;   
0223 %
0224 graph_comp_RT_jd(rays,legs,equil_fit,filename,opt)
0225 %
0226 diary4cvs_C3PO_yp(id_wave,dkepath,waves);% diary some results for CVS validation
0227 
0228 
0229 
0230 
0231 
0232 
0233

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