0001 function [p,iok]=inistep(p)
0002
0003
0004 iok1=0;iok2=0; [p.u,res]=nlooppde(p,p.u,p.lam); ineg=-1;
0005 if(res<p.tol)
0006 fprintf('got first point with lam=%g, res=%g \n',p.lam,res);
0007 if(p.spcalcsw>0);
0008 r=resi(p,p.u,p.lam); Gu=getGu(p,p.u,p.lam,r);
0009 [ineg,muv]=spcalc(Gu,p);
0010 end
0011 if(p.errchecksw>0); p.err=errcheck(p);end
0012 brout=p.outfu(p,p.u,p.lam);
0013 p.branch=[p.branch [p.count; ineg; p.lam; p.err; brout]];
0014 figure(p.brfig); hold on;
0015 if(ineg<=0) plot(p.lam,brout(p.bpcmp),'*'); else plot(p.lam,brout(p.bpcmp),'+'); end
0016 if p.smod~=0
0017 fname=[p.pname,sprintf('%i',p.count),'.mat']; save(fname,'p');
0018 end
0019 iok1=1;p.count=p.count+1;
0020 else fprintf('no convergence in zeroth step, lam=%g, res=%g\n',p.lam,res);
0021 end
0022 lam=p.lam;p.lam=lam+p.ds/10;fprintf('now lam=%g\n',p.lam);
0023 [u,res]=nlooppde(p,p.u,p.lam);
0024 if(res<p.tol)
0025 fprintf('got second point with lam=%g, res=%g \n',p.lam,res);
0026 if(p.spcalcsw>0); r=resi(p,u,p.lam); Gu=getGu(p,u,p.lam,r);
0027 [ineg,muv]=spcalc(Gu,p); end
0028 if(p.errchecksw>0); p.err=errcheck(p);end
0029 brout=p.outfu(p,u,p.lam);
0030 p.branch=[p.branch [p.count; ineg; p.lam; p.err; brout]];
0031 figure(p.brfig); hold on;
0032 if(ineg<=0) plot(p.lam,brout(p.bpcmp),'*'); else plot(p.lam,brout(p.bpcmp),'+'); end
0033 if(mod(p.count-1,p.smod)==0)
0034 fname=[p.pname,sprintf('%i',p.count),'.mat']; save(fname,'p'); end
0035 iok2=1;p.count=p.count+1;
0036 else fprintf('no convergence in first step, lam=%g, res=%g\n',p.lam,res);
0037 end
0038 iok=iok1*iok2; tau=[(u-p.u)/(p.lam-lam); 1];
0039 p.u=u;p.tau=tau/xinorm(tau,p.xi);p.restart=1; p.ineg=ineg;