0001 function [equil_magnetic,prho,pspsin,pspsinT,pp] = equil_magnetic_EFIT_jd(eqdsk,display_mode,p_opt,dispname,savename,opt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if nargin < 6,
0025 opt.sfac = 10;
0026 opt.axenforce = true;
0027 end
0028
0029 if nargin < 5,
0030 savename = 'equil';
0031 end
0032
0033 if nargin < 4,
0034 dispname = '';
0035 end
0036
0037 if nargin < 3,
0038 p_opt = -1;
0039 end
0040
0041 if nargin < 2,
0042 display_mode = 0;
0043 end
0044
0045 method = 'spline';
0046 nt = 65;
0047
0048
0049
0050 [x,y,xypsin,psia,psin,pF,pp,pq,Rp,Zp,Ip,Rv,Zv,Bv,pFdFdpsi,pdpdpsi] = eqdsk_jd(eqdsk,display_mode,p_opt,dispname,savename);
0051
0052
0053
0054 [ptx,pty,ptdpsindx,ptdpsindy,psin,theta] = rz2pt_jd(x,y,xypsin,psin,nt,method,display_mode,p_opt,savename,opt);
0055
0056 np = length(psin);
0057 ap = ptx(np,1);
0058 psi_apRp = psin*psia*ap/Rp;
0059 ptR = Rp + ptx;
0060
0061
0062
0063 ptBx = -ptdpsindy*psia./ptR;
0064 ptBy = ptdpsindx*psia./ptR;
0065
0066 ptF = repmat(pF.',[1,nt]);
0067 ptBPHI = ptF./ptR;
0068
0069 ptBP = sqrt(ptBx.^2 +ptBy.^2);
0070 ptB = sqrt(ptBP.^2 + ptBPHI.^2);
0071
0072 prho = ptx(:,1).'/ap;
0073
0074 pq_h = (pq(1:end-1) + pq(2:end))/2;
0075 pdpsin = diff(psin);
0076 ppsiT = [0,cumsum(pq_h.*pdpsin)];
0077 pspsinT = sqrt(ppsiT/ppsiT(end));
0078
0079 pspsin = sqrt(psin);
0080
0081 if display_mode == 2,
0082
0083 rx = [-fliplr(prho(2:np)),prho];
0084 rBx = [fliplr(ptBx(2:np,(nt+1)/2)'),ptBx(:,1)'];
0085 rBy = [fliplr(ptBy(2:np,(nt+1)/2)'),ptBy(:,1)'];
0086 rBPHI = [fliplr(ptBPHI(2:np,(nt+1)/2)'),ptBPHI(:,1)'];
0087 rBP = sqrt(rBx.^2 + rBy.^2);
0088 rB = sqrt(rBP.^2 + rBPHI.^2);
0089
0090 style = '-';
0091 marker = 'none';
0092 color1 = 'r';
0093 color2 = 'b';
0094 color3 = 'k';
0095 width = 2;
0096 siz = 20;
0097 red = 0.9;
0098 lspace = 0.7;
0099 bspace = 0.6;
0100 tit = [dispname];
0101
0102 figure(12),clf
0103
0104 xlab = 'r/a';
0105 ylab = 'B(T)';
0106 xlim = [-1,1];
0107 ylim = NaN;
0108 leg = ['B_T';'B_P';'B '];
0109
0110 graph1D_jd(rx,abs(rBPHI),0,0,'','','',NaN,xlim,ylim,style,marker,color1,width,siz,gca,red,lspace,bspace);
0111 graph1D_jd(rx,rBP,0,0,'','','',NaN,xlim,ylim,style,marker,color2,width);
0112 graph1D_jd(rx,rB,0,0,xlab,ylab,tit,leg,xlim,ylim,style,marker,color3,width);
0113 print_jd(p_opt,[savename,'_Bfield']);
0114
0115 figure(13),clf
0116 graph1D_jd(theta,ptB(2,:),0,0,'','','',NaN,'','',style,marker,'b',width);hold on
0117 plot(theta,ptB([2:end],:))
0118 legend(['r/a = ',num2str(prho(2))])
0119 axis([0,2*pi,0,ceil(max(max(ptB([2:end],:)))*10)/10])
0120 xlabel('\theta (rd)'),ylabel('B(T)'),title([dispname])
0121 end
0122
0123 ptx(:,65) = ptx(:,1);
0124 pty(:,65) = pty(:,1);
0125 ptBx(:,65) = ptBx(:,1);
0126 ptBy(:,65) = ptBy(:,1);
0127 ptBPHI(:,65) = ptBPHI(:,1);
0128
0129
0130
0131 equil_magnetic.psi_apRp = psi_apRp;
0132 equil_magnetic.theta = theta;
0133 equil_magnetic.ptx = ptx;
0134 equil_magnetic.pty = pty;
0135 equil_magnetic.ptBx = ptBx;
0136 equil_magnetic.ptBy = ptBy;
0137 equil_magnetic.ptBPHI = ptBPHI;
0138 equil_magnetic.Rp = Rp;
0139 equil_magnetic.Zp = Zp;
0140 equil_magnetic.equi_src = eqdsk;
0141
0142 equil_magnetic.eqdsk.x = x;
0143 equil_magnetic.eqdsk.y = y;
0144 equil_magnetic.eqdsk.xypsin = xypsin;
0145 equil_magnetic.eqdsk.psia = psia;
0146 equil_magnetic.eqdsk.psin = psin;
0147 equil_magnetic.eqdsk.pF = pF;
0148 equil_magnetic.eqdsk.pp = pp;
0149 equil_magnetic.eqdsk.pq = pq;
0150 equil_magnetic.eqdsk.Rp = Rp;
0151 equil_magnetic.eqdsk.Zp = Zp;
0152 equil_magnetic.eqdsk.Ip = Ip;
0153 equil_magnetic.eqdsk.Rv = Rv;
0154 equil_magnetic.eqdsk.Zv = Zv;
0155 equil_magnetic.eqdsk.Bv = Bv;
0156 equil_magnetic.eqdsk.pFdFdpsi = pFdFdpsi;
0157 equil_magnetic.eqdsk.pdpdpsi = pdpdpsi;
0158