Home > p2plib > spcalc.m

spcalc

PURPOSE ^

calculate p.neig EVals of Gu closest to 0. Return them sorted wrt real parts,

SYNOPSIS ^

function [ineg,muv,impar]=spcalc(Gu,p)

DESCRIPTION ^

 calculate p.neig EVals of Gu closest to 0. Return them sorted wrt real parts,  
 and the number ineg of negative evals 
 give warning

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ineg,muv,impar]=spcalc(Gu,p) 
0002 % calculate p.neig EVals of Gu closest to 0. Return them sorted wrt real parts,
0003 % and the number ineg of negative evals
0004 % give warning
0005 [~,MId]=assema(p.points,p.tria,0,1,zeros(p.neq,1)); % compute mass matrix of identity
0006 if(strcmp(p.eigmeth,'eigs')) % compute p.neig FEM eigenvalues
0007     if p.eigsstart==1; vs=size(Gu,1); p.evopts.v0=ones(vs,1)/vs; end 
0008     [~,mu]=eigs(Gu,MId,p.neig,p.eigref,p.evopts); 
0009     muv=mu*ones(1,p.neig)';
0010 else % compute Evals with real-part in [p.eigint(1), p.eigint(2)], usually slow
0011     evalc('[V,muv]=sptarn(Gu,MId,p.eigint(1),p.eigint(2));');
0012 end
0013 mul=length(muv); [ms,ix]=sort(real(muv)); 
0014 ineg=0; mus=zeros(1,mul); impar=0;
0015 for i=1:mul; mus(i)=muv(ix(i)); 
0016     if (ms(i)<0) ineg=ineg+1; impar=impar+imag(mus(i)); end
0017 end; 
0018 if abs(mus(1))>abs(mus(mul))/2
0019     fprintf('warning: mu-min=%g, mu-max=%g; consider increasing p.neig\n', mus(1),mus(mul));
0020 end
0021 if(impar>10*eps) 
0022     fprintf('warning: nonzero sum of imaginary parts of negative evals of Gu.\n');
0023 end
0024 muv=mus;

Generated on Wed 15-Aug-2012 10:09:15 by m2html © 2005