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