0001 function [] = make_wave_JETliketest
0002
0003
0004
0005
0006
0007
0008
0009 close all
0010
0011 id_wave = 'JETliketest';
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;
0036 phi0 = 0;
0037
0038 m0 = 0;
0039 n0 = NaN;
0040 Nphi0 = -2.0;
0041
0042 dNpar0 = NaN;
0043 P0_2piRp = NaN;
0044
0045
0046
0047 mdce_mode_main_C3PO_jd = 0;
0048
0049
0050
0051 C3POdisplay_pchip.ray = 1;
0052 C3POdisplay_pchip.equilibrium = 0;
0053 C3POdisplay_pchip.p_opt = 2;
0054 C3POdisplay_pchip.mdce = 0;
0055
0056 C3POdisplay_spline.ray = 0;
0057 C3POdisplay_spline.equilibrium = 0;
0058 C3POdisplay_spline.p_opt = -1;
0059 C3POdisplay_spline.mdce = 0;
0060
0061 C3POdisplay_analytic.ray = 1;
0062 C3POdisplay_analytic.equilibrium = 0;
0063 C3POdisplay_analytic.p_opt = -1;
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 = 1;
0091 rayparam.tensortype = waveparam.kmode;
0092 rayparam.t0 = 0;
0093 rayparam.tfinal = 30000;
0094 rayparam.dt0 = 1.e-4;
0095 rayparam.dS = 1.e-4;
0096 rayparam.tol = 1e-12;
0097 rayparam.kmax = 30000;
0098 rayparam.ncyclharm = 3;
0099 rayparam.reflection = 1;
0100 rayparam.rel_opt = 1;
0101 rayparam.nperp = 1000;
0102 rayparam.pperpmax = 10;
0103 rayparam.tau_lim = 20;
0104 rayparam.metricmode = 1;
0105 rayparam.rhoswitch = 0.1;
0106 rayparam.substitution_method = 7;
0107
0108
0109
0110
0111
0112 fitparam.method = 'pchip';
0113 tstart = tic;
0114 equil_fit_pchip = fitequil_yp(equil,fitparam.mode_equil,fitparam.method,fitparam.ngridresample,fitparam.nharm);
0115 telapsed_equil_pchip = toc(tstart);
0116
0117 info_dke_yp(2,['Vectorial form of the magnetic equilibrium ',equil.id,' is calculated with pchip method.']);
0118 if C3POdisplay_pchip.equilibrium,testfitequil_yp(equil,equil_fit_pchip);end
0119
0120 fitparam.method = 'spline';
0121 tstart = tic;
0122 equil_fit_spline = fitequil_yp(equil,fitparam.mode_equil,fitparam.method,fitparam.ngridresample,fitparam.nharm);
0123 telapsed_equil_spline = toc(tstart);
0124
0125 info_dke_yp(2,['Vectorial form of the magnetic equilibrium ',equil.id,' is calculated with spline method.']);
0126 if C3POdisplay_spline.equilibrium,testfitequil_yp(equil,equil_fit_spline);end
0127
0128
0129
0130
0131
0132 Bx_a0_fit = ppval(equil_fit_pchip.Bx_fit.pp_a0,rho0);
0133 Bx_an_fit = ppval(equil_fit_pchip.Bx_fit.pp_an,rho0);
0134 Bx_bn_fit = ppval(equil_fit_pchip.Bx_fit.pp_bn,rho0);
0135
0136 By_a0_fit = ppval(equil_fit_pchip.By_fit.pp_a0,rho0);
0137 By_an_fit = ppval(equil_fit_pchip.By_fit.pp_an,rho0);
0138 By_bn_fit = ppval(equil_fit_pchip.By_fit.pp_bn,rho0);
0139
0140 Bz_a0_fit = ppval(equil_fit_pchip.Bz_fit.pp_a0,rho0);
0141 Bz_an_fit = ppval(equil_fit_pchip.Bz_fit.pp_an,rho0);
0142 Bz_bn_fit = ppval(equil_fit_pchip.Bz_fit.pp_bn,rho0);
0143
0144 B_a0_fit = ppval(equil_fit_pchip.B_fit.pp_a0,rho0);
0145 B_an_fit = ppval(equil_fit_pchip.B_fit.pp_an,rho0);
0146 B_bn_fit = ppval(equil_fit_pchip.B_fit.pp_bn,rho0);
0147
0148
0149
0150 [xBx] = calcval_yp(equil_fit_pchip,theta0,Bx_a0_fit,Bx_an_fit,Bx_bn_fit);
0151 [xBy] = calcval_yp(equil_fit_pchip,theta0,By_a0_fit,By_an_fit,By_bn_fit);
0152 [xBz] = calcval_yp(equil_fit_pchip,theta0,Bz_a0_fit,Bz_an_fit,Bz_bn_fit);
0153 [xB] = calcval_yp(equil_fit_pchip,theta0,B_a0_fit,B_an_fit,B_bn_fit);
0154
0155 xBzn = xBz./xB;
0156
0157 Npar0 = Nphi0.*xBzn;
0158
0159 rayinit.omega_rf = omega_rf;
0160 rayinit.yrho0 = rho0;
0161 rayinit.ytheta0 = theta0;
0162 rayinit.yphi0 = phi0;
0163 rayinit.ym0 = m0;
0164 rayinit.yn0 = n0;
0165 rayinit.yNpar0 = Npar0;
0166 rayinit.ydNpar0 = dNpar0;
0167 rayinit.yP0_2piRp = P0_2piRp;
0168
0169
0170
0171
0172
0173 C3POparam.clustermode.main_C3PO_jd.scheduler.mode = mdce_mode_main_C3PO_jd;
0174
0175
0176
0177 tstart = tic;
0178 wave_numeric_pchip = main_C3PO_jd(dkepath,[id_wave,'_numeric_pchip'],equil,equil_fit_pchip,rayinit,waveparam,[],rayparam,C3POdisplay_pchip,C3POparam,[],[],0);clear mex;clear functions
0179 telapsed_ray_numeric_pchip = toc(tstart);
0180
0181
0182
0183
0184
0185
0186
0187 Bx_a0_fit = ppval(equil_fit_spline.Bx_fit.pp_a0,rho0);
0188 Bx_an_fit = ppval(equil_fit_spline.Bx_fit.pp_an,rho0);
0189 Bx_bn_fit = ppval(equil_fit_spline.Bx_fit.pp_bn,rho0);
0190
0191 By_a0_fit = ppval(equil_fit_spline.By_fit.pp_a0,rho0);
0192 By_an_fit = ppval(equil_fit_spline.By_fit.pp_an,rho0);
0193 By_bn_fit = ppval(equil_fit_spline.By_fit.pp_bn,rho0);
0194
0195 Bz_a0_fit = ppval(equil_fit_spline.Bz_fit.pp_a0,rho0);
0196 Bz_an_fit = ppval(equil_fit_spline.Bz_fit.pp_an,rho0);
0197 Bz_bn_fit = ppval(equil_fit_spline.Bz_fit.pp_bn,rho0);
0198
0199 B_a0_fit = ppval(equil_fit_spline.B_fit.pp_a0,rho0);
0200 B_an_fit = ppval(equil_fit_spline.B_fit.pp_an,rho0);
0201 B_bn_fit = ppval(equil_fit_spline.B_fit.pp_bn,rho0);
0202
0203
0204
0205 [xBx] = calcval_yp(equil_fit_spline,theta0,Bx_a0_fit,Bx_an_fit,Bx_bn_fit);
0206 [xBy] = calcval_yp(equil_fit_spline,theta0,By_a0_fit,By_an_fit,By_bn_fit);
0207 [xBz] = calcval_yp(equil_fit_spline,theta0,Bz_a0_fit,Bz_an_fit,Bz_bn_fit);
0208 [xB] = calcval_yp(equil_fit_spline,theta0,B_a0_fit,B_an_fit,B_bn_fit);
0209
0210 xBzn = xBz./xB;
0211
0212 Npar0 = Nphi0.*xBzn;
0213
0214 rayinit.omega_rf = omega_rf;
0215 rayinit.yrho0 = rho0;
0216 rayinit.ytheta0 = theta0;
0217 rayinit.yphi0 = phi0;
0218 rayinit.ym0 = m0;
0219 rayinit.yn0 = n0;
0220 rayinit.yNpar0 = Npar0;
0221 rayinit.ydNpar0 = dNpar0;
0222 rayinit.yP0_2piRp = P0_2piRp;
0223
0224
0225
0226 C3POparam.clustermode.main_C3PO_jd.scheduler.mode = mdce_mode_main_C3PO_jd;
0227
0228
0229
0230
0231
0232
0233
0234 info_dke_yp(2,'Ray trajectories calculated (interpolated magnetic equilibrium with spline method)');
0235
0236
0237
0238
0239
0240
0241
0242 save_str = ['WAVE_',id_wave,'.mat'];
0243 save(save_str,'id_wave','wave_numeric_pchip','equil_fit_pchip');
0244
0245
0246
0247 disp(['Elapsed time (s):',num2str(telapsed_equil_pchip),' for interpolating MHD equilibrium (PCHIP interp. technique)']);
0248
0249
0250 disp(['Elapsed time (s):',num2str(telapsed_ray_numeric_pchip),' for ray calculations with numerical MHD equilibrium (PCHIP interp. technique)']);
0251
0252
0253
0254
0255
0256 waves = {wave_numeric_pchip};
0257 rays = {wave_numeric_pchip.rays{1}};
0258
0259 legs = {'Numeric - pchip';...
0260 'Numeric_pchip'};
0261
0262 equil_fit = [equil_fit_pchip];
0263
0264 filename = ['Fig_',id_wave];
0265
0266 opt.p_opt = C3POdisplay_pchip.p_opt;
0267 opt.ntheta_fit = 65;
0268 opt.nrho_fit = 15;
0269 opt.propvar = 1;
0270
0271 graph_comp_RT_jd(rays,legs,equil_fit,filename,opt)
0272
0273 diary4cvs_C3PO_yp(id_wave,dkepath,waves);