coll_dke_jd

PURPOSE ^

LUKE - collision operators calculations

SYNOPSIS ^

function [ZXXD_c,ZXXF_c,ZXXD_c_tp,ZXXF_c_tp,XXfM,XXILor] = coll_dke_jd(dkepath,dkeparam,dkedisplay,equilDKE,mksa,gridDKE,Zmomcoef,Zbouncecoef);

DESCRIPTION ^

LUKE - collision operators calculations

Collision operators calculations (e-e, e-i)

by Yves Peysson (CEA-IRFM,yves.peysson@cea.fr) and Joan Decker (CEA-IRFM,joan.decker@cea.fr) and

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ZXXD_c,ZXXF_c,ZXXD_c_tp,ZXXF_c_tp,XXfM,XXILor] = coll_dke_jd(dkepath,dkeparam,dkedisplay,equilDKE,mksa,gridDKE,Zmomcoef,Zbouncecoef);
0002 %LUKE - collision operators calculations
0003 %
0004 %Collision operators calculations (e-e, e-i)
0005 %
0006 %by Yves Peysson (CEA-IRFM,yves.peysson@cea.fr) and Joan Decker (CEA-IRFM,joan.decker@cea.fr) and
0007 %
0008     etime_coll = 0;
0009     time0 = clock;
0010     %
0011     %load([fullfile(dkepath.temppath,'temp_DKE.mat'],'ZXXD_c','ZXXF_c','ZXXD_c_tp','ZXXF_c_tp','XXfM','XXILor');
0012     %
0013     if exist('XXfM') == 1, %The bounce averaging coefficients were calculated before.
0014           %
0015         %load([fullfile(dkepath.temppath,'temp_DKE.mat'],'ZXXD_c','ZXXF_c','ZXXD_c_tp','ZXXF_c_tp','XXfM','XXILor')
0016           %
0017         if dkedisplay.display_mode >= 1,info_dke_yp(2,['Collision flux coefficients retrieved.']);end    
0018         %
0019     else
0020         [xTe_norm,xne_norm,xzni_norm,xzTi_norm,xnloss_norm,xbetath,xlnc_e,xnhu,xrnhuth] = normcoef_dke_yp(mksa,equilDKE,gridDKE);
0021         %
0022         % Output files initialization
0023         %
0024         XXfM = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0025         %
0026         % Terms from Sp at l+1/2 (Notations: _imj -> (i,j+1+2);_ipj -> (i+1,j+1/2)
0027         %
0028           ZXXD_c.pp_ipj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0029           ZXXD_c.pp_imj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0030          ZXXD_c.pm_ipj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0031          ZXXD_c.pm_imj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0032          ZXXD_c.pr_ipj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0033          ZXXD_c.pr_imj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0034         %
0035           ZXXF_c.p_ipj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0036           ZXXF_c.p_imj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0037         %
0038         % Terms from Sksi at l+1/2 (Notations: _ijp -> (i+1/2,j+1);_ijm -> (i+1/2,j)
0039         %
0040          ZXXD_c.mm_ijp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0041          ZXXD_c.mm_ijm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0042          ZXXD_c.mp_ijp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0043           ZXXD_c.mp_ijm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0044          ZXXD_c.mr_ijp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0045           ZXXD_c.mr_ijm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0046         %
0047           ZXXF_c.m_ijp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0048           ZXXF_c.m_ijm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%momentum dynamics only
0049         %
0050         % Terms from Spsi at (i+1/2,j+1/2) (Notations: _lm -> (l);_lp -> (l+1);
0051         %
0052          ZXXD_c.rr_lm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%radial dynamics only
0053          ZXXD_c.rr_lp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%radial dynamics only
0054          ZXXD_c.rp_lm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0055           ZXXD_c.rp_lp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0056          ZXXD_c.rm_lm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0057           ZXXD_c.rm_lp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0058         %
0059           ZXXF_c.r_lm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%radial dynamics only
0060           ZXXF_c.r_lp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);%radial dynamics only
0061         %
0062         % Terms used by the old scheme only for momentum cross-derivatives (M.
0063         % Shoucri and I. Shkarofsky,Comp. Phys. Comm., 82 (1994) 287)
0064         %
0065         ZXXD_c.pp_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0066          ZXXD_c.pm_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0067          ZXXD_c.mp_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0068           ZXXF_c.p_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0069           %
0070         if dkeparam.dke_mode == 1
0071             %
0072             ZXXD_c_tp.pp_ippj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0073             ZXXD_c_tp.pp_ipj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0074             ZXXD_c_tp.pp_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0075             ZXXD_c_tp.pp_imj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0076             ZXXD_c_tp.pp_immj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0077             ZXXD_c_tp.pm_ipj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0078             ZXXD_c_tp.pm_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0079             ZXXD_c_tp.pm_imj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0080             ZXXD_c_tp.mp_ijp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0081             ZXXD_c_tp.mp_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0082             ZXXD_c_tp.mp_ijm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0083             ZXXD_c_tp.mm_ijp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0084             ZXXD_c_tp.mm_ijm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0085             %
0086             ZXXF_c_tp.p_ippj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0087             ZXXF_c_tp.p_ipj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0088             ZXXF_c_tp.p_ij = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0089             ZXXF_c_tp.p_imj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0090             ZXXF_c_tp.p_immj = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0091             ZXXF_c_tp.m_ijp = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0092             ZXXF_c_tp.m_ijm = zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr_dke);
0093         else
0094             ZXXD_c_tp = NaN;
0095             ZXXF_c_tp = NaN;        
0096         end
0097         %
0098         if isfield(dkeparam.clustermode,'coll_dke_jd') && isfield(dkeparam.clustermode.coll_dke_jd,'scheduler') && dkeparam.clustermode.coll_dke_jd.scheduler.mode,
0099             for ir = 1:gridDKE.nr,arg_range{ir} = ir;end
0100             [dkecluster] = clustermode_luke(dkeparam.clustermode,'coll_dke_jd',dkepath); 
0101             [flag,XXfM_out,ZXXD_c_pp_ipj,ZXXD_c_pp_ij,ZXXD_c_pp_imj,ZXXD_c_mm_ijp,ZXXD_c_mm_ijm,ZXXF_c_p_ipj,ZXXF_c_p_ij,ZXXF_c_p_imj] = mdce_run(@loop_coll_dke_jd1,{ir,gridDKE,Zmomcoef,Zbouncecoef,equilDKE,mksa,dkepath,dkeparam,xTe_norm,xne_norm,xzni_norm,xzTi_norm,xnloss_norm,xbetath,xlnc_e,xnhu,xrnhuth},1,arg_range,dkecluster);            
0102             for ir = 1:gridDKE.nr
0103                 XXfM(:,:,ir) = XXfM_out{ir};
0104                 ZXXD_c.pp_ipj(:,:,ir) = ZXXD_c_pp_ipj{ir};
0105                 ZXXD_c.pp_ij(:,:,ir) = ZXXD_c_pp_ij{ir};
0106                 ZXXD_c.pp_imj(:,:,ir) = ZXXD_c_pp_imj{ir};
0107                 ZXXD_c.mm_ijp(:,:,ir) = ZXXD_c_mm_ijp{ir};
0108                 ZXXD_c.mm_ijm(:,:,ir) = ZXXD_c_mm_ijm{ir};
0109                 %
0110                 ZXXF_c.p_ipj(:,:,ir) = ZXXF_c_p_ipj{ir};
0111                 ZXXF_c.p_ij(:,:,ir) = ZXXF_c_p_ij{ir};
0112                 ZXXF_c.p_imj(:,:,ir) = ZXXF_c_p_imj{ir};
0113              end
0114             %
0115             if dkeparam.dke_mode == 1
0116                 for ir = 1:gridDKE.nr,arg_range{ir} = ir;end    
0117                 [dkecluster] = clustermode_luke(dkeparam.clustermode,'coll_dke_jd',dkepath); 
0118                 [flag,ZXXD_c_tp_pp_ippj,ZXXD_c_tp_pp_ipj,ZXXD_c_tp_pp_ij,ZXXD_c_tp_pp_imj,ZXXD_c_tp_pp_immj,ZXXD_c_tp_mm_ijp,ZXXD_c_tp_mm_ijm,ZXXF_c_tp_p_ippj,ZXXF_c_tp_p_ipj,ZXXF_c_tp_p_ij,ZXXF_c_tp_p_im,ZXXF_c_tp_p_immj,ZXXF_c_tp_m_ijp,ZXXF_c_tp_m_ijm] = mdce_run(@loop_coll_dke_jd2,{ir,gridDKE,Zbouncecoef,ZXXD_c,dkeparam},1,arg_range,dkecluster);
0119                    %
0120                    for ir = 1:gridDKE.nr,
0121                     ir_dke = find(ir == gridDKE.rdke);
0122                     if ~isempty(ir_dke)
0123                         ZXXD_c_tp.pp_ippj(:,:,ir_dke) = ZXXD_c_tp_pp_ippj{ir};
0124                         ZXXD_c_tp.pp_ipj(:,:,ir_dke) = ZXXD_c_tp_pp_ipj{ir};
0125                         ZXXD_c_tp.pp_ij(:,:,ir_dke) = ZXXD_c_tp_pp_ij{ir};
0126                         ZXXD_c_tp.pp_imj(:,:,ir_dke) = ZXXD_c_tp_pp_imj{ir};
0127                         ZXXD_c_tp.pp_immj(:,:,ir_dke) = ZXXD_c_tp_pp_immj{ir};
0128                         ZXXD_c_tp.mm_ijp(:,:,ir_dke) = ZXXD_c_tp_mm_ijp{ir};
0129                         ZXXD_c_tp.mm_ijm(:,:,ir_dke) = ZXXD_c_tp_mm_ijm{ir};
0130                         %
0131                         ZXXF_c_tp.p_ippj(:,:,ir_dke) = ZXXF_c_tp_p_ippj{ir};
0132                         ZXXF_c_tp.p_ipj(:,:,ir_dke) = ZXXF_c_tp_p_ipj{ir};
0133                         ZXXF_c_tp.p_ij(:,:,ir_dke) = ZXXF_c_tp_p_ij{ir};
0134                         ZXXF_c_tp.p_im(:,:,ir_dke) = ZXXF_c_tp_p_im{ir};
0135                         ZXXF_c_tp.p_immj(:,:,ir_dke) = ZXXF_c_tp_p_immj{ir};
0136                         ZXXF_c_tp.m_ijp(:,:,ir_dke) = ZXXF_c_tp_m_ijp{ir};
0137                         ZXXF_c_tp.m_ijm(:,:,ir_dke)= ZXXF_c_tp_m_ijm{ir};
0138                     end
0139                 end
0140             end
0141         else
0142               %
0143             for ir = 1:gridDKE.nr,
0144                 [XXfM(:,:,ir),ZXXD_c.pp_ipj(:,:,ir),ZXXD_c.pp_ij(:,:,ir),ZXXD_c.pp_imj(:,:,ir),ZXXD_c.mm_ijp(:,:,ir),ZXXD_c.mm_ijm(:,:,ir),ZXXF_c.p_ipj(:,:,ir),ZXXF_c.p_ij(:,:,ir),ZXXF_c.p_imj(:,:,ir)] = loop_coll_dke_jd1(ir,gridDKE,Zmomcoef,Zbouncecoef,equilDKE,mksa,dkepath,dkeparam,xTe_norm,xne_norm,xzni_norm,xzTi_norm,xnloss_norm,xbetath,xlnc_e,xnhu,xrnhuth);
0145             end
0146             %
0147             if dkeparam.dke_mode == 1
0148                 %
0149                 for ir = 1:gridDKE.nr,
0150                     ir_dke = find(ir == gridDKE.rdke);
0151                     if ~isempty(ir_dke)
0152                         [ZXXD_c_tp.pp_ippj(:,:,ir_dke),ZXXD_c_tp.pp_ipj(:,:,ir_dke),ZXXD_c_tp.pp_ij(:,:,ir_dke),ZXXD_c_tp.pp_imj(:,:,ir_dke),ZXXD_c_tp.pp_immj(:,:,ir_dke),ZXXD_c_tp.mm_ijp(:,:,ir_dke),ZXXD_c_tp.mm_ijm(:,:,ir_dke),ZXXF_c_tp.p_ippj(:,:,ir_dke),ZXXF_c_tp.p_ipj(:,:,ir_dke),ZXXF_c_tp.p_ij(:,:,ir_dke),ZXXF_c_tp.p_im(:,:,ir_dke),ZXXF_c_tp.p_immj(:,:,ir_dke),ZXXF_c_tp.m_ijp(:,:,ir_dke),ZXXF_c_tp.m_ijm(:,:,ir_dke)] = loop_coll_dke_jd2(ir,gridDKE,Zbouncecoef,ZXXD_c,dkeparam);
0153                     end
0154                 end            
0155             end
0156         end
0157         %
0158         %Pitch-angle integral for the Lorentz model (test mode only and initial guess for the drift kinetic equation, see documentation)
0159         %
0160         XXILor =  zeros(gridDKE.npn,gridDKE.nmhu,gridDKE.nr);
0161         for ir_dke = 1:gridDKE.nr_dke,
0162             jr2 = gridDKE.rdke(ir_dke);
0163             if dkeparam.bounce_mode == 1
0164                 ILor_p = Zbouncecoef.Zmask_f0_P{jr2}.*sum(((gridDKE.dmhu.*(gridDKE.mhu>=0).*Zbouncecoef.XXlambda_b_p3m2(1,:,jr2)./Zbouncecoef.XXlambda_p2m1(1,:,jr2))'*ones(1,gridDKE.nmhu)).*triu(ones(gridDKE.nmhu,gridDKE.nmhu)));
0165                 ILor_m = fliplr(ILor_p);
0166                 ILor = ILor_m + ILor_p;
0167                 XXILor(:,:,jr2) = ones(gridDKE.npn,1)*ILor;
0168             else
0169                 XXILor(:,:,jr2) = zeros(gridDKE.npn,gridDKE.nmhu);
0170             end 
0171         end 
0172         %
0173         %  save([fullfile(dkepath.temppath,'temp_DKE.mat'],'ZXXD_c','ZXXF_c','ZXXD_c_tp','ZXXF_c_tp','XXfM','XXILor','-append');
0174         %
0175         etime_coll = etime_coll + etime(clock,time0);
0176         if dkedisplay.display_mode >= 1,info_dke_yp(2,['Collision flux coefficients calculations done in ',num2str(etime_coll),' (s)']);end    
0177         %
0178     end
0179 end
0180 
0181

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