build_f0struct_yp

PURPOSE ^

SYNOPSIS ^

function f0struct = build_f0struct_yp(dke_out,momentumDKE,equilDKE,mksa,mode,method,ngrid,nharm)

DESCRIPTION ^

 Build vectorial tokamak magnetic equilibrium from its numerical counterpart
 Two operating modes :
 1) Spline-Fourier description for (psi,theta) magnetic equilibrium (HELENA for example)

    1-D: use interp1.m MatLab built-in function (Hermite polynomials (pchip), spline, linear,  nearest,...)
    2-D: use Fourier series expansion for the poloidal dependence and the
    interp1.m for the Fourier series coefficients (Hermite polynomials (pchip), spline, linear,
    nearest,...)

 2) Spline-Spline description for (x,y) magnetic equilibrium (EFIT for example)

    1-D: use interp1.m MatLab built-in function (Hermite polynomials (pchip), spline, linear, nearest,...)
    2-D: use interp1.m for the x-direction and the interp1.m again for the coefficients of the 
    previous spline (Hermite polynomials (pchip), spline, linear, nearest,...)

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function f0struct = build_f0struct_yp(dke_out,momentumDKE,equilDKE,mksa,mode,method,ngrid,nharm)
0002 %
0003 % Build vectorial tokamak magnetic equilibrium from its numerical counterpart
0004 % Two operating modes :
0005 % 1) Spline-Fourier description for (psi,theta) magnetic equilibrium (HELENA for example)
0006 %
0007 %    1-D: use interp1.m MatLab built-in function (Hermite polynomials (pchip), spline, linear,  nearest,...)
0008 %    2-D: use Fourier series expansion for the poloidal dependence and the
0009 %    interp1.m for the Fourier series coefficients (Hermite polynomials (pchip), spline, linear,
0010 %    nearest,...)
0011 %
0012 % 2) Spline-Spline description for (x,y) magnetic equilibrium (EFIT for example)
0013 %
0014 %    1-D: use interp1.m MatLab built-in function (Hermite polynomials (pchip), spline, linear, nearest,...)
0015 %    2-D: use interp1.m for the x-direction and the interp1.m again for the coefficients of the
0016 %    previous spline (Hermite polynomials (pchip), spline, linear, nearest,...)
0017 %
0018 % By Yves Peysson (CEA-DRFC, yves.peysson@cea.fr) and Joan Decker (CEA-DRFC, joan.decker@cea.fr)
0019 %
0020 if nargin < 4, 
0021     error('Wrong number of input arguments in build_f0struct_yp.m');
0022 end
0023 %
0024 if nargin == 4, 
0025     mode = 1;%Spline-Fourier case
0026     method = 'pchip';
0027     ngrid = 200;
0028     nharm = [];
0029 end
0030 %
0031 if nargin == 5, 
0032     method = 'pchip';
0033     ngrid = 200;
0034     nharm = [];
0035 end
0036 %
0037 if nargin == 6, 
0038     ngrid = 200;  
0039     nharm = [];
0040 end
0041 %
0042 if nargin == 7, 
0043     nharm = [];%For Spline-Fourier case only
0044 end
0045 %
0046 f0struct.ne_ref = mksa.ne_ref;
0047 f0struct.betath_ref = mksa.betath_ref;
0048 %
0049 f0struct.pn = momentumDKE.pn;
0050 f0struct.mhu = momentumDKE.mhu;
0051 %
0052 if mode == 1,
0053     %
0054     srho = linspace(0,1,ngrid).^2;
0055     %
0056     sBx = interp1(equilDKE.xrho,equilDKE.XBx,srho,method);%Bx field component
0057     sBy = interp1(equilDKE.xrho,equilDKE.XBy,srho,method);%By field component
0058     sBphi = interp1(equilDKE.xrho,equilDKE.XBphi,srho,method);%PHI field component
0059     %
0060     sB = sqrt(sBx.*sBx + sBy.*sBy + sBphi.*sBphi);%Module of the total magnetic field
0061     sB0 = interp1(equilDKE.xrho,equilDKE.xB0(:)*ones(1,length(equilDKE.mtheta)),srho,method);%Module of the total magnetic field at theta = 0 (where it is minimum)
0062     sPSI = sB./sB0;
0063     %
0064     f0struct.PSI_fit = interpequilpt_yp(method,sPSI,srho,equilDKE.mtheta,nharm);
0065     %
0066     sXXf0 = interp1(equilDKE.xrho,reshape(dke_out.XXf0{end},length(momentumDKE.pn)*length(momentumDKE.mhu),length(equilDKE.xrho))',srho,method);
0067     f0struct.XXf0_fit = interpequilpt_yp(method,sXXf0',srho);
0068     %
0069 else
0070    error('XY equilibrium is not yet implemented for f0struct interpolation.');
0071 end
0072 
0073

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