bremlocaldisplay_dke_yp

PURPOSE ^

R5-X2 - Draws local properties of the plasma bremsstrahlung

SYNOPSIS ^

function [] = bremlocaldisplay_dke_yp(dkeparam,display,equilDKE,momentumDKE,Zmomcoef,radialDKE,dke_out,mksa,Zbremchord,Zbremplasma,r_display,t_display,k_display,p_opt,filename);

DESCRIPTION ^

R5-X2 - Draws local properties of the plasma bremsstrahlung

 This function draws local properties of the plasma bremsstrahlung

 by J. Decker (CEA/IRFM, joan.decker@cea.fr) and Y. Peysson (CEA/IRFM, yves.peysson@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [] = bremlocaldisplay_dke_yp(dkeparam,display,equilDKE,momentumDKE,Zmomcoef,radialDKE,dke_out,mksa,Zbremchord,Zbremplasma,r_display,t_display,k_display,p_opt,filename);
0002 %R5-X2 - Draws local properties of the plasma bremsstrahlung
0003 %
0004 % This function draws local properties of the plasma bremsstrahlung
0005 %
0006 % by J. Decker (CEA/IRFM, joan.decker@cea.fr) and Y. Peysson (CEA/IRFM, yves.peysson@cea.fr)
0007 %
0008 if nargin < 13, error('Not enough input argument in bremlocaldisplay_dke_yp');end
0009 if nargin == 13, 
0010     p_opt = 2;
0011     filename = '';
0012 end
0013 if nargin == 14, 
0014     filename = '';
0015 end
0016 %
0017 dp_cyl = display.dp_cyl;
0018 nlevel = display.nlevel;
0019 %
0020 [qe,me,mp,mn,e0,mu0,re,mc2,clum,alpha] = pc_dke_yp;%Physics constant
0021 %
0022 ne_ref = mksa.ne_ref;
0023 betath_ref = mksa.betath_ref;
0024 Ec = Zmomcoef.Ec_ref;
0025 %
0026 dmhu = momentumDKE.dmhu;
0027 mhu = momentumDKE.mhu;
0028 dpn = momentumDKE.dpn;
0029 pn = momentumDKE.pn;
0030 %
0031 r_dke = radialDKE.r_dke;
0032 %
0033 pnmax_S = dkeparam.pnmax_S;
0034 bounce_mode = dkeparam.bounce_mode;
0035 %
0036 kphot = Zbremplasma.kphot;
0037 theta_hxr = Zbremplasma.theta_hxr(1,:);
0038 mhubounce2_hxr = Zbremplasma.mhubounce2_hxr;
0039 %
0040 if iscell(dke_out.XXfinit)
0041     XXfinit = dke_out.XXfinit{1}(:,:,r_dke);
0042 else
0043     XXfinit = dke_out.XXfinit(:,:,r_dke);
0044 end
0045 if iscell(dke_out.XXf0)
0046     XXf0 = dke_out.XXf0{1}(:,:,r_dke);
0047 else
0048     XXf0 = dke_out.XXf0(:,:,r_dke);
0049 end
0050 %
0051 Rp = equilDKE.Rp;
0052 Zp = equilDKE.Zp;
0053 ap = equilDKE.Xx(end,1);
0054 %
0055 theta = equilDKE.mtheta;
0056 xpsin = equilDKE.xpsin;
0057 psia_apRp = equilDKE.psia_apRp;
0058 XR = equilDKE.Xx + Rp;
0059 XZ = equilDKE.Xy + Zp;
0060 XBR = equilDKE.XBx;
0061 XBZ = equilDKE.XBy;
0062 XBphi = equilDKE.XBphi;
0063 xB0 = equilDKE.xB0;
0064 xR0 = equilDKE.xx0 + Rp;
0065 xBT0 = equilDKE.xBT0;
0066 xBp0 = equilDKE.xBp0;
0067 xrho = equilDKE.xrho;
0068 xTe = equilDKE.xTe;
0069 xne = equilDKE.xne;
0070 xzTi = equilDKE.xzTi;
0071 xzni = equilDKE.xzni;
0072 zZi = equilDKE.zZi;
0073 zmi = equilDKE.zmi;
0074 xZeff = equilDKE.xZeff;
0075 Rp = equilDKE.Rp;
0076 Zp = equilDKE.Zp;
0077 ap = equilDKE.ap;
0078 xmhu0T2 = equilDKE.xmhu0T2;
0079 xdV_dke = equilDKE.xdV_2piRp_dke*2*pi*Rp;
0080 xdA_dke = equilDKE.xdA_dke;
0081 xzni_norm = xzni(:,r_dke)/ne_ref;
0082 xne_norm = xne(r_dke)/ne_ref;
0083 xrho = xrho(r_dke);
0084 %
0085 pn2 = pn.*pn;
0086 gamma = sqrt(1 + pn2*betath_ref^2);
0087 %
0088 i_test = find(abs(xrho - r_display) == min(abs(xrho - r_display)),1,'first');%Normalized radius index for output and display
0089 j_test = find(abs(theta_hxr - t_display*pi/180) == min(abs(theta_hxr- t_display*pi/180)),1,'first');%Poloidal angle index for output and display
0090 k_test = find(kphot == k_display,1);%Photon energy (keV)
0091 %
0092 rho_out = xrho(i_test);
0093 theta_out = theta_hxr(j_test);
0094 %
0095 % Test of the reconstruction of the distribution function on the Legendre polynomial basis
0096 %
0097 figure('Name','Distribution function @ p_{\perp} = 0');
0098 %ylab = ['f(norm initial: ',num2str(Zbremplasma.Znorm0_hxr{i_test,j_test}),', norm recontructed: ',num2str(Zbremplasma.Znormi_hxr{i_test,j_test}),')'];
0099 ylab = 'f_{0}/n_{e0}';
0100 tit = 'Distribution function @ p_{\perp} = 0';
0101 %
0102 graph1D_jd(pn,Zbremplasma.ZXf0_i{i_test,j_test}(:,size(Zbremplasma.ZXf0_i{i_test,j_test},2)),0,1,'','','',NaN,'','','-','non','b',2);
0103 hold on            
0104 graph1D_jd(pn,Zbremplasma.ZXf0_i1{i_test,j_test}(:,size(Zbremplasma.ZXf0_i{i_test,j_test},2)),0,1,'','','',NaN,'','','--','non','r',2);
0105 graph1D_jd(pn,Zbremplasma.ZXf0_i{i_test,j_test}(:,1),0,1,'','','',NaN,'','','-','non','c',2);
0106 graph1D_jd(pn,Zbremplasma.ZXf0_i1{i_test,j_test}(:,1),0,1,'p_{||}/p_{Te}^{ref}',ylab,tit,NaN,'','','--','non','k',2);
0107 grid on,zoom on
0108 legend('Forward DKE','Forward Legendre','Backward DKE','Backward Legendre','Location','NorthEast')
0109 xxlimit = xlim;yylimit = ylim;
0110 ht = text(xxlimit(1)+1,yylimit(1)*6,['\rho = ',num2str(rho_out),' and \theta_{pol} = ',num2str(theta_out*180/pi),' (Deg)']);set(ht,'fontsize',20);
0111 print_jd(p_opt,[filename,'_DistributionFunction']);
0112 %
0113 % Contour plot of the electron distribution function
0114 %
0115 [logXfinit_cyl,ppar_cyl,dppar_cyl,pperp_cyl,dpperp_cyl] = s2c_dke_yp(log(XXfinit(:,:,i_test)),pn,mhu,dp_cyl);
0116 [logXf0_cyl,ppar_cyl,dppar_cyl,pperp_cyl,dpperp_cyl] = s2c_dke_yp(log(XXf0(:,:,i_test)),pn,mhu,dp_cyl);
0117 [logXf_hxr_cyl,ppar_cyl,dppar_cyl,pperp_cyl,dpperp_cyl] = s2c_dke_yp(log(Zbremplasma.ZXf0_hxr{i_test,j_test}),pn,Zbremplasma.mhu_hxr{i_test,j_test},dp_cyl);
0118 %
0119 Xppar_cyl = ones(length(pperp_cyl),1)*ppar_cyl(:)';
0120 Xpperp_cyl = pperp_cyl(:)*ones(1,length(ppar_cyl));
0121 Xp_cyl2 = Xppar_cyl.*Xppar_cyl + Xpperp_cyl.*Xpperp_cyl;
0122 Xp_cyl = sqrt(Xp_cyl2);
0123 %
0124 Xf0_cyl = exp(logXf0_cyl);%For accurate representation in figures
0125 Xf0_cyl = Xf0_cyl.*(Xf0_cyl>0);%Remove negative values
0126 Xf0_cyl = Xf0_cyl.*(Xp_cyl<max(ppar_cyl));%Remove values above max(ppar)
0127 Xf0_cyl(isnan(Xf0_cyl)) = 0;%Remove NaN values
0128 Xf0_cyl = Xf0_cyl.*(abs(Xf0_cyl)>eps);%Remove value smaller than the numerical accuracy
0129 %
0130 Xfinit_cyl = exp(logXfinit_cyl);%For accurate representation in figures
0131 Xfinit_cyl = Xfinit_cyl.*(Xfinit_cyl>0);%Remove negative values
0132 Xfinit_cyl = Xfinit_cyl.*(Xp_cyl<max(ppar_cyl));%Remove values above max(ppar)
0133 Xfinit_cyl(isnan(Xfinit_cyl)) = 0;%Remove NaN values
0134 Xfinit_cyl = Xfinit_cyl.*(abs(Xfinit_cyl)>eps);%Remove value smaller than the numerical accuracy
0135 %
0136 Xf_hxr_cyl = exp(logXf_hxr_cyl);%For accurate representation in figures
0137 Xf_hxr_cyl = Xf_hxr_cyl.*(Xf_hxr_cyl>0);%Remove negative values
0138 Xf_hxr_cyl = Xf_hxr_cyl.*(Xp_cyl<max(ppar_cyl));%Remove values above max(ppar)
0139 Xf_hxr_cyl(isnan(Xf_hxr_cyl)) = 0;%Remove NaN values
0140 Xf_hxr_cyl = Xf_hxr_cyl.*(abs(Xf_hxr_cyl)>eps);%Remove value smaller than the numerical accuracy
0141 %
0142 %Xppar_cyl = ones(length(pperp_cyl),1)*ppar_cyl(:)';
0143 %Xpperp_cyl = pperp_cyl(:)*ones(1,length(ppar_cyl));
0144 %Xp_cyl = sqrt(Xppar_cyl.*Xppar_cyl + Xpperp_cyl.*Xpperp_cyl);
0145 %
0146 Ec_cyl = (sqrt(Xp_cyl2*(betath_ref).^2 + 1) - 1)*mc2;
0147 mask_cyl_hxr = 1.0*(Ec_cyl < kphot(k_test));
0148 mask_cyl_hxr(mask_cyl_hxr==0) = Inf*mask_cyl_hxr(mask_cyl_hxr==0);
0149 %
0150 xlim1 = [-pnmax_S,pnmax_S];xlim2 = [0,pnmax_S];
0151 siz = 20;red = 0.95;
0152 %
0153 figure('Name','Distribution function contour at B=Bmin');
0154 graph2D_jd(ppar_cyl,pperp_cyl,Xfinit_cyl','','','',xlim1,xlim2,0,betath_ref,[0:0.5:pnmax_S],0,'-','b',0.5,siz,red,max(max(Xf0_cyl)));
0155 graph2D_jd(ppar_cyl,pperp_cyl,Xfinit_cyl'.*mask_cyl_hxr','p_{||}/p_{Te}^{ref}','p_{\perp}/p_{Te}^{ref}','Distribution function',xlim1,xlim2,0,betath_ref,[0:0.5:pnmax_S],0,'-','k',2,siz,red,max(max(Xfinit_cyl)));
0156 graph2D_jd(ppar_cyl,pperp_cyl,Xf0_cyl','p_{||}/p_{Te}^{ref}','p_{\perp}/p_{Te}^{ref}','Distribution function',xlim1,xlim2,0,betath_ref,[0:0.5:pnmax_S],0,'-','r',2,siz,red,max(max(Xfinit_cyl)));
0157 axis('equal');
0158 xxlimit = xlim;yylimit = ylim;
0159 ht = text(xxlimit(1)+1,yylimit(1),['\rho = ',num2str(rho_out),' and \theta_{pol} = 0 (Deg)']);set(ht,'fontsize',20);
0160 %s
0161 if bounce_mode >= 1,%Draw bounce domain boundaries
0162    mhubounce2_0 = xmhu0T2(i_test);
0163    line([0,pnmax_S*sqrt(mhubounce2_0)],[0,pnmax_S*sqrt(1 - mhubounce2_0)],'color','k');
0164    line([0,-pnmax_S*sqrt(mhubounce2_0)],[0,pnmax_S*sqrt(1 - mhubounce2_0)],'color','k');
0165 end                
0166 print_jd(p_opt,[filename,'_DistributionFunctionBmin']);
0167 %
0168 figure('Name','Distribution function contour');
0169 graph2D_jd(ppar_cyl,pperp_cyl,Xfinit_cyl','','','',xlim1,xlim2,0,betath_ref,[0:0.5:pnmax_S],0,'-','b',0.5,siz,red,max(max(Xf_hxr_cyl)));
0170 graph2D_jd(ppar_cyl,pperp_cyl,Xfinit_cyl'.*mask_cyl_hxr','p_{||}/p_{Te}^{ref}','p_{\perp}/p_{Te}^{ref}','Distribution function',xlim1,xlim2,0,betath_ref,[0:0.5:pnmax_S],0,'-','k',2,siz,red,max(max(Xfinit_cyl)));
0171 graph2D_jd(ppar_cyl,pperp_cyl,Xf_hxr_cyl','p_{||}/p_{Te}^{ref}','p_{\perp}/p_{Te}^{ref}','Distribution function',xlim1,xlim2,0,betath_ref,[0:0.5:pnmax_S],0,'-','r',2,siz,red,max(max(Xfinit_cyl)));
0172 axis('equal');
0173 xxlimit = xlim;yylimit = ylim;
0174 ht = text(xxlimit(1)+1,yylimit(1),['\rho = ',num2str(rho_out),' and \theta_{pol} = ',num2str(theta_out*180/pi),' (Deg)']);set(ht,'fontsize',20);
0175 %
0176 if bounce_mode >= 1,%Draw bounce domain boundaries
0177    mhubounce2 = mhubounce2_hxr(i_test,j_test);
0178    line([0,pnmax_S*sqrt(mhubounce2)],[0,pnmax_S*sqrt(1 - mhubounce2)],'color','k');
0179    line([0,-pnmax_S*sqrt(mhubounce2)],[0,pnmax_S*sqrt(1 - mhubounce2)],'color','k');
0180 end
0181 print_jd(p_opt,[filename,'_DistributionFunctionB']);
0182 %
0183 % Local bremsstrahlung properties
0184 %
0185 figure('Name','Local bremshrahlung forward - perp - backward');
0186 graph1D_jd(kphot,Zbremplasma.brem_forward{i_test,j_test},0,1,'','','',NaN,'','','-','non','r',2);
0187 graph1D_jd(kphot,Zbremplasma.brem_backward{i_test,j_test},0,1,'','','',NaN,'','','-','non','b',2);
0188 graph1D_jd(kphot,Zbremplasma.brem_4pi{i_test,j_test},0,1,'','','',NaN,[0,200],'','-.','non','g',2);
0189 graph1D_jd(kphot,Zbremplasma.brem_perp{i_test,j_test},0,1,'Photon energy (keV)','Photon density (s-1*m-3*keV-1*str-1)','Bremsstrahlung emission',NaN,'','','-','non','k',2);
0190 legend('Forward','Backward','Mean 4{\pi}','Perp.')
0191 xxlimit = xlim;yylimit = ylim;
0192 ht = text(xxlimit(1)+1,yylimit(1)*7,['\rho = ',num2str(rho_out),' and \theta_{pol} = ',num2str(theta_out*180/pi),' (Deg)']);set(ht,'fontsize',20);
0193 grid on
0194 print_jd(p_opt,[filename,'_LocalBremsstrahlung']);
0195 %

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