0001 function [Zlossmripple] = mripplecoefbuilder_dke_yp(dkeparam,display,equil,equilDKE,gridDKE,mksa,ripple)
0002
0003
0004
0005
0006
0007
0008 npn = gridDKE.npn;
0009 nmhu = gridDKE.nmhu;
0010 nr = gridDKE.nr;
0011 xrho = gridDKE.xrho;
0012
0013 display_mode = display.display_mode;
0014
0015 [xTe_norm,xne_norm,xzni_norm,xzTi_norm,xnloss_norm,xbetath,xlnc_e,xnhu,xrnhuth] = normcoef_dke_yp(mksa,equilDKE,gridDKE);
0016
0017 XXlossripple = zeros(npn,nmhu,nr);
0018 xdeltaripple = zeros(size(xrho));
0019 xdeltaripple = zeros(size(xrho));
0020 xNq = zeros(size(xrho));
0021 Xnhuloss = zeros(npn,nmhu);
0022 xthetabanana = zeros(size(xrho));
0023 xthetaloss = zeros(size(xrho));
0024 xpndetrap = zeros(size(xrho));
0025 xEseuil = zeros(size(xrho));
0026
0027 if ~isempty(ripple) && (isstruct(ripple) && isfield(ripple,'mode') && ripple.mode == 1),
0028 etime_rip = 0;
0029 time0 = clock;
0030
0031 bounce_mode = dkeparam.bounce_mode;
0032
0033 xne = equilDKE.xne;
0034 xBT0 = equilDKE.xBT0;
0035 xZeff = equilDKE.xZeff;
0036 ap = equilDKE.ap;
0037 Rp = equilDKE.Rp;
0038
0039 Xpn = gridDKE.Xpn;
0040 Xmhu = gridDKE.Xmhu;
0041
0042 tokname = equil.id;
0043
0044 xnhuloss = ones(size(xrho))*1000;
0045
0046 for ir = 1:nr,
0047 if isnan(xnhuloss(ir)) == 0 && bounce_mode == 1 && ~(isempty(findstr(tokname,'TS')) && isempty(findstr(tokname,'WEST'))) == 1,
0048 if ir == 1,
0049 info_dke_yp(2,'WARNING: Ripple losses calculations only valid for Tore Supra and WEST tokamak, see main_dke_yp.m for BeLi, Ip and Ncoils values');
0050 disp('-------------------------------------------------------------------------------------------------------------------');
0051 Ip = 0.61;
0052 BeLi = 1.0;
0053 end
0054
0055
0056 [xthetabanana(ir),xthetaloss(ir),pndetrap,xEseuil(ir),xdeltaripple(ir)] = detrapmj3(xZeff(ir),ap,xBT0(ir),Rp,BeLi,Ip,xne(ir),xrho(ir));
0057 xpndetrap(ir) = pndetrap/mksa.betath_ref;
0058
0059 xmhusupertrap(ir) = sin(pi*xthetaloss(ir)/180);
0060 Xmaskrip = (Xpn > xpndetrap(ir)).*(abs(Xmhu) < xmhusupertrap(ir));
0061 Xnhuloss = Xmaskrip*xnhuloss(ir);
0062 else
0063 if isnan(xnhuloss(ir)) == 0 & bounce_mode == 1 & (isempty(findstr(tokname,'TS')) || isempty(findstr(tokname,'WEST'))) == 1
0064 if ir == 1,
0065 info_dke_yp(2,'WARNING: Ripple losses calculations only valid for Tore Supra or WEST tokamak. Wrong tokamak name');
0066 disp('-------------------------------------------------------------------------------------------------------------------');
0067 end
0068 elseif isnan(xnhuloss(ir)) == 0 & bounce_mode == 0 & (isempty(findstr(tokname,'TS')) || isempty(findstr(tokname,'WEST'))) == 0
0069 if ir == 1,
0070 info_dke_yp(2,'WARNING: Ripple losses calculations only valid for bounce averaged calculations');
0071 disp('-------------------------------------------------------------------------------------------------------------------');
0072 end
0073 end
0074 end
0075 XXlossripple(:,:,ir) = Xnhuloss;
0076 end
0077
0078 etime_rip = etime_rip + etime(clock,time0);
0079 if display_mode >= 1,info_dke_yp(2,['Magnetic ripple coefficients calculations done in ',num2str(etime_rip),' (s)']);end
0080 end
0081
0082
0083
0084
0085 Zlossmripple.XXlossripple = XXlossripple;
0086 Zlossmripple.xdeltaripple = xdeltaripple;
0087 Zlossmripple.xNq = xNq;
0088 Zlossmripple.Xnhuloss = Xnhuloss;
0089 Zlossmripple.xthetabanana = xthetabanana;
0090 Zlossmripple.xthetaloss = xthetaloss;
0091 Zlossmripple.xpndetrap = xpndetrap;
0092 Zlossmripple.xpnth = xbetath./xbetath(1);
0093 Zlossmripple.xEseuil = xEseuil;
0094
0095