Zlasmadisp_jd

PURPOSE ^

SYNOPSIS ^

function [Z_sn,Zp_sn,Zpp_sn] = Zlasmadisp_jd(zeta_sn,display_mode,NZ)

DESCRIPTION ^

 This function calculates the plasma dispersion function using mex files
 if they exist and a matlab function otherwise.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Z_sn,Zp_sn,Zpp_sn] = Zlasmadisp_jd(zeta_sn,display_mode,NZ)
0002 %
0003 % This function calculates the plasma dispersion function using mex files
0004 % if they exist and a matlab function otherwise.
0005 %
0006 if nargin < 3
0007     NZ = 10000;
0008 end
0009 %
0010 if nargin < 2
0011     display_mode = 0;
0012 end
0013 %
0014 [Ns,Nn] = size(zeta_sn);
0015 %
0016 if exist(['erfcc_mex_jd.',mexext],'file') == 3,%fortran file
0017     Z_sn = zeros(Ns,Nn);
0018     for is = 1:Ns,
0019         %
0020         x = [zeta_sn(is,:),zeros(1,65536 - Nn)];
0021         %
0022         [yr,yi] = erfcc_mex_jd(Nn,real(x),imag(x));
0023         %
0024         Z_sn(is,:) = sqrt(pi)*(1i*yr(1:Nn) - yi(1:Nn));
0025     end
0026     Zp_sn = -2*(1 + zeta_sn.*Z_sn);
0027     Zpp_sn = -2*(Z_sn - 2*zeta_sn.*(1 + zeta_sn.*Z_sn));
0028     %
0029     maskp_sn = abs(zeta_sn) > sqrt(1e-2/(2*eps));
0030     maskpp_sn = abs(zeta_sn) > sqrt(sqrt(1e-2/(4*eps)));
0031     %
0032     if display_mode && any(maskp_sn),
0033         disp(['Warning : there are ',num2str(sum(maskp_sn(:))),'/',num2str(length(maskp_sn(:))),...
0034             ' points outside the plasma dispersion function first derivative calculation range'])
0035     end
0036     %
0037     if display_mode && any(maskpp_sn),
0038         disp(['Warning : there are ',num2str(sum(maskpp_sn(:))),'/',num2str(length(maskpp_sn(:))),...
0039             ' points outside the plasma dispersion function second derivative calculation range'])
0040     end
0041     %
0042 elseif exist('pdisp','file') == 3,%fortran file
0043     if display_mode >= 1,
0044        wb = waitbar(0,'Plasma dispersion function');
0045     end
0046     Z_sn = NaN*ones(Ns,Nn);
0047     for is = 1:Ns,
0048         Z_sn(is,:) = pdispm(zeta_sn(is,:));
0049         if display_mode >= 1,
0050            waitbar(in/Nn,wb);
0051         end
0052     end
0053     if display_mode >= 1,
0054        close(wb)
0055     end
0056     Zp_sn = -2*(1 + zeta_sn.*Z_sn);
0057     Zpp_sn = -2*(Z_sn - 2*zeta_sn.*(1 + zeta_sn.*Z_sn));
0058     %
0059 else
0060     %
0061     % error('Please compile the function erfcc.f as a mex file.');
0062     %
0063     % disp('Warning: Zplasma must be checked first. Second derivative calculations are wrong for imag. part and for small arguments.')
0064     %
0065     [Z_sn,Zp_sn,Zpp_sn] = Zplasma(zeta_sn,NZ);
0066     %
0067 end

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