Home > p2plib > nlooppde.m

nlooppde

PURPOSE ^

newton-loop (with damping parameter alpha) for pde alone,

SYNOPSIS ^

function [u,res,iter,Gu,Glam]=nlooppde(p,u1,lam1)

DESCRIPTION ^

 newton-loop (with damping parameter alpha) for pde alone, 
 i.e., "natural-parametrization", i.e. fixed lambda

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [u,res,iter,Gu,Glam]=nlooppde(p,u1,lam1) 
0002 % newton-loop (with damping parameter alpha) for pde alone,
0003 % i.e., "natural-parametrization", i.e. fixed lambda
0004 almin=0.01; % minimal damping
0005 u=u1; lam=lam1; alpha=1; iter=0; 
0006 r=resi(p,u,lam);res0=norm(r,p.normsw); % (starting) residual
0007 Gu=getGu(p,u,lam,r); % derivatives (needed for next tangent, thus alway computed)
0008 if(res0<p.tol); % starting residual already small, compute Glam and return
0009    Glam=getGlam(p,u,lam,r); res=res0; return; 
0010 end; 
0011 
0012 % now start the actual loop
0013 stepok=1; % stepok=1 indicates that step of size alpha decreased residual!
0014 while(abs(res0)>p.tol && iter<p.imax && stepok)  
0015   upd=p.lss(Gu,r,p,lam); stepok=0; 
0016   while(stepok==0 && alpha>almin) 
0017     u1=u-alpha*upd;    % the newton step
0018     r=resi(p,u1,lam); res=norm(r,p.normsw); 
0019     if(res<res0); % good step
0020        if(res<res0/4 && alpha<1) % very good step, possibly increase alpha
0021            alpha=2*alpha; 
0022        end 
0023        stepok=1; u=u1; res0=res; 
0024        if(p.nsw==0) % full Newton, get new derivatives
0025           Gu=getGu(p,u,lam,r);  % next Jacobian
0026        end
0027     else alpha=alpha/2; % bad step, try smaller al
0028     end % if res<res0
0029   end % while stepok==0
0030   iter=iter+1; alpha=1; 
0031 end   % while res0>p.tol && stepok
0032 
0033 % some postprocessing
0034 if(p.nsw==0); Glam=getGlam(p,u,lam,r); % Newton, only update Glam
0035 else [Gu,Glam]=getder(p,u,lam,r); end % chord, update Gu,Glam
0036 if(p.vsw>1); if(alpha<1); % inform user about damping ...
0037         fprintf('nlooppde: damp alpha=%g, res=%g\n', alpha,res0); end; end; 
0038 res=res0; % return res of u0=best u

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