Function files bratuf.m, bratujac.m and bratuinit.m
function [c,a,f,b]=bratuf(p,u,lam)
u=pdeintrp(p.points,p.tria,u); c=1; a=0;f=-10*(u-lam*exp(u)); b=0;
function [c,fu,flam,b]=bratujac(p,u,lam)
u=pdeintrp(p.points,p.tria,u); c=1;
fu=-10*(1-lam*exp(u)); flam=10*exp(u); b=0;
function p=bratuinit(p)
p=stanparam(p);
p.neq=1; p.f=@bratuf; p.jac=@bratujac;
[p.geo,bc]=recnbc1(0.5,0.5);
p.bcf=@(p,u,lam) bc;
nx=20;p=stanmesh(p,nx,nx);
p=setbmesh(p);
p.maxt=2*p.nt;
pre=sprintf('%s',inputname(1)); p=setfn(p,pre);
p.tau=zeros(p.neq*p.np+1,1); p.tau(1)=1;
p.xi=1/p.np;
p.pstyle=1; p.cm=hot;
p.nsteps=50; p.dsmax=1;
p.dlammax=0.02;
p.lammin=0.05;
p.lam=0.2;
p.u=0.1*ones(p.np,1);p.ds=0.05;
res=norm(resi(p,p.u,p.lam), p.normsw);
fprintf('initial res=%g\n',res);
[p.u,p.res,p.iter]=nlooppde(p,p.u,p.lam);
fprintf('first res=%g with %i iterations\n',p.res,p.iter);
plotsol(p,1,1,p.pstyle);
Script bratucmds.m
close all; clear all; path('../../pde2p',path); path('../../aux',path);
p=[]; p=bratuinit(p); p=cont(p);
q=swibra('p','bp1','q'); q.lammin=0.09;q.nsteps=21;q=cont(q);
r=swibra('q','bp1','r'); r.lammin=0.05;r.nsteps=20;r=cont(r);
figure(3);clf(3);
plotbra(p,3,2,'ms',12,'lwst',5,'lwun',2,'fs',16,'cl','k');
plotbra(q,3,2,'ms',12,'lwst',6,'lwun',2,'lab',[20],'fs',16,'cl','b');
plotbra(r,3,2,'ms',12,'lwst',6,'lwun',2,'lab',[20],'fs',16,'cl','r');
axis([0.05 0.37 0.5 3.5]);xlabel('\lambda');ylabel('||u||_2');
plotsolf('q','p20',7,1,1);
figure(7); view(-30,50); xlabel('x');ylabel('y');
plotsolf('r','p20',8,1,3);
figure(8); view(-30,50); xlabel('x');ylabel('y');