exercise 4 mat

7
1 Obasi Martin Essuka Martrikel-Nr. 3556554 MatLab excercise 4 1a) l=100; %length of the domain in km  dx=0.1; %grid spacing  kappa=30e-6; %thermal diffusivity in km2/a  x=0:dx:l; n=length(x); %number of elements  T=zeros(1,n); t=0; dt=100; %in years Tm=1250; T=Tm*(1-x/l); %initial temp. distribution  T(1)=Tm; %Temp. atthe left-hand boundary  T(n)=Tm; %Temp. at the right-hand boundary  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 

Upload: lambert-strong

Post on 05-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Exercise 4 Mat

8/16/2019 Exercise 4 Mat

http://slidepdf.com/reader/full/exercise-4-mat 1/7

1

Obasi Martin Essuka Martrikel-Nr. 3556554 MatLab excercise 4

1a)

l=100; %length of the domain in km dx=0.1; %grid spacing kappa=30e-6; %thermal diffusivity in km2/a x=0:dx:l; n=length(x); %number of elements T=zeros(1,n); t=0;

dt=100; %in years Tm=1250;

T=Tm*(1-x/l); %initial temp. distribution T(1)=Tm; %Temp. atthe left-hand boundary T(n)=Tm; %Temp. at the right-hand boundary

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

Page 2: Exercise 4 Mat

8/16/2019 Exercise 4 Mat

http://slidepdf.com/reader/full/exercise-4-mat 2/7

2

Obasi Martin Essuka Martrikel-Nr. 3556554 MatLab excercise 4

1b)

Plot for t=0:

0 10 20 30 40 50 60 70 80 90 1000

200

400

600

800

1000

1200

1400

position in km

t e m p e r a

t u r e

i n ° C

Plot for t=10000

0 10 20 30 40 50 60 70 80 90 1000

200

400

600

800

1000

1200

1400

position in km

t e m p e r a

t u r e

i n ° C

Page 3: Exercise 4 Mat

8/16/2019 Exercise 4 Mat

http://slidepdf.com/reader/full/exercise-4-mat 3/7

3

Obasi Martin Essuka Martrikel-Nr. 3556554 MatLab excercise 4

Plot for t=100000

0 10 20 30 40 50 60 70 80 90 1000

200

400

600

800

1000

1200

1400

position in km

t e m p e r a

t u r e

i n ° C

increasing t

Page 4: Exercise 4 Mat

8/16/2019 Exercise 4 Mat

http://slidepdf.com/reader/full/exercise-4-mat 4/7

4

Obasi Martin Essuka Martrikel-Nr. 3556554 MatLab excercise 4

c)

l=100; %length of the domain in km dx=0.1; %grid spacing

kappa=30e-6; %thermal diffusivity in km2/a x=0:dx:l; n=length(x); %number of elements T=zeros(1,n); t=0;

dt=10; %in years Tm=1250;

T=Tm*(1-x/l); T(1)=1250; T(n)=1250; hold on

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

0 0.5 1 1.5 2 2.5

x 104

102.787

10 2.789

102.791

102.793

time in years

T m - T m e a n

i n ° C

Page 5: Exercise 4 Mat

8/16/2019 Exercise 4 Mat

http://slidepdf.com/reader/full/exercise-4-mat 5/7

5

Obasi Martin Essuka Martrikel-Nr. 3556554 MatLab excercise 4

d) Plot of Tm-Tmean for l = 100 km and l = 50 km

0 200 400 600 800 1000 1200

102.792

102.793

102.794

time in years

T m - T m e a n

i n ° C

l=100kml=50km

The plot above shows that the difference between both curves increases with time. The mean of thetemperature at l = 50 km increases faster this means Tm-Tmean decreases faster, because a steady-state-condition with nearly the same temperatures everywhere in the plate is achieved earlier. In otherwords, 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.

Page 6: Exercise 4 Mat

8/16/2019 Exercise 4 Mat

http://slidepdf.com/reader/full/exercise-4-mat 6/7

6

Obasi Martin Essuka Martrikel-Nr. 3556554 MatLab excercise 4

0 200 400 600 800 1000 1200

1.4

1.6

1.8

2

2.2

2.4

2.6

2.8

3

3.2

time in years

D i f f e r e n c e

b e

t w e e n

t h e m e a n s

The last two figures were plotted by using the following code:

l=100; %length of the 1st domain in km m=50; %length of the 2nd domain in km dx=0.1; %grid spacing kappa=30e-6; %thermal diffusivity in km2/a x=0:dx:l; %position in domain 1 z=0:dx:m; %position in domain 1 n=length(x); %number of elements 2nd domain k=length(z); %number of elements 2nd domain T=zeros(1,n); t=0;

dt=10; %in years Tm=1250;

T=Tm*(1-x/l); T(1)=1250; T(n)=1250; U=1250*(1-z/m); %temperature in the 2nd domain U(1)=1250; U(k)=1250; hold on

while t<=1000

Page 7: Exercise 4 Mat

8/16/2019 Exercise 4 Mat

http://slidepdf.com/reader/full/exercise-4-mat 7/7

7

Obasi Martin Essuka 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);

hold on 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