% FEMLAB Model M-file
% Generated 06-Jan-2002 17:53:31 by FEMLAB 2.1.0.127.

flclear fem
% FEMLAB Version
clear vrsn;
vrsn.name='FEMLAB 2.1';
vrsn.major=0;
vrsn.build=127;
fem.version=vrsn;

% Space dimensions
fem.sdim={'x','y'};

% Geometry
clear s c p
p=[-0.017500000000000002 -0.017500000000000002 -0.01 -0.01 -0.01 -0.01  ...
-0.01 -0.0050000000000000001 -0.0050000000000000001 0.0050000000000000001  ...
0.0050000000000000001 0.01 0.01 0.01 0.01 0.017500000000000002  ...
0.017500000000000002;-0.0050000000000000001 0.0050000000000000001 -0.01  ...
-0.0098976745888010326 -0.0050000000000000001 0.0050000000000000001 0.01  ...
-0.0050000000000000001 0.0050000000000000001 -0.0050000000000000001  ...
0.0050000000000000001 -0.01 -0.0050000000000000001 0.0050000000000000001  ...
0.01 -0.0050000000000000001 0.0050000000000000001];
rb={1:17,[1 1 2 3 3 4 6 7 8 8 9 10 12 13 14 14 16;2 5 6 4 12 5 7 15 9 10 11  ...
11 13 16 15 17 17],zeros(3,0),zeros(4,0)};
wt={zeros(1,0),ones(2,17),zeros(3,0),zeros(4,0)};
lr={[NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN], ...
[0 1 0 0 1 0 0 0 1 0 1 0 1 1 1 0 1;1 0 1 1 0 1 1 1 0 1 0 1 0 0 0 1 0], ...
zeros(2,0),zeros(2,0)};
CO1=solid2(p,rb,wt,lr);
objs={CO1};
names={'CO1'};
s.objs=objs;
s.name=names;

objs={};
names={};
c.objs=objs;
c.name=names;

objs={};
names={};
p.objs=objs;
p.name=names;

drawstruct=struct('s',s,'c',c,'p',p);
fem.draw=drawstruct;
fem.geom=geomcsg(fem);

% Recorded command sequence

clear appl

% Application mode 1
appl{1}.mode='flpdeht2d(''dim'',{''T''},''sdim'',{''x'',''y''},''submode'',''std'',''tdiff'',''on'')';
appl{1}.dim={'T'};
appl{1}.form='coefficient';
appl{1}.border='on';
appl{1}.name='ht';
appl{1}.var={};
appl{1}.assign={'C';'C';'Const';'Const';'Ctrans';'Ctrans';'Q';'Q';'Tamb'; ...
'Tamb';'Tambtrans';'Tambtrans';'Text';'Text';'Tinf';'Tinf';'flux';'flux'; ...
'flux_x';'flux_x';'flux_y';'flux_y';'gradT';'gradT';'gradTx';'gradTx'; ...
'gradTy';'gradTy';'h';'h';'htrans';'htrans';'n_flux';'n_flux';'q';'q';'rho'; ...
'rho'};
appl{1}.equ.rho={'7800'};
appl{1}.equ.C={'460'};
appl{1}.equ.k={{{'45'}}};
appl{1}.equ.Q={'0'};
appl{1}.equ.htrans={'0'};
appl{1}.equ.Text={'0'};
appl{1}.equ.Ctrans={'0'};
appl{1}.equ.Tambtrans={'0'};
appl{1}.equ.ind=1;
appl{1}.usage=1;
appl{1}.bnd.q={'0','0','0','0'};
appl{1}.bnd.h={'10','5','0','0'};
appl{1}.bnd.Tinf={'T0','T0','0','0'};
appl{1}.bnd.Const={'0','0','0','0'};
appl{1}.bnd.Tamb={'0','0','0','0'};
appl{1}.bnd.T={'0','0','(273+60)','0'};
appl{1}.bnd.type={'q','q','T','q0'};
appl{1}.bnd.ind=[1 2 1 2 2 2 1 1 3 3 3 3 2 2 1 1 4];
appl{1}.init.sd={{{'(273+20)'}}};
appl{1}.init.ind=1;

fem.appl=appl;

% Initialize mesh
fem.mesh=meshinit(fem,...
	'Out',    {'mesh'},...
	'jiggle', 'mean',...
	'Hcurve', 0.29999999999999999,...
	'Hgrad',  1.3,...
	'Hpnt',   {10,[]});

% Refine mesh
fem.mesh=meshrefine(fem,...
	'out',    {'mesh'},...
	'rmethod','regular');

% Refine mesh
fem.mesh=meshrefine(fem,...
	'out',    {'mesh'},...
	'rmethod','regular');

% Dimension
fem.dim={{'T'}};

% Boundary conditions
fem.border=1;

% Usage
fem.usage=1;

% Problem form
fem.form='coefficient';

% Differentiation
fem.diff='off';

% Differentiation simplification
fem.simplify='on';

% Differentiation rules
fem.rules={};

% Define variables
fem.variables={'T0', 293};

% Define application mode variables
fem.var={};

