interp_legendre_yp

PURPOSE ^

LUKE: Perform a projection of the distribution function on the Legendre polynomial basis ( for data compression)

SYNOPSIS ^

function [XXf0_interp,normfinterp] = interp_legendre_yp(dkeparam,gridDKE,XXf0,test)

DESCRIPTION ^

 LUKE: Perform a projection of the distribution function on the Legendre polynomial basis ( for data compression)

 Compact input LUKE data structure (LUKE_RESULTS or LUKE_DATA) by performing a projection of the distribution function on the Legendre polynomial basis

   INPUTS:
   
       - dkeparam: LUKE parameter structure
       - gridDKE: LUKE grid structure 
       - XXf0: initial distribution function. May be an array cell
       - test: check the projection with the normalization
       
   OUTPUTS:
   
      - XXf0_interp: projected Legendre polynomial structure

 by Yves Peysson(CEA/IRFM, yves.peysson@cea.fr) and Joan Decker (EPFL/CRPP, joan.decker@epfl.ch)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [XXf0_interp,normfinterp] = interp_legendre_yp(dkeparam,gridDKE,XXf0,test)
0002 % LUKE: Perform a projection of the distribution function on the Legendre polynomial basis ( for data compression)
0003 %
0004 % Compact input LUKE data structure (LUKE_RESULTS or LUKE_DATA) by performing a projection of the distribution function on the Legendre polynomial basis
0005 %
0006 %   INPUTS:
0007 %
0008 %       - dkeparam: LUKE parameter structure
0009 %       - gridDKE: LUKE grid structure
0010 %       - XXf0: initial distribution function. May be an array cell
0011 %       - test: check the projection with the normalization
0012 %
0013 %   OUTPUTS:
0014 %
0015 %      - XXf0_interp: projected Legendre polynomial structure
0016 %
0017 % by Yves Peysson(CEA/IRFM, yves.peysson@cea.fr) and Joan Decker (EPFL/CRPP, joan.decker@epfl.ch)
0018 %
0019 if nargin < 4,
0020     test = 0;
0021 end
0022 %
0023 normfinterp = [];
0024 %
0025 n_pol = dkeparam.n_gauleg;%Necessary for accurate reconstruction at ksi = -1
0026 [x_leg,w_leg] = gauleg_dke_yp(dkeparam.n_gauleg,dkeparam.epsi_gauleg);%Gauss-Legendre abscissa and weigth calculations between -1 and + 1
0027 [Pm,cL] = leg_dke_yp(x_leg(:)',n_pol);%Legendre polynomial calculation
0028 %
0029 if iscell(XXf0),
0030     for it = 1:length(XXf0),
0031         XXf0_interp{it} = finterp_legendre_yp(Pm,x_leg,w_leg,cL,dkeparam.method,gridDKE.mhu,XXf0{it});
0032     end
0033 else
0034     XXf0_interp = finterp_legendre_yp(Pm,x_leg,w_leg,cL,dkeparam.method,gridDKE.mhu,XXf0);
0035 end
0036 %
0037 % Distribution function reconstruction test
0038 %
0039 if test,
0040     if iscell(XXf0_interp)
0041         for it = 1:length(XXf0_interp),
0042             normfinterp(it) = test_finterp_legendre_yp(Pm,x_leg,cL,dkeparam.method,gridDKE.pn2,gridDKE.dpn,gridDKE.mhu,XXf0{it},XXf0_interp{it});
0043         end
0044     else
0045         normfinterp = test_finterp_legendre_yp(Pm,x_leg,cL,dkeparam.method,gridDKE.pn2,gridDKE.dpn,gridDKE.mhu,XXf0,XXf0_interp);
0046     end
0047 end
0048 %
0049 end
0050 
0051 function XXf0_leg = finterp_legendre_yp(Pm,x_leg,w_leg,cL,method,mhu,XXf0)
0052     %
0053     XXf0_leg = zeros(size(XXf0,1),length(cL),size(XXf0,3));
0054     %
0055     for ir = 1:size(XXf0,3),%radial position
0056         XXf0_leg(:,:,ir) = (interp1(mhu(:),XXf0(:,:,ir)',x_leg(:),method)'.*(w_leg*ones(1,size(XXf0,1)))')*Pm';%Calculation of the Legendre coefficients for local values of the distribution function
0057     end
0058     %
0059 end
0060 
0061 function normfinterp = test_finterp_legendre_yp(Pm,x_leg,cL,method,pn2,dpn,mhu,XXf0,XXf0_leg)
0062     %
0063     for ir = 1:size(XXf0_leg,3),
0064         Xf0_i1 = (Pm.'*(XXf0_leg(:,:,ir).*(ones(size(XXf0_leg(:,:,ir),1),1)*cL.')).').';%Distribution function on the Legendre polynomials pitch-angle grid back calculated
0065         Xf0_i2 = interp1(x_leg(:),Xf0_i1.',mhu(:),method).';%Distribution function on initial pitch-angle grid back calculated from Legendre polynomial fit
0066         normfinterp.norm0(ir) = 2*pi*integral_dke_jd(dpn.',pn2.'.*trapz_dke_yp([mhu(:),XXf0(:,:,ir).']).',1);%initial normalization
0067         normfinterp.normi1(ir) = 2*pi*integral_dke_jd(dpn.',pn2.'.*trapz_dke_yp([x_leg(:),Xf0_i1.']).',1);%normamization with Legendre pitch-angle grid
0068         normfinterp.normi2(ir) = 2*pi*integral_dke_jd(dpn.',pn2.'.*trapz_dke_yp([mhu(:),Xf0_i2.']).',1);%normalization from fitted distribution
0069     end
0070     %
0071 end
0072

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