Exercise 4 Mat
Exercise 4 Mat
Exercise 4 Mat
1a)
l=100;
dx=0.1;
kappa=30e-6;
x=0:dx:l;
n=length(x);
T=zeros(1,n);
t=0;
dt=100;
Tm=1250;
%in years
T=Tm*(1-x/l);
T(1)=Tm;
T(n)=Tm;
while t<=100000
t=t+dt
T(2:n-1)=T(2:n-1)+dt*kappa*(T(3:n)-2*T(2:n-1)+T(1:n-2))/dx^2;
plot(x,T)
xlabel('position in km');ylabel('temperature in C')
pause(0.1)
end
Martrikel-Nr. 3556554
MatLab excercise 4
2
1b)
Plot for t=0:
1400
1200
temperature in C
1000
800
600
400
200
10
20
30
40
50
60
position in km
70
80
90
100
1400
1200
temperature in C
1000
800
600
400
200
10
20
30
40
50
60
position in km
Martrikel-Nr. 3556554
70
80
90
100
MatLab excercise 4
3
Plot for t=100000
1400
1200
temperature in C
1000
800
increasing t
600
400
200
10
20
30
40
50
60
position in km
70
Martrikel-Nr. 3556554
80
90
100
MatLab excercise 4
c)
l=100;
dx=0.1;
kappa=30e-6;
x=0:dx:l;
n=length(x);
T=zeros(1,n);
t=0;
dt=10;
Tm=1250;
%in years
T=Tm*(1-x/l);
T(1)=1250;
T(n)=1250;
holdon
while t<=25000
t=t+dt
T(2:n-1)=T(2:n-1)+dt*kappa*(T(3:n)-2*T(2:n-1)+T(1:n-2))/dx^2;
Tmean=mean(T.*1)
plot(t,Tm-Tmean)
xlabel('time in years'),ylabel('Tm-Tmean in C')
end
Tm-Tmean in C
2.793
10
2.791
10
2.789
10
2.787
10
0.5
1.5
time in years
Martrikel-Nr. 3556554
2.5
4
x 10
MatLab excercise 4
5
d) Plot of Tm-Tmean for l = 100 km and l = 50 km
l=100km
l=50km
2.794
Tm-Tmean in C
10
2.793
10
2.792
10
200
400
600
time in years
800
1000
1200
The plot above shows that the difference between both curves increases with time. The mean of the
temperature at l = 50 km increases faster this means Tm-Tmean decreases faster, because a steadystate-condition with nearly the same temperatures everywhere in the plate is achieved earlier. In other
words, the heat is distributed faster through the plate.
In the following figure, there is also the difference between both means (for 100 km and 50 km) plotted
versus time t.
Martrikel-Nr. 3556554
MatLab excercise 4
3.2
3
2.8
2.6
2.4
2.2
2
1.8
1.6
1.4
200
400
600
time in years
800
1000
1200
The last two figures were plotted by using the following code:
l=100;
m=50;
dx=0.1;
kappa=30e-6;
x=0:dx:l;
z=0:dx:m;
n=length(x);
k=length(z);
T=zeros(1,n);
t=0;
dt=10;
Tm=1250;
T=Tm*(1-x/l);
T(1)=1250;
T(n)=1250;
U=1250*(1-z/m);
U(1)=1250;
U(k)=1250;
holdon
%in years
while t<=1000
Martrikel-Nr. 3556554
MatLab excercise 4
t=t+dt
T(2:n-1)=T(2:n-1)+dt*kappa*(T(3:n)-2*T(2:n-1)+T(1:n-2))/dx^2;
Tmean=mean(T.*1);
U(2:k-1)=U(2:k-1)+dt*kappa*(U(3:k)-2*U(2:k-1)+U(1:k-2))/dx^2;
Umean=mean(U.*1);
Diff=mean(U.*1)-mean(T.*1);
holdon
figure(1)
plot(t,Tm-Tmean,'r+',t,Tm-Umean,'b.')
xlabel('time in years'),ylabel('Tm-Tmean in C')
legend('l=100km','l=50km')
figure(2)
plot(t,Diff,'gx')
xlabel('time in years'),ylabel('Difference between the means')
end
Martrikel-Nr. 3556554
MatLab excercise 4