calcval_yp

PURPOSE ^

SYNOPSIS ^

function [varargout] = calcval_yp(fit,theta,a0,an,bn,da0drho,dandrho,dbndrho,d2a0drho2,d2andrho2,d2bndrho2)

DESCRIPTION ^

 Calculate the local interpolated value at any poloidal angle position

 INPUT
    - fit: interpolated structure
    - poloidal angle value (rad) [1,1], can be up to 3D
    - a0,an,bn: Fourier expansion coefficients
    - da0drho,dandrho,dbndrho: 1st order radial derivatives of the Fourier expansion coefficients
    - d2a0drho2,d2andrho2,d2bndrho2: 2nd order radial derivatives of the Fourier expansion coefficients

 OUTPUT: 
    - X: value at position (rho,theta) [1,1]
    - dXdtheta: value of the first order poloidal derivatives at position (rho,theta) [1,1]
    - d2Xdtheta2: value of the second order poloidal derivatives at position (rho,theta) [1,1]
    - dXdrho: value of the first order radial derivatives at position (rho,theta) [1,1]
    - d2Xdthetadrho: value of the second order poloidal and radial cross-derivatives at position (rho,theta) [1,1]
    - d2Xdrho2: value of the second order poloidal and radial cross-derivatives at position (rho,theta) [1,1]

 By Yves Peysson (CEA-IRFM, yves.peysson@cea.fr), Joan Decker (CEA-IRFM, joan.decker@cea.fr), Emelie Nilsson (CEA-IRFM, emelie.nilsson@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [varargout] = calcval_yp(fit,theta,a0,an,bn,da0drho,dandrho,dbndrho,d2a0drho2,d2andrho2,d2bndrho2)
0002 %
0003 % Calculate the local interpolated value at any poloidal angle position
0004 %
0005 % INPUT
0006 %    - fit: interpolated structure
0007 %    - poloidal angle value (rad) [1,1], can be up to 3D
0008 %    - a0,an,bn: Fourier expansion coefficients
0009 %    - da0drho,dandrho,dbndrho: 1st order radial derivatives of the Fourier expansion coefficients
0010 %    - d2a0drho2,d2andrho2,d2bndrho2: 2nd order radial derivatives of the Fourier expansion coefficients
0011 %
0012 % OUTPUT:
0013 %    - X: value at position (rho,theta) [1,1]
0014 %    - dXdtheta: value of the first order poloidal derivatives at position (rho,theta) [1,1]
0015 %    - d2Xdtheta2: value of the second order poloidal derivatives at position (rho,theta) [1,1]
0016 %    - dXdrho: value of the first order radial derivatives at position (rho,theta) [1,1]
0017 %    - d2Xdthetadrho: value of the second order poloidal and radial cross-derivatives at position (rho,theta) [1,1]
0018 %    - d2Xdrho2: value of the second order poloidal and radial cross-derivatives at position (rho,theta) [1,1]
0019 %
0020 % By Yves Peysson (CEA-IRFM, yves.peysson@cea.fr), Joan Decker (CEA-IRFM, joan.decker@cea.fr), Emelie Nilsson (CEA-IRFM, emelie.nilsson@cea.fr)
0021 %
0022 if isfield(fit,'x_fit'), fit = fit.x_fit;end%backward compatibility with equilfit_yp
0023 %
0024 if nargin ~= 11 & nargin ~= 8 & nargin ~= 5,error('Wrong number of input arguments in calcval_yp.m');end
0025 %
0026 if size(an,2) ~= size(fit.n,1), an = an.';end
0027 if size(bn,2) ~= size(fit.n,1), bn = bn.';end 
0028 %
0029 if nargin >= 8,
0030     if size(dandrho,2) ~= size(fit.n,1), dandrho = dandrho.';end
0031     if size(dbndrho,2) ~= size(fit.n,1), dbndrho = dbndrho.';end 
0032 end
0033 %
0034 if nargin == 11,
0035     if size(d2andrho2,2) ~= size(fit.n,1), d2andrho2 = d2andrho2.';end
0036     if size(d2bndrho2,2) ~= size(fit.n,1), d2bndrho2 = d2bndrho2.';end 
0037 end
0038 %
0039 n = fit.n;
0040 %
0041 Xa0 = repmat(a0(:),[1,size(theta,1),size(theta,2)]);
0042 %
0043 Zan = repmat(an,[1,1,size(theta,1),size(theta,2)]);
0044 Zbn = repmat(bn,[1,1,size(theta,1),size(theta,2)]);
0045 %
0046 Zn = permute(repmat(n(:),[1,size(a0(:),1),size(theta,1),size(theta,2)]),[2,1,3,4]);
0047 %
0048 Ztheta = permute(repmat(theta,[1,1,size(a0(:),1),size(n(:),1)]),[3,4,1,2]);
0049 %
0050 X = squeeze(Xa0) + squeeze(sum(Zan.*cos(Zn.*Ztheta),2)) + squeeze(sum(Zbn.*sin(Zn.*Ztheta),2));
0051 dXdtheta = -squeeze(sum(Zan.*(Zn.*sin(Zn.*Ztheta)),2)) + squeeze(sum(Zbn.*(Zn.*cos(Zn.*Ztheta)),2));
0052 d2Xdtheta2 = -squeeze(sum(Zan.*(Zn.^2.*cos(Zn.*Ztheta)),2)) - squeeze(sum(Zbn.*(Zn.^2.*sin(Zn.*Ztheta)),2));
0053 %
0054 if nargin >= 8,
0055     if ~isempty(da0drho) & ~isempty(dandrho) & ~isempty(dbndrho),
0056         %
0057         Xda0drho = repmat(da0drho(:),[1,size(theta,1),size(theta,2)]);
0058         Zdandrho = repmat(dandrho,[1,1,size(theta,1),size(theta,2)]);
0059         Zdbndrho = repmat(dbndrho,[1,1,size(theta,1),size(theta,2)]);
0060         %
0061         dXdrho = squeeze(Xda0drho) + squeeze(sum(Zdandrho.*cos(Zn.*Ztheta),2)) + squeeze(sum(Zdbndrho.*sin(Zn.*Ztheta),2));
0062         d2Xdthetadrho = squeeze(sum(-Zdandrho.*(Zn.*sin(Zn.*Ztheta)),2)) + squeeze(sum(Zdbndrho.*(Zn.*cos(Zn.*Ztheta)),2));%
0063         %
0064     else
0065         %
0066         dXdrho = [];
0067         d2Xdthetadrho = [];
0068         %
0069     end
0070 end
0071 %
0072 if nargin == 11,
0073     if ~isempty(d2a0drho2) & ~isempty(d2andrho2) & ~isempty(d2bndrho2),
0074         %
0075         Xd2a0drho2 = repmat(d2a0drho2(:),[1,size(theta,1),size(theta,2)]);
0076         Zd2andrho2 = repmat(d2andrho2,[1,1,size(theta,1),size(theta,2)]);
0077         Zd2bndrho2 = repmat(d2bndrho2,[1,1,size(theta,1),size(theta,2)]);
0078         %
0079         d2Xdrho2 = squeeze(Xd2a0drho2) + squeeze(sum(Zd2andrho2.*cos(Zn.*Ztheta),2)) + squeeze(sum(Zd2bndrho2.*sin(Zn.*Ztheta),2));
0080     else
0081         d2Xdrho2 = [];
0082     end
0083 end
0084 %
0085 if nargout >= 1 & nargin >=5, varargout{1} = X;end
0086 if nargout >= 2 & nargin >=5, varargout{2} = dXdtheta;end
0087 if nargout >= 3 & nargin >=5, varargout{3} = d2Xdtheta2;end
0088 if nargout >= 4 & nargin >= 8, varargout{4} = dXdrho;end
0089 if nargout >= 5 & nargin >= 8, varargout{5} = d2Xdthetadrho;end
0090 if nargout >= 6 & nargin == 11, varargout{6} = d2Xdrho2;end
0091 %
0092

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