bremchorddisplay_dke_yp

PURPOSE ^

SYNOPSIS ^

function [] = bremchorddisplay_dke_yp(Zbremchord,chordnum_disp,axs,p_opt,filename,font)

DESCRIPTION ^

 This function draws chord positions for bremsstrahlung tomography

 INPUTS

       - Zbremchord: Bremsstrahlung diagnostic arrangement data strcuture
       
 OUTPUTS: none

 by J. Decker (jodecker@alum.mit.edu) and Y. Peysson (yves.peysson@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [] = bremchorddisplay_dke_yp(Zbremchord,chordnum_disp,axs,p_opt,filename,font)
0002 %
0003 % This function draws chord positions for bremsstrahlung tomography
0004 %
0005 % INPUTS
0006 %
0007 %       - Zbremchord: Bremsstrahlung diagnostic arrangement data strcuture
0008 %
0009 % OUTPUTS: none
0010 %
0011 % by J. Decker (jodecker@alum.mit.edu) and Y. Peysson (yves.peysson@cea.fr)
0012 %
0013 if nargin < 6, 
0014     font = struct;
0015 end
0016 if nargin < 5, 
0017     filename = '';
0018 end
0019 if nargin < 4, 
0020     p_opt = -1;
0021 end
0022 if nargin < 3, 
0023     axs = [];
0024 end
0025 if nargin < 2, 
0026     chordnum_disp = [];
0027 end
0028 if nargin < 1, 
0029     error('Not enough input argument in bremchorddisplay_dke_yp');
0030 end
0031 %
0032 if iscell(Zbremchord),% multiple cameras, iluke
0033     %
0034     opt_txt = false;
0035     %
0036     ncams = length(Zbremchord);
0037     sR = cell(1,ncams);
0038     sZ = cell(1,ncams);
0039     sphi = cell(1,ncams);    
0040     for icam = 1:ncams,
0041         sR{icam} = Zbremchord{icam}.sR;
0042         sZ{icam} = Zbremchord{icam}.sZ;
0043         sphi{icam} = Zbremchord{icam}.sphi;
0044     end
0045     %
0046     ptrho = Zbremchord{1}.ptrho;
0047     xq = Zbremchord{1}.xq;
0048     xpsin_S = Zbremchord{1}.xpsin_S;
0049     RR_pol = Zbremchord{1}.RR_pol;
0050     ZZ_pol = Zbremchord{1}.ZZ_pol;
0051     HHR_pol = Zbremchord{1}.HHR_pol;
0052     HHZ_pol = Zbremchord{1}.HHZ_pol;
0053     VVR_pol = Zbremchord{1}.VVR_pol;
0054     VVZ_pol = Zbremchord{1}.VVZ_pol;
0055     ptR = Zbremchord{1}.ptR;
0056     ptZ = Zbremchord{1}.ptZ;
0057     BR_pol = Zbremchord{1}.BR_pol;
0058     BZ_pol = Zbremchord{1}.BZ_pol;
0059     X_mfl_lcs = Zbremchord{1}.X_mfl_lcs;
0060     Y_mfl_lcs = Zbremchord{1}.Y_mfl_lcs;
0061     Z_mfl_lcs = Zbremchord{1}.Z_mfl_lcs;
0062     BX_mfl_lcs = Zbremchord{1}.BX_mfl_lcs;
0063     BY_mfl_lcs = Zbremchord{1}.BY_mfl_lcs;
0064     Ipdir_mfl_lcs = Zbremchord{1}.Ipdir_mfl_lcs;
0065     XX_tor_min = Zbremchord{1}.XX_tor_min;
0066     YY_tor_min = Zbremchord{1}.YY_tor_min;
0067     XX_tor = Zbremchord{1}.XX_tor;
0068     YY_tor = Zbremchord{1}.YY_tor;
0069     XX_tor_max = Zbremchord{1}.XX_tor_max;
0070     YY_tor_max = Zbremchord{1}.YY_tor_max;
0071     VVX = Zbremchord{1}.VVX;
0072     VVY = Zbremchord{1}.VVY;
0073     HHX = Zbremchord{1}.HHX;
0074     HHY = Zbremchord{1}.HHY;
0075     %
0076 else% unique camera, irunhxr_jd
0077     %
0078     opt_txt = true;
0079     %
0080     ncams = 1;
0081     sR = {Zbremchord.sR};
0082     sZ = {Zbremchord.sZ};
0083     sphi = {Zbremchord.sphi};
0084     %
0085     ptrho = Zbremchord.ptrho;
0086     xq = Zbremchord.xq;
0087     xpsin_S = Zbremchord.xpsin_S;
0088     RR_pol = Zbremchord.RR_pol;
0089     ZZ_pol = Zbremchord.ZZ_pol;
0090     HHR_pol = Zbremchord.HHR_pol;
0091     HHZ_pol = Zbremchord.HHZ_pol;
0092     VVR_pol = Zbremchord.VVR_pol;
0093     VVZ_pol = Zbremchord.VVZ_pol;
0094     ptR = Zbremchord.ptR;
0095     ptZ = Zbremchord.ptZ;
0096     BR_pol = Zbremchord.BR_pol;
0097     BZ_pol = Zbremchord.BZ_pol;
0098     X_mfl_lcs = Zbremchord.X_mfl_lcs;
0099     Y_mfl_lcs = Zbremchord.Y_mfl_lcs;
0100     Z_mfl_lcs = Zbremchord.Z_mfl_lcs;
0101     BX_mfl_lcs = Zbremchord.BX_mfl_lcs;
0102     BY_mfl_lcs = Zbremchord.BY_mfl_lcs;
0103     Ipdir_mfl_lcs = Zbremchord.Ipdir_mfl_lcs;
0104     XX_tor_min = Zbremchord.XX_tor_min;
0105     YY_tor_min = Zbremchord.YY_tor_min;
0106     XX_tor = Zbremchord.XX_tor;
0107     YY_tor = Zbremchord.YY_tor;
0108     XX_tor_max = Zbremchord.XX_tor_max;
0109     YY_tor_max = Zbremchord.YY_tor_max;
0110     VVX = Zbremchord.VVX;
0111     VVY = Zbremchord.VVY;
0112     HHX = Zbremchord.HHX;
0113     HHY = Zbremchord.HHY;
0114     %
0115 end
0116 %
0117 if isempty(axs),
0118     red = 0.9;
0119     lspace = 0.7;
0120     bspace = 0.5;
0121     %
0122     figure('Name','Safety factor');
0123     ax = gca;
0124     %
0125     [ax] = graph1D_jd(ptrho,xq,0,0,'Normalized radius {\rho}','q','Safety factor',NaN,'','','-','none','b',2,font,ax,red,lspace,bspace);drawnow;%Safety factor profile
0126     print_jd(p_opt,[filename,'_SafetyFactor']);
0127 else
0128     red = 1;
0129     lspace = NaN;
0130     bspace = NaN;
0131 end
0132 %
0133 if isempty(axs),
0134     figure('Name','Bremsstrahlung tomography (Poloidal view)');
0135     ax = gca;
0136     tit = 'Bremsstrahlung tomography (Poloidal view)';
0137 else
0138     ax = axs(1);
0139     tit = '';
0140 end
0141 %
0142 for icam = 1:ncams,
0143     [ax] = graph1D_jd(sR{icam},sZ{icam},0,0,'','','',NaN,'','','-','none','b',2,font,ax);%Poloidal plot
0144     if ~isempty(chordnum_disp) && ~isnan(chordnum_disp(icam)),
0145        [ax] = graph1D_jd(sR{icam}(:,chordnum_disp(icam)),sZ{icam}(:,chordnum_disp(icam)),0,0,'','','',NaN,'','','-','none','g',2,font,ax);%Poloidal plot
0146     end
0147 end
0148 if opt_txt,
0149     for ichord = 1:size(sR,2),
0150         if iscell(sR)
0151             sRc = sR{1}(~isnan(sR{1}(:,ichord)),ichord);
0152         else
0153             sRc = sR(~isnan(sR(:,ichord)),ichord);
0154         end
0155         if iscell(sZ)
0156             sZc = sZ{1}(~isnan(sZ{1}(:,ichord)),ichord);
0157         else
0158             sZc = sZ(~isnan(sZ(:,ichord)),ichord);
0159         end
0160        if ~isempty(sRc) && ~isempty(sZc)
0161           ht = text(sRc(end),sZc(end),['  #',int2str(ichord)]);set(ht,'fontsize',10);
0162        end
0163     end
0164 end
0165 if isempty(axs),
0166     for ir = 1:length(xpsin_S),
0167        [ax] = graph1D_jd(RR_pol(ir,:),ZZ_pol(ir,:),0,0,'','','',NaN,'','','-','none','r',1,font,ax);
0168     end
0169     graph1D_jd(HHR_pol,HHZ_pol,0,0,'','','',NaN,'','','-.','none','r',1);
0170     graph1D_jd(VVR_pol,VVZ_pol,0,0,'','','',NaN,'','','-.','none','r',1);
0171     graph1D_jd(HHR_pol,HHZ_pol,0,0,'','','',NaN,'','','-.','none','r',1);
0172     graph1D_jd(VVR_pol,VVZ_pol,0,0,'','','',NaN,'','','-.','none','r',1); 
0173     graph1D_jd(ptR,ptZ,0,0,'R (m)','Z (m)',tit,NaN,'','','-','none','r',1,font,ax,red,lspace,bspace);
0174 else
0175     graph1D_jd(ptR.',ptZ.',0,0,'R (m)','Z (m)',tit,NaN,'','','-','none','r',1,font,ax,red,lspace,bspace);    
0176 end
0177 axis(ax,'equal');drawnow
0178 print_jd(p_opt,[filename,'_PoloidalView']);
0179 %
0180 if isempty(axs),
0181     figure('Name','Poloidal field');
0182     quiver(RR_pol,ZZ_pol,BR_pol,BZ_pol);
0183     axis('equal');
0184     hold on
0185     graph1D_jd(ptR,ptZ,0,0,'','','',NaN,'','','-','none','c',1);
0186     graph1D_jd(HHR_pol,HHZ_pol,0,0,'','','',NaN,'','','-.','none','r',1);
0187     graph1D_jd(VVR_pol,VVZ_pol,0,0,'X=R (m)','Z (m)','B_{\theta} field (T)',NaN,'','','-.','none','r',1);
0188     hold off
0189     print_jd(p_opt,[filename,'_BthetaField']);
0190 end
0191 %
0192 if isempty(axs),
0193     figure('Name','Bremsstrahlung tomography (Toroidal top view, Z = 0)');
0194     ax = gca;
0195     tit = 'Bremsstrahlung tomography (Poloidal view)';
0196     leg = 'B-field, (Ip: green, Ip-dke: magenta)';
0197     %
0198     h = quiver(X_mfl_lcs(1:40:end),Y_mfl_lcs(1:40:end),BX_mfl_lcs(1:40:end),BY_mfl_lcs(1:40:end),0.5);%Magnetic field line direction
0199     set(h,'Color','k');
0200     hold on
0201     sssB = sign(BY_mfl_lcs(1));%sign at phi = 0. if BPHI < 0, sssB < 0, and for BPHI > 0, sssB > 0
0202     sssIp = sign(Ipdir_mfl_lcs(1));
0203     h = quiver(X_mfl_lcs(20:40:end),Y_mfl_lcs(20:40:end),sssIp*sssB*BX_mfl_lcs(20:40:end),sssIp*sssB*BY_mfl_lcs(20:40:end),0.5);%Current direction on magnetic field line direction
0204     set(h,'Color','g');
0205 else
0206     ax = axs(2);
0207     tit = '';
0208     leg = NaN;
0209 end
0210 %
0211 if isempty(axs),
0212     graph1D_jd(XX_tor_min,YY_tor_min,0,0,'','','',NaN,'','','-','none','r',2);
0213     graph1D_jd(XX_tor,YY_tor,0,0,'','','',NaN,'','','-.','none','r',2);
0214     graph1D_jd(XX_tor_max,YY_tor_max,0,0,'','','',NaN,'','','-','none','r',2);
0215     graph1D_jd(VVX,VVY,0,0,'','','',NaN,'','','-.','none','r',1);
0216     graph1D_jd(HHX,HHY,0,0,'','','',NaN,'','','-.','none','r',1);
0217     i_mfl_lcs = find(Z_mfl_lcs>=0);
0218     [ax] = graph1D_jd(X_mfl_lcs(1:3:end),Y_mfl_lcs(1:3:end),0,0,'','','',NaN,'','',':','none','k',1,font,ax);%Z < 0
0219     [ax] = graph1D_jd(X_mfl_lcs(i_mfl_lcs(1:end-1)),Y_mfl_lcs(i_mfl_lcs(1:end-1)),0,0,'','','',NaN,'','','-','none','k',1,font,ax);%Z >= 0
0220     [ax] = graph1D_jd(X_mfl_lcs(i_mfl_lcs(1)),Y_mfl_lcs(i_mfl_lcs(1)),0,0,'X (m)','Y (m)',tit,leg,'','','none','*','k',1,font,ax,red,lspace,bspace);%Z >= 0
0221     set(ax,'YDir','rev');%Because the reference is indirect by definition
0222 else
0223     phi = linspace(0,2*pi,1001);
0224     nr = size(ptR,1);
0225     for ir = 1:nr,
0226         Rmin = min(ptR(ir,:));
0227         Rmax = max(ptR(ir,:));
0228         %
0229         [ax] = graph1D_jd(Rmin*cos(phi),Rmin*sin(phi),0,0,'','','',NaN,'','','-','none','r',1,font,ax);
0230         if ir < nr,
0231             [ax] = graph1D_jd(Rmax*cos(phi),Rmax*sin(phi),0,0,'','','',NaN,'','','-','none','r',1,font,ax);
0232         else
0233             [ax] = graph1D_jd(Rmax*cos(phi),Rmax*sin(phi),0,0,'X (m)','Y (m)',tit,leg,'','','-','none','r',1,font,ax,red,lspace,bspace);
0234         end
0235     end
0236 end
0237 %
0238 for icam = 1:ncams,
0239     ax = graph1D_jd(sR{icam}.*cos(sphi{icam}),sR{icam}.*sin(sphi{icam}),0,0,'','','',NaN,'','','-','none','b',2,font,ax);
0240     if ~isempty(chordnum_disp) && ~isnan(chordnum_disp(icam)),
0241        [ax] = graph1D_jd(sR{icam}(:,chordnum_disp(icam)).*cos(sphi{icam}(:,chordnum_disp(icam))),sR{icam}(:,chordnum_disp(icam)).*sin(sphi{icam}(:,chordnum_disp(icam))),0,0,'','','',NaN,'','','-','none','g',2,font,ax);%Poloidal plot
0242     end
0243 end
0244 %
0245 axis(ax,'equal')
0246 set(ax,'xtickmode','auto','ytickmode','auto');drawnow
0247 %
0248 print_jd(p_opt,[filename,'_TopView']);
0249 %
0250 if isempty(axs),
0251     disp('***************************************************************************************************************************************************')
0252     disp('WARNING: the definitions used in the DKE code, and here crucial for HXR calculations are the following');
0253     disp('   1) the toroidal frame (R,Z,phi) is direct (phi is positive clockwise when the tokamak is seen from the top)');
0254     disp('   2) the poloidal frame (r,theta,phi) is direct');
0255     disp('   3) (psi,s,phi) must be direct : if Ip.phi > 0, then B.theta > 0 and psi > 0, and s.theta > 0 (s as the same direction of theta)');
0256     disp('   4) the sign of psi is the sign of Ip.phi');
0257     disp('With the definitions above, if Ip is positive, psi is turned outward, Btheta is counterclockwise poloidally, and s too. The Ampere theorem is OK !');
0258     disp('The HXR diagnostic arrangement is taking this frame of reference.');
0259     disp('-----------------------------------------------------------');
0260     disp(['Sign of Bphi: ',int2str(sssB),' / Sign of Ip: ',int2str(sssIp)]);
0261     disp('***************************************************************************************************************************************************')
0262 end
0263

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