0001 function [] = make_wave_JETliketest_ter
0002
0003
0004
0005
0006
0007
0008
0009 close all
0010
0011 id_wave = 'JETliketest_ter';
0012 flag_analytic = 2;
0013
0014
0015
0016 id_dkepath = '';
0017 path_dkepath = '';
0018
0019
0020
0021 id_equil = 'JETliketest';
0022 path_equil = '../EQUIL/';
0023
0024
0025
0026 [equil,dkepath] = load_structures_yp('equil',id_equil,path_equil,'dkepath',id_dkepath,path_dkepath);
0027
0028
0029
0030
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;
0041
0042 dNpar0 = NaN;
0043 P0_2piRp = NaN;
0044
0045
0046
0047 mdce_mode_main_C3PO_jd = 0;
0048
0049
0050
0051 C3POdisplay_rt.ray = 1;
0052 C3POdisplay_rt.equilibrium = 0;
0053 C3POdisplay_rt.p_opt = 2;
0054 C3POdisplay_rt.mdce = 0;
0055
0056 C3POdisplay_rtxy.ray = 1;
0057 C3POdisplay_rtxy.equilibrium = 0;
0058 C3POdisplay_rtxy.p_opt = 2;
0059 C3POdisplay_rtxy.mdce = 0;
0060
0061 C3POdisplay_analytic.ray = 0;
0062 C3POdisplay_analytic.equilibrium = 0;
0063 C3POdisplay_analytic.p_opt = 2;
0064 C3POdisplay_analytic.mdce = 0;
0065
0066
0067
0068 waveparam.mmode = -1;
0069 waveparam.kmode = 0;
0070
0071
0072
0073
0074
0075
0076 waveparam.opt_rf = NaN;
0077
0078 waveparam.dsmin = NaN;
0079
0080
0081
0082
0083
0084 fitparam.mode_equil = 1;
0085 fitparam.nharm = NaN;
0086 fitparam.ngridresample = 1001;
0087
0088
0089
0090 rayparam.testmode = 0;
0091 rayparam.tensortype = waveparam.kmode;
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;
0097 rayparam.kmax = 60000;
0098 rayparam.ncyclharm = 3;
0099 rayparam.reflection = 0;
0100 rayparam.rel_opt = 1;
0101 rayparam.nperp = 1000;
0102 rayparam.pperpmax = 10;
0103 rayparam.tau_lim = 20;
0104
0105
0106
0107
0108
0109 fitparam.method = 'pchip';
0110 tstart = tic;
0111 equil_fit = fitequil_yp(equil,fitparam.mode_equil,fitparam.method,fitparam.ngridresample,fitparam.nharm);
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
0118
0119
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
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;
0150 rayinit.ytheta0 = theta0;
0151 rayinit.yphi0 = phi0;
0152 rayinit.ym0 = m0;
0153 rayinit.yn0 = n0;
0154 rayinit.yNpar0 = Npar0;
0155 rayinit.ydNpar0 = dNpar0;
0156 rayinit.yP0_2piRp = P0_2piRp;
0157
0158
0159
0160
0161
0162 C3POparam.clustermode.main_C3PO_jd.scheduler.mode = mdce_mode_main_C3PO_jd;
0163
0164
0165
0166 rayparam.metricmode = 1;
0167 rayparam.rhoswitch = 0.1;
0168 rayparam.deltaswitch = 0.001;
0169 rayparam.substitution_method = 7;
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
0178
0179 rayparam.metricmode = 2;
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
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
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);
0227
0228
0229
0230
0231
0232
0233