%Chapter 8
function pdemodel
[pde_fig,ax]=pdeinit;
pdetool('appl_cb',1);
set(ax,'DataAspectRatio',[1 0.97500000000000031 1]);
set(ax,'PlotBoxAspectRatio',[10 6.6666666666666661 1]);
set(ax,'XLimMode','auto');
set(ax,'YLimMode','auto');
set(ax,'XTickMode','auto');
set(ax,'YTickMode','auto');
pdetool('gridon','on');

% Geometry description:
pderect([-67 67 31.5 -31.5],'R1');
pdepoly([ -58,...
 -49.5,...
 -41,...
 -33,...
 -24.5,...
 -16.5,...
 -8,...
 -2,...
 -0.5,...
 -2,...
 -8,...
 -16.5,...
 -24.5,...
 -33,...
 -41,...
 -49.5,...
],...
[ 0,...
 5,...
 7.25,...
 7,...
 4.5,...
 2.5,...
 1.5,...
 0.94999999999999996,...
 0,...
 -0.94999999999999996,...
 -1.5,...
 -2.5,...
 -4.5,...
 -7,...
 -7.25,...
 -5,...
],...
 'P1');
pdepoly([ 0.5,...
 2,...
 8,...
 16.5,...
 24.5,...
 33,...
 41,...
 49.5,...
 58,...
 49.5,...
 41,...
 33,...
 24.5,...
 16.5,...
 8,...
 2,...
],...
[ 0,...
 0.94999999999999996,...
 1.5,...
 2.5,...
 4.5,...
 7,...
 7.25,...
 5,...
 0,...
 -5,...
 -7.25,...
 -7,...
 -4.5,...
 -2.5,...
 -1.5,...
 -0.94999999999999996,...
],...
 'P2');
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String','R1+P1+P2')

% Boundary conditions:
pdetool('changemode',0)
pdesetbd(35,...
'dir',...
1,...
'1',...
'0')
pdesetbd(34,...
'dir',...
1,...
'1',...
'0')
pdesetbd(2,...
'dir',...
1,...
'1',...
'0')
pdesetbd(1,...
'dir',...
1,...
'1',...
'0')

% Mesh generation:
setuprop(pde_fig,'trisize',8.5);
setuprop(pde_fig,'Hgrad',1.3);
setuprop(pde_fig,'refinemethod','regular');
pdetool('initmesh')

% PDE coefficients:
pdeseteq(1,...
'1.0',...
'0.0',...
'10.0',...
'1.0',...
'0:10',...
'0.0',...
'0.0',...
'[0 100]')
setuprop(pde_fig,'currparam',...
['1.0 ';...
'0.0 ';...
'10.0';...
'1.0 '])

% Solve parameters:
setuprop(pde_fig,'solveparam',...
str2mat('0','1000','10','pdeadworst',...
'0.5','longest','0','1E-4','','fixed','Inf'))

% Plotflags and user data strings:
setuprop(pde_fig,'plotflags',[1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 0 1]);
setuprop(pde_fig,'colstring','');
setuprop(pde_fig,'arrowstring','');
setuprop(pde_fig,'deformstring','');
setuprop(pde_fig,'heightstring','');
