bouncecoefbuilder_dke_yp

PURPOSE ^

SYNOPSIS ^

function [Zbouncecoef] = bouncecoeffbuilder_dke_yp(dkeparam,dkedisplay,equilDKE,gridDKE)

DESCRIPTION ^

   Calculate bounce averaged coefficients for the 3D electron relativistic drift kinetic solver.

   by Y. Peysson (CEA-DRFC) (yves.peysson@cea.fr) and J. Decker (CEA-DRFC) (joan.decker@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Zbouncecoef] = bouncecoeffbuilder_dke_yp(dkeparam,dkedisplay,equilDKE,gridDKE)
0002 %
0003 %   Calculate bounce averaged coefficients for the 3D electron relativistic drift kinetic solver.
0004 %
0005 %   by Y. Peysson (CEA-DRFC) (yves.peysson@cea.fr) and J. Decker (CEA-DRFC) (joan.decker@cea.fr)
0006 %
0007 bounce_mode = dkeparam.bounce_mode;
0008 dke_mode = dkeparam.dke_mode;
0009 equil_mode = dkeparam.equil_mode;
0010 %
0011 display_mode = dkedisplay.display_mode;
0012 %
0013 mhu = gridDKE.mhu;
0014 mhum = gridDKE.mhum;
0015 mhup = gridDKE.mhup;
0016 nr = gridDKE.nr;
0017 nmhu = gridDKE.nmhu;
0018 npn = gridDKE.npn;
0019 nr_dke = gridDKE.nr_dke;
0020 rdke = gridDKE.rdke;
0021 %
0022 %
0023 %Bounce average coefficients
0024 %
0025 [xq,xqtilde,xqbar,xqhat,xqcronos,...
0026      XXheaviside,XXheaviside_p,XXheaviside_m,...
0027      Xxlambda,Xxlambda_p,Xxlambda_m,...
0028      XXlambda,XXRlambda_m,XXRlambda_p,...
0029      XXlambda_p2m1,XXRlambda_p2m1_m,XXRlambda_p2m1_p,...
0030      XXRlambda_p0p3,XXRlambda_p2p2_m,XXRlambda_p2p2_p,...
0031      XXlambda_p2m2p2,...
0032      XXRlambda_b_p1p1,...
0033      XXlambda_b_p1m1p2,XXRlambda_b_p1m1p2,XXRlambda_b_p1m1p2_m,XXRlambda_b_p1m1p2_p,...
0034      XXlambda_b_p1m1,XXRlambda_b_p1m1,XXRlambda_b_p1m1_m,XXRlambda_b_p1m1_p,...
0035      XXRlambda_b_p1m2_m,XXRlambda_b_p1m2_p,...
0036      XXlambda_b_p2m2p2,XXRlambda_b_p2m2p2,XXRlambda_b_p2m2p2_m,XXRlambda_b_p2m2p2_p,...
0037      XXlambda_b_p3m2,XXRlambda_b_p3m2_m,XXRlambda_b_p3m2_p,...
0038      XXlambda_b_p2,...
0039      XXlambda_b_p1m3p4,XXlambda_b_p1m2p2]...
0040 =  bounceparam_dke_yp(bounce_mode,equil_mode,display_mode,...
0041      mhu,mhum,mhup,npn,equilDKE);
0042 %
0043 sm_f = zeros(1,nr+1);
0044 sm_T_f = zeros(1,nr+1);
0045 %
0046 for ir = 1:nr,
0047     if bounce_mode == 1,
0048         Zmask_f0_P{ir} = logical(XXheaviside(1,:,ir));%Passing electrons are selected
0049         Zmask_f0_Tm{ir} = logical(~XXheaviside(1,:,ir)) & (mhu < 0);%Trapped electrons with mhu>0 are selected
0050         Zmask_f0_Tp{ir} = logical(~XXheaviside(1,:,ir)) & (mhu > 0);%Trapped electrons with mhu<0 are selected
0051         Zmask_f0_t{ir} = (Zmask_f0_P{ir} + Zmask_f0_Tp{ir}) > 0;%Passing and half of trapped electrons are selected
0052         Zmask_f0_t_P{ir} = Zmask_f0_P{ir}(Zmask_f0_t{ir});%For matrix symmetrization
0053         Zmask_f0_t_Tp{ir} = Zmask_f0_Tp{ir}(Zmask_f0_t{ir});%For matrix symmetrization
0054         jmhut_min(ir) = min(find(Zmask_f0_Tm{ir})); 
0055         jmhut_max(ir) = max(find(Zmask_f0_Tp{ir})); 
0056         djmhut(ir) = (jmhut_max(ir) - jmhut_min(ir) + 1)/2;
0057         ns_f(ir) = djmhut(ir);
0058         if djmhut(ir) <= 3,
0059            error(['WARNING: Not enough pitch-angle grid points in the bounce region for accurate bounce-averaged calculations (increasing nmhu may solve the problem) !'])
0060         end
0061     else
0062         Zmask_f0_t{ir} = logical(ones(1,nmhu));%All electrons are selected
0063         ns_f(ir) = 0;%Number of mhu values that are removed for implicit bounce averaged calculations
0064     end
0065 %
0066     blocksize_f_t(ir) = (nmhu-ns_f(ir))*npn;%For supermatrix construction
0067     blocksize_T_f_t(ir) = (nmhu-ns_f(ir))*npn;%For supermatrix construction
0068 end
0069 %
0070 if dke_mode == 1,
0071     for ir_dke = 1:nr_dke,
0072         jr2 = rdke(ir_dke);
0073         Zmask_g{ir_dke} = Zmask_f0_P{jr2};%Passing electrons are selected
0074         ns_g(ir_dke)= max(find(~Zmask_g{ir_dke})) - min(find(~Zmask_g{ir_dke})) + 1;%number of mhu values that are removed
0075 %
0076         blocksize_tp(ir_dke) = nmhu*npn;    
0077         blocksize_g_t(ir_dke) = (nmhu-ns_g(ir_dke))*npn;
0078     end
0079 %
0080     nMMXP_tp = max(cumsum(blocksize_tp));
0081     nMMH_tp = npn*nmhu*nr;
0082     nMMXP_g_t = max(cumsum(blocksize_g_t));
0083 %
0084     MMXP_tp = [];
0085     MMH_tp = sparse(nMMH_tp,nMMH_tp);
0086     MMXP_g_t = [];
0087 %
0088     sm_tp = zeros(1,nr_dke+1);
0089     sm_g = zeros(1,nr_dke+1);
0090 end
0091 %
0092 if bounce_mode == 1,
0093    Zbouncecoef.Zmask_f0_P = Zmask_f0_P;
0094    Zbouncecoef.Zmask_f0_Tm = Zmask_f0_Tm;
0095    Zbouncecoef.Zmask_f0_Tp = Zmask_f0_Tp;
0096    Zbouncecoef.Zmask_f0_t_P = Zmask_f0_t_P;
0097    Zbouncecoef.Zmask_f0_t_Tp = Zmask_f0_t_Tp;
0098    Zbouncecoef.jmhut_min = jmhut_min;
0099    Zbouncecoef.jmhut_max = jmhut_max;
0100    Zbouncecoef.djmhut = djmhut;
0101 else
0102    Zbouncecoef.Zmask_f0_P = [];
0103    Zbouncecoef.Zmask_f0_Tm = [];
0104    Zbouncecoef.Zmask_f0_Tp =[];
0105    Zbouncecoef.Zmask_f0_t_P = [];
0106    Zbouncecoef.Zmask_f0_t_Tp = [];
0107    Zbouncecoef.jmhut_min = [];
0108    Zbouncecoef.jmhut_max = [];
0109    Zbouncecoef.djmhut = [];  
0110 end
0111 %
0112 Zbouncecoef.sm_f = sm_f;
0113 Zbouncecoef.sm_T_f = sm_T_f;
0114 Zbouncecoef.Zmask_f0_t = Zmask_f0_t;
0115 Zbouncecoef.ns_f = ns_f;
0116 %
0117 if dke_mode == 1,
0118     Zbouncecoef.Zmask_g = Zmask_g;%Passing electrons are selected
0119     Zbouncecoef.ns_g = ns_g;%number of mhu values that are removed
0120 %
0121     Zbouncecoef.blocksize_tp = blocksize_tp;    
0122     Zbouncecoef.blocksize_g_t = blocksize_g_t;
0123 %
0124     Zbouncecoef.nMMXP_tp = nMMXP_tp;
0125     Zbouncecoef.nMMH_tp = nMMH_tp;
0126     Zbouncecoef.nMMXP_g_t = nMMXP_g_t;
0127 %
0128     Zbouncecoef.MMXP_tp = MMXP_tp;
0129     Zbouncecoef.MMH_tp = MMH_tp;
0130     Zbouncecoef.MMXP_g_t = MMXP_g_t;
0131 %
0132     Zbouncecoef.sm_tp = sm_tp;
0133     Zbouncecoef.sm_g = sm_g;
0134 else
0135     Zbouncecoef.Zmask_g = [];
0136     Zbouncecoef.ns_g = [];
0137 %
0138     Zbouncecoef.blocksize_tp = [];    
0139     Zbouncecoef.blocksize_g_t = [];
0140 %
0141     Zbouncecoef.nMMXP_tp = [];
0142     Zbouncecoef.nMMH_tp = [];
0143     Zbouncecoef.nMMXP_g_t = [];
0144 %
0145     Zbouncecoef.MMXP_tp = [];
0146     Zbouncecoef.MMH_tp = [];
0147     Zbouncecoef.MMXP_g_t = [];
0148 %
0149     Zbouncecoef.sm_tp = [];
0150     Zbouncecoef.sm_g = [];
0151 end
0152 %
0153 Zbouncecoef.blocksize_f_t = blocksize_f_t;
0154 Zbouncecoef.blocksize_T_f_t = blocksize_T_f_t;
0155 %
0156 Zbouncecoef.xq = xq;
0157 Zbouncecoef.xqtilde = xqtilde;
0158 Zbouncecoef.xqbar = xqbar;
0159 Zbouncecoef.xqhat = xqhat;
0160 Zbouncecoef.xqcronos = xqcronos;
0161 %
0162 Zbouncecoef.XXheaviside = XXheaviside;
0163 Zbouncecoef.XXheaviside_p = XXheaviside_p;
0164 Zbouncecoef.XXheaviside_m = XXheaviside_m;
0165 Zbouncecoef.Xxlambda = Xxlambda;
0166 Zbouncecoef.Xxlambda_p = Xxlambda_p;
0167 Zbouncecoef.Xxlambda_m = Xxlambda_m;
0168 Zbouncecoef.XXlambda = XXlambda;
0169 Zbouncecoef.XXRlambda_m = XXRlambda_m;
0170 Zbouncecoef.XXRlambda_p = XXRlambda_p;
0171 Zbouncecoef.XXlambda_p2m1 = XXlambda_p2m1;
0172 Zbouncecoef.XXRlambda_p2m1_m = XXRlambda_p2m1_m;
0173 Zbouncecoef.XXRlambda_p2m1_p = XXRlambda_p2m1_p;
0174 Zbouncecoef.XXRlambda_p0p3 = XXRlambda_p0p3;
0175 Zbouncecoef.XXRlambda_p2p2_m = XXRlambda_p2p2_m;
0176 Zbouncecoef.XXRlambda_p2p2_p = XXRlambda_p2p2_p;
0177 Zbouncecoef.XXlambda_p2m2p2 = XXlambda_p2m2p2;
0178 Zbouncecoef.XXRlambda_b_p1p1 = XXRlambda_b_p1p1;
0179 Zbouncecoef.XXlambda_b_p1m1p2 = XXlambda_b_p1m1p2;
0180 Zbouncecoef.XXRlambda_b_p1m1p2 = XXRlambda_b_p1m1p2;
0181 Zbouncecoef.XXRlambda_b_p1m1p2_m = XXRlambda_b_p1m1p2_m;
0182 Zbouncecoef.XXRlambda_b_p1m1p2_p = XXRlambda_b_p1m1p2_p;
0183 Zbouncecoef.XXlambda_b_p1m1 = XXlambda_b_p1m1;
0184 Zbouncecoef.XXRlambda_b_p1m1 = XXRlambda_b_p1m1;
0185 Zbouncecoef.XXRlambda_b_p1m1_m = XXRlambda_b_p1m1_m;
0186 Zbouncecoef.XXRlambda_b_p1m1_p = XXRlambda_b_p1m1_p;
0187 Zbouncecoef.XXRlambda_b_p1m2_m = XXRlambda_b_p1m2_m;
0188 Zbouncecoef.XXRlambda_b_p1m2_p = XXRlambda_b_p1m2_p;
0189 Zbouncecoef.XXlambda_b_p2m2p2 = XXlambda_b_p2m2p2;
0190 Zbouncecoef.XXRlambda_b_p2m2p2 = XXRlambda_b_p2m2p2;
0191 Zbouncecoef.XXRlambda_b_p2m2p2_m = XXRlambda_b_p2m2p2_m;
0192 Zbouncecoef.XXRlambda_b_p2m2p2_p = XXRlambda_b_p2m2p2_p;
0193 Zbouncecoef.XXlambda_b_p3m2 = XXlambda_b_p3m2;
0194 Zbouncecoef.XXRlambda_b_p3m2_m = XXRlambda_b_p3m2_m;
0195 Zbouncecoef.XXRlambda_b_p3m2_p = XXRlambda_b_p3m2_p;
0196 Zbouncecoef.XXlambda_b_p2 = XXlambda_b_p2;
0197 Zbouncecoef.XXlambda_b_p1m3p4 = XXlambda_b_p1m3p4;
0198 Zbouncecoef.XXlambda_b_p1m2p2 = XXlambda_b_p1m2p2;
0199 
0200 
0201 
0202 
0203 
0204 
0205 
0206

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