Home > demos > bratu > bratucmds.m

bratucmds

PURPOSE ^

command templates for Bratu; run cell-by-cell;

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 command templates for Bratu; run cell-by-cell; 
 note that the basic bif-diagram and solution plots 
 only require the first 3 cells

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % command templates for Bratu; run cell-by-cell;
0002 % note that the basic bif-diagram and solution plots
0003 % only require the first 3 cells
0004 close all; clear all; 
0005 p=[]; p=bratuinit(p); p=cont(p); % homogeneous branch
0006 %% 2 branch switchings and successive continuation
0007 q=swibra('p','bp1','q'); q.lammin=0.09;q.nsteps=21;q=cont(q); 
0008 r=swibra('q','bp1','r'); r.lammin=0.05;r.nsteps=20;r=cont(r); 
0009 %% postprocessing, first plot BifDiagram
0010 figure(3);clf(3);
0011 plotbra(p,3,2,'ms',12,'lwst',5,'lwun',2,'fs',16,'cl','k');
0012 plotbra(q,3,2,'ms',12,'lwst',6,'lwun',2,'lab',[20],'fs',16,'cl','b');
0013 plotbra(r,3,2,'ms',12,'lwst',6,'lwun',2,'lab',[20],'fs',16,'cl','r');
0014 axis([0.05 0.37 0.5 3.5]);xlabel('\lambda');ylabel('||u||_2');
0015 %% plot solutions
0016 plotsolf('q','p20',7,1,1); % mesh plot
0017 figure(7); view(-30,50); xlabel('x');ylabel('y');
0018 plotsolf('r','p20',8,1,3); % rendered 3D plot
0019 figure(8); view(-30,50); xlabel('x');ylabel('y');
0020 %% first 'ad hoc meshcheck': refine mesh (to about maxt) and plot the difference
0021 q0=loadp('q','p20','q0'); [q0r,ud]=meshcheck(q0,1);  
0022 %% now refine aiming at error-bound
0023 q0r=meshref(q0,'eb',0.02); plotsol(q0r,9,1,1);view(-30,50); 
0024 %% just return error-estimate
0025 err0=errcheck(q0); fprintf('error-estimate %g\n',err0); 
0026 %% test of different adaption strategies; first load p10 on q branch
0027 q0=loadp('q','p10','q0');q0.lammin=0.05;q0=resetc(q0); q0.nsteps=40; 
0028 q0.errbound=0.1; q0.neig=100; q0b=q0; % save the point for restarts
0029 q0=cont(q0); % no refinement
0030 q1=q0b;q1.amod=10; q1=cont(q1);     % adapt every 10 steps
0031 q2=q0b;q2.errchecksw=2;q2=cont(q2); % adapt when err-est>errbound
0032 q3=q0b;q3.errchecksw=3;q3=cont(q3); % refine when err-est>errbound
0033 %% error plot
0034 figure(5);clf;hold on;
0035 ploterr(q0,5,3);ploterr(q1,5,3);ploterr(q2,5,3); legend('q0','q1','q2');
0036 %% branch plots;
0037 clf(3);cmp=2; 
0038 plotbra(q0,3,cmp,'labi',25,'cl','k','ms',8);
0039 plotbra(q1,3,cmp,'labi',10,'cl','b','ms',8); 
0040 plotbra(q2,3,cmp,'labi',10,'cl','r','ms',8);
0041 %% check how many triangles needed to fulfill error-estimate
0042 q0r=meshref(q0,'eb',0.0025,'maxt',10^5, 'ngen',20);

Generated on Wed 15-Aug-2012 12:53:02 by m2html © 2005