0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 clear all
0013
0014 id_wave = 'LH_karney_offaxis_2';
0015
0016 id_equil = 'JETh77';
0017 path_equil = '../EQUIL_files/';
0018
0019 [equil] = load_structures_yp('equil',id_equil,path_equil);
0020
0021 omega_lh = [4]*2*pi*1e9;
0022
0023
0024
0025 opt_lh = 2;
0026
0027
0028 blist_lh = [1];
0029
0030
0031
0032
0033 norm_ref = 1;
0034
0035 yvparmin_lh = [4];
0036 yvparmax_lh = [7];
0037
0038 yNparmin_lh = [NaN];
0039 yNparmax_lh = [NaN];
0040 yNpar_lh = [NaN];
0041 ydNpar_lh = [NaN];
0042
0043
0044 yD0_in_c_lh = [2];
0045
0046 yD0_in_lh_prof = [1];
0047 ypeak_lh = [0.4];
0048 ywidth_lh = [0.1];
0049
0050 ythetab_lh = [0]*pi/180;
0051
0052
0053
0054
0055
0056 ns = 1000;
0057 method = 'spline';
0058
0059
0060
0061 [qe,me,mp,mn,e0,mu0,re,mc2,clum,alpha] = pc_dke_yp;
0062
0063 [equilDKE] = equilibrium_jd(equil);
0064
0065 srho = 1:-1/ns:1/ns;
0066
0067 Te0 = equilDKE.xTe(1);
0068 ne0 = equilDKE.xne(1);
0069 lnc_e_ref = 31.3 - 0.5*log(ne0) + log(Te0*1000);
0070 betath_ref = sqrt(Te0/mc2);
0071 nhuth_ref = qe^4*ne0.*lnc_e_ref./(4*pi*e0^2*me^2.*(clum*betath_ref).^3);
0072
0073 sTe = interp1(equilDKE.xrho,equilDKE.xTe,srho,method);
0074 sne = interp1(equilDKE.xrho,equilDKE.xne,srho,method);
0075 slnc_e = 31.3 - 0.5*log(sne) + log(sTe*1000);
0076 sbetath = sqrt(sTe/mc2);
0077 snhuth = qe^4*sne.*slnc_e./(4*pi*e0^2*me^2.*(clum*sbetath).^3);
0078 swpe = sqrt(qe^2*sne/me/e0);
0079
0080 if norm_ref == 0,
0081 srbetath = ones(1,ns);
0082 srnhuth = ones(1,ns);
0083 else
0084 srbetath = sbetath/betath_ref;
0085 srnhuth = snhuth/nhuth_ref;
0086 end
0087
0088 nb_lh = length(yD0_in_c_lh);
0089
0090 sythetab_lh = ones(ns,1)*ythetab_lh;
0091
0092 syvparmin_lh = ones(ns,1)*yvparmin_lh;
0093 syvparmax_lh = ones(ns,1)*yvparmax_lh;
0094 syNparmin_lh = ones(ns,1)*yNparmin_lh;
0095 syNparmax_lh = ones(ns,1)*yNparmax_lh;
0096 syNpar_lh = ones(ns,1)*yNpar_lh;
0097 sydNpar_lh = ones(ns,1)*ydNpar_lh;
0098 syD0_in_c_lh = ones(ns,1)*yD0_in_c_lh;
0099 sypeak_lh = ones(ns,1)*ypeak_lh;
0100 sywidth_lh = ones(ns,1)*ywidth_lh;
0101
0102 syrbetath_lh = repmat(srbetath',[1,nb_lh]);
0103 syrnhuth_lh = repmat(srnhuth',[1,nb_lh]);
0104 sybetath_loc = repmat(sbetath',[1,nb_lh]);
0105
0106 ytest_maskvpar_lh = ~isnan(yvparmin_lh) & ~isnan(yvparmax_lh);
0107 ytest_maskNpars_lh = ~isnan(yNparmin_lh) & ~isnan(yNparmax_lh);
0108 ytest_maskNparg_lh = ~isnan(yNpar_lh) & ~isnan(ydNpar_lh);
0109 ytest_input_lh = [ytest_maskvpar_lh;ytest_maskNpars_lh;ytest_maskNparg_lh];
0110
0111 if sum(ytest_input_lh) ~= ones(1,nb_lh)
0112 error('LH Fourier spectrum input not compatible')
0113 end
0114
0115 syvparmin_lh_loc = syvparmin_lh./syrbetath_lh;
0116 syvparmax_lh_loc = syvparmax_lh./syrbetath_lh;
0117
0118 syNparmin_lh(:,ytest_maskvpar_lh) = 1./syvparmax_lh_loc(:,ytest_maskvpar_lh)./sybetath_loc(:,ytest_maskvpar_lh);
0119 syNparmax_lh(:,ytest_maskvpar_lh) = 1./syvparmin_lh_loc(:,ytest_maskvpar_lh)./sybetath_loc(:,ytest_maskvpar_lh);
0120 ytest_maskNpars_lh = logical(ytest_maskNpars_lh + ytest_maskvpar_lh);
0121
0122 syNpar_lh(:,ytest_maskNpars_lh) = (syNparmax_lh(:,ytest_maskvpar_lh) + syNparmin_lh(:,ytest_maskvpar_lh))/2;
0123
0124
0125 sydNpar_lh(:,ytest_maskNpars_lh) = i*(syNparmax_lh(:,ytest_maskvpar_lh) - syNparmin_lh(:,ytest_maskvpar_lh));
0126
0127 yD0_in_lh_prof = logical(yD0_in_lh_prof);
0128
0129 syrho = srho'*ones(1,nb_lh);
0130
0131 syD0_in_lh = zeros(ns,nb_lh);
0132 syD0_in_lh(:,yD0_in_lh_prof) = 2*sqrt(log(2))*exp(-(syrho(:,yD0_in_lh_prof) - sypeak_lh(:,yD0_in_lh_prof)).^2./(sywidth_lh(:,yD0_in_lh_prof)/2/sqrt(log(2))).^2).*syD0_in_c_lh(:,yD0_in_lh_prof)/sqrt(pi);
0133 syD0_in_lh(:,~yD0_in_lh_prof) = syD0_in_c_lh(:,~yD0_in_lh_prof);
0134
0135 syD0_lh = syD0_in_lh./(syrbetath_lh.*syrbetath_lh.*syrnhuth_lh);
0136
0137
0138
0139
0140 syepol_z_lh = 1./swpe'*omega_lh*ones(1,nb_lh);
0141 syphi_z_lh = 1./syNpar_lh;
0142
0143 syepol_p_lh = [0]*ones(ns,nb_lh);
0144 syepol_m_lh = [0]*ones(ns,nb_lh);
0145 syphi_x_lh = [0]*ones(ns,nb_lh);
0146 syphi_y_lh = [0]*ones(ns,nb_lh);
0147
0148
0149
0150 synorm_lh = (srho*equilDKE.ap*equilDKE.Rp*me.*slnc_e.*swpe.^2*omega_lh)'*ones(1,nb_lh).*abs(syphi_z_lh)./syepol_z_lh.^2;
0151
0152 syP0_lh = zeros(ns,nb_lh);
0153 syP0_lh(:,ytest_maskNpars_lh) = synorm_lh(:,ytest_maskNpars_lh).*syD0_lh(:,ytest_maskNpars_lh).*(syNparmax_lh(:,ytest_maskNpars_lh) - syNparmin_lh(:,ytest_maskNpars_lh));
0154 syP0_lh(:,ytest_maskNparg_lh) = synorm_lh(:,ytest_maskNparg_lh).*syD0_lh(:,ytest_maskNparg_lh).*sydNpar_lh(:,ytest_maskNparg_lh)*sqrt(pi);
0155
0156
0157
0158
0159
0160
0161
0162 yP0_lh = max(syP0_lh);
0163 syphi_z_lh = syphi_z_lh.*(ones(ns,1)*yP0_lh)./(syP0_lh+eps);
0164
0165
0166 syNperp_lh = syNpar_lh./syepol_z_lh;
0167
0168 syR = equilDKE.Rp + equilDKE.ap*syrho.*cos(sythetab_lh);
0169 syZ = equilDKE.Zp + equilDKE.ap*syrho.*sin(sythetab_lh);
0170 syphi = [0]*ones(ns,nb_lh);
0171
0172 for i_lh = blist_lh,
0173 ray.P0_2piRp = yP0_lh(i_lh)'/(2*pi*equilDKE.Rp);
0174
0175 ray.sx = syR(:,i_lh)' - equil.Rp;
0176 ray.sphi = syZ(:,i_lh)';
0177 ray.sy = syphi(:,i_lh)' - equil.Zp;
0178
0179 ray.ss = [];
0180 ray.spsin = [];
0181 ray.stheta = [];
0182
0183 ray.skx = [];
0184 ray.sn = [];
0185 ray.sky = [];
0186
0187 ray.sNpar = syNpar_lh(:,i_lh)';
0188 ray.sNperp = syNperp_lh(:,i_lh)';
0189 ray.sdNpar = reshape(sydNpar_lh(:,i_lh),[1,ns]);
0190
0191
0192 syepol_pmz_lh = [syepol_p_lh(:,i_lh)';syepol_m_lh(:,i_lh)';syepol_z_lh(:,i_lh)'];
0193 syphi_xyz_lh = [syphi_x_lh(:,i_lh)';syphi_y_lh(:,i_lh)';syphi_z_lh(:,i_lh)'];
0194
0195 ray.sepol_pmz = syepol_pmz_lh;
0196 ray.sphi_xyz = syphi_xyz_lh;
0197
0198 rays{i_lh} = ray;
0199 end
0200
0201 wave.omega_rf = omega_lh;
0202 wave.opt_rf = opt_lh;
0203 wave.opt_disp = 0;
0204 wave.equil_id = id_equil;
0205 wave.rays = rays;
0206
0207 save_str = ['WAVE_',id_equil,'_',id_wave,'.mat'];
0208 eval(['save ',save_str,' wave']);