Question: Finish the code heat 2 Dimplicit.m ( shared in Files ) , by programming the implicit finite difference approximation of the 2 D temperature equation.
Finish the code heatDimplicit.m shared in Files by programming the implicit finite difference approximation of the D temperature equation.
Solves the D heat equation with an implicit finite difference scheme
clear
Physical parameters
L e; Width of lithosphere m
H e; Height of lithosphere m
Tbot ; Temperature of bottom lithosphere C
Tsurf ; Temperature of country rock C
Tplume ; Temperature of plume C
kappa e; Thermal diffusivity of rock ms
Wplume e; Width of plume m
day ; # seconds per day
year day; # seconds per year
dt eyear; timestep
Numerical parameters
nx ; # gridpoints in xdirection
nz ; # gridpoints in zdirection
nt ; Number of timesteps to compute
dx Lnx; Spacing of grid in xdirection
dz Hnz; Spacing of grid in zdirection
xdzd meshgridL:dx:LH:dz:; create grid
Setup initial linear temperature profile
T abszdHTbot;
Imping plume beneath lithosphere
ind findabsxd: Wplume;
Tind Tplume;
Setup numbering
num ;
for i:nz
for j:nx
Numberij num;
num num;
end
end
Construct the A matrix
A sparsenxnznxnz;
sx kappadtdx;
sz kappadtdz;
for i :nz
for j :nx
ii Numberij;
A ii Numberij ;
A ii Numberi j;
end
end
Set lower and upper BC
for j :nx
end
Set left and right BC
for i :nz
end
time ;
for n:nt
Compute rhs
rhs zerosnxnz;
for i :nz
for j :nx
ii Numberij;
end
end
Compute solution vector
Tnewvector Arhs;
Create D matrix from vector
Tnew TnewvectorNumber;
T Tnew;
time timedt;
Plot solution every timesteps
if modn
figure clf
pcolorxdezdeTnew; shading interp, colorbar
hold on
contourxdezdeTnew,::k;
xlabelx km
ylabelz km
zlabelTemperature oC
titleTemperature evolution after numstrtimeyeare Myrs
drawnow
end
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