% Boundary conditions
clear bnd
bnd.q={{{'10'}},{{'5'}},{{'0'}},{{'0'}}};
bnd.g={{{'10.*T0'}},{{'5.*T0'}},{{'0'}},{{'0'}}};
bnd.h={{{'0'}},{{'0'}},{{'1'}},{{'0'}}};
bnd.r={{{'0'}},{{'0'}},{{'333'}},{{'0'}}};
bnd.var={'q',{'0','0','0','0'},'h',{'10','5','0','0'},'Tinf',{'T0','T0','0', ...
'0'},'Const',{'0','0','0','0'},'Tamb',{'0','0','0','0'},'n_flux','-ncu1'};
bnd.ind=[1 2 1 2 2 2 1 1 3 3 3 3 2 2 1 1 4];
fem.bnd=bnd;

% PDE coefficients
clear equ
equ.da={{{'3588000'}}};
equ.c={{{'45'}}};
equ.al={{{'0';'0'}}};
equ.ga={{{'0';'0'}}};
equ.be={{{'0';'0'}}};
equ.a={{{'0'}}};
equ.f={{{'0'}}};
equ.var={'rho',{'7800'},'C',{'460'},'Q',{'0'},'htrans',{'0'},'Text',{'0'}, ...
'Ctrans',{'0'},'Tambtrans',{'0'},'gradTx','-Tx','gradTy','-Ty','gradT', ...
'sqrt(Tx.^2+Ty.^2)','flux_x','-cu1x','flux_y','-cu1y','flux', ...
'sqrt(cu1x.^2+cu1y.^2)'};
equ.ind=1;
fem.equ=equ;

% Evaluate initial condition
fem.init=asseminit(fem,...
	'context','local',...
	'init',   struct('sd',{{{{'293'}}}},'ind',{1}));

% Solve dynamic problem
fem.sol=femtime(fem,...
	'tlist',  0:10,...
	'atol',   0.001,...
	'rtol',   0.01,...
	'jacobian','equ',...
	'mass',   'full',...
	'ode',    'ode15s',...
	'odeopt', struct('InitialStep',{[]},'MaxOrder',{5},'MaxStep',{[]}),...
	'out',    'sol',...
	'stop',   'on',...
	'report', 'on',...
	'context','local',...
	'sd',     'off',...
	'Epoint', 'gauss2',...
	'Nullfun','flnullorth',...
	'Tpoint', 'gauss2',...
	'Solcomp',1);

% Save current mesh
restart.mesh=fem.mesh;
restart.usage=fem.usage;

% Plot solution
postplot(fem,...
	'context','local',...
	'tridata',{'T','cont','on'},...
	'trifacestyle','interp',...
	'triedgestyle','none',...
	'trimap', 'jet',...
	'trimaxmin','off',...
	'tribar', 'on',...
	'geom',   'on',...
	'geomcol','bginv',...
	'view',   [0 90],...
	'title',  'Time=10  Surface: temperature (T)  ',...
	'renderer','zbuffer',...
	'solnum', 11,...
	'axisvisible','on')

% Plot solution
postplot(fem,...
	'context','local',...
	'tridata',{'T','cont','on'},...
	'trifacestyle','interp',...
	'triedgestyle','none',...
	'trimap', 'jet',...
	'trimaxmin','off',...
	'tribar', 'on',...
	'triz',   {'T','cont','on'},...
	'view',   [0 90],...
	'title',  'Time=10  Surface: temperature (T)  Height: temperature (T)  ',...
	'renderer','zbuffer',...
	'solnum', 11,...
	'axisvisible','on')

% Plot solution
postplot(fem,...
	'context','local',...
	'tridata',{'T','cont','on'},...
	'trifacestyle','interp',...
	'triedgestyle','none',...
	'trimap', 'jet',...
	'trimaxmin','off',...
	'tribar', 'on',...
	'triz',   {'T','cont','on'},...
	'view',   [-37.5 30],...
	'title',  'Time=1  Surface: temperature (T)  Height: temperature (T)  ',...
	'renderer','zbuffer',...
	'solnum', 2,...
	'axisvisible','on')

% Plot solution
postplot(fem,...
	'context','local',...
	'tridata',{'T','cont','on'},...
	'trifacestyle','interp',...
	'triedgestyle','none',...
	'trimap', 'jet',...
	'trimaxmin','off',...
	'tribar', 'on',...
	'triz',   {'T','cont','on'},...
	'view',   [-37.5 30],...
	'title',  'Time=0  Surface: temperature (T)  Height: temperature (T)  ',...
	'renderer','zbuffer',...
	'solnum', 1,...
	'axisvisible','on')

% Plot solution
postplot(fem,...
	'context','local',...
	'tridata',{'T','cont','on'},...
	'trifacestyle','interp',...
	'triedgestyle','none',...
	'trimap', 'jet',...
	'trimaxmin','off',...
	'tribar', 'on',...
	'triz',   {'T','cont','on'},...
	'view',   [-37.5 30],...
	'title',  'Time=1  Surface: temperature (T)  Height: temperature (T)  ',...
	'renderer','zbuffer',...
	'solnum', 2,...
	'axisvisible','on')

% Animate solution
postmovie(fem,...
	'context','local',...
	'tridata',{'T','cont','on'},...
	'trifacestyle','interp',...
	'triedgestyle','none',...
	'trimap', 'jet',...
	'trimaxmin','off',...
	'tribar', 'on',...
	'triz',   {'T','cont','on'},...
	'movie',  'on',...
	'repeat', 1,...
	'fps',    12,...
	'title',  'Surface: temperature (T)  Height: temperature (T)  ',...
	'renderer','zbuffer',...
	'view',   [-37.5 30])
