Anda di halaman 1dari 10

In[1]:= (Homework 8

Heat Conduction in a NonUniform Bar The 'Shooting' Method)


In[2]:= (The Problem)
A[x_] Cos[(2Pix)/L] 1.1
ODE A'[x]phi'[x] A[x]phi''[x] lambdaA[x]phi[x] 0
Out[2]= 1.1 Cos
2 x
L

Out[3]= lambda 1.1 Cos


2 x
L
phi[x]
2 Sin
2 x
L
phi

[x]
L
1.1 Cos
2 x
L
phi

[x] 0
In[4]:= (Search for the first Eigenvalue, Lambda1.)
LambdaValue 0.00222
ICGuess 10
A[x_] Cos[(2Pix)/L] 1.1
MyODE2 A'[x]phi2'[x] A[x]phi2''[x] lambda2A[x]phi2[x] 0
My2IC1 phi2[0] 0
My2IC2 phi2'[0] ICGuess
L 20;
MySol2 First[phi2/.NDSolve[
{MyODE2/.lambda2 LambdaValue,
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
Plot[MySol2[x],{x,0,L], PlotStyle Thick]
(This is a plot of the solution with the first eigenvalue)
Plot[MySol2'[x],{x,0,L], PlotStyle Thick]
(This is a plot of the derivative of the solution.)
Out[4]= 0.00222
Out[5]= 10
Out[6]= 1.1 Cos
2 x
L

Out[7]= lambda2 1.1 Cos


2 x
L
phi2[x]
2 Sin
2 x
L
phi2

[x]
L
1.1 Cos
2 x
L
phi2

[x] 0
Out[8]= phi2[0] 0
Out[9]= phi2

[0] 10
Out[12]=
5 10 15 20
200
400
600
800
Out[13]=
5 10 15 20
50
100
150
200
In[14]:= Lambda1 LambdaValue
Out[14]= 0.00222
In[15]:= (Search for the second Eigenvalue, Lambda2.)
LambdaValue 0.0751
ICGuess 10
A[x_] Cos[(2Pix)/L] 1.1
MyODE2 A'[x]phi2'[x] A[x]phi2''[x] lambda2A[x]phi2[x] 0
My2IC1 phi2[0] 0
My2IC2 phi2'[0] ICGuess
L 20;
MySol2 First[phi2/.NDSolve[
{MyODE2/.lambda2 LambdaValue,
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
Plot[MySol2[x],{x,0,L], PlotStyle Thick]
(This is a plot of the solution with the second eigenvalue)
Plot[MySol2'[x],{x,0,L], PlotStyle Thick]
(This is a plot of the derivative of the solution.)
Out[15]= 0.0751
Out[16]= 10
2 PDE Day 17. m
Out[17]= 1.1 Cos
x
10

Out[18]= lambda2 1.1 Cos


x
10
phi2[x]
1
10
Sin
x
10
phi2

[x] 1.1 Cos


x
10
phi2

[x] 0
Out[19]= phi2[0] 0
Out[20]= phi2

[0] 10
Out[23]=
5 10 15 20
10
20
30
40
50
Out[24]=
5 10 15 20
15
10
5
5
10
In[25]:= Lambda2 LambdaValue
Out[25]= 0.0751
PDE Day 17. m 3
In[26]:= (Search for the third Eigenvalue, Lambda3.)
LambdaValue 0.189
ICGuess 10
A[x_] Cos[(2Pix)/L] 1.1
MyODE2 A'[x]phi2'[x] A[x]phi2''[x] lambda2A[x]phi2[x] 0
My2IC1 phi2[0] 0
My2IC2 phi2'[0] ICGuess
L 20;
MySol2 First[phi2/.NDSolve[
{MyODE2/.lambda2 LambdaValue,
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
Plot[MySol2[x],{x,0,L], PlotStyle Thick]
(This is a plot of the solution with the second eigenvalue)
Plot[MySol2'[x],{x,0,L], PlotStyle Thick]
(This is a plot of the derivative of the solution.)
Out[26]= 0.189
Out[27]= 10
Out[28]= 1.1 Cos
x
10

Out[29]= lambda2 1.1 Cos


x
10
phi2[x]
1
10
Sin
x
10
phi2

[x] 1.1 Cos


x
10
phi2

[x] 0
Out[30]= phi2[0] 0
Out[31]= phi2

[0] 10
Out[34]=
5 10 15 20
150
100
50
50
4 PDE Day 17. m
Out[35]=
5 10 15 20
60
40
20
20
40
In[36]:= Lambda3 LambdaValue
Out[36]= 0.189
In[37]:= (Search for the fourth Eigenvalue, Lambda4.)
LambdaValue 0.344
ICGuess 10
A[x_] Cos[(2Pix)/L] 1.1
MyODE2 A'[x]phi2'[x] A[x]phi2''[x] lambda2A[x]phi2[x] 0
My2IC1 phi2[0] 0
My2IC2 phi2'[0] ICGuess
L 20;
MySol2 First[phi2/.NDSolve[
{MyODE2/.lambda2 LambdaValue,
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
Plot[MySol2[x],{x,0,L], PlotStyle Thick]
(This is a plot of the solution with the second eigenvalue)
Plot[MySol2'[x],{x,0,L], PlotStyle Thick]
(This is a plot of the derivative of the solution.)
Out[37]= 0.344
Out[38]= 10
Out[39]= 1.1 Cos
x
10

Out[40]= lambda2 1.1 Cos


x
10
phi2[x]
1
10
Sin
x
10
phi2

[x] 1.1 Cos


x
10
phi2

[x] 0
Out[41]= phi2[0] 0
Out[42]= phi2

[0] 10
PDE Day 17. m 5
Out[45]=
5 10 15 20
50
40
30
20
10
10
Out[46]=
5 10 15 20
10
10
20
In[47]:= Lambda4 LambdaValue
Out[47]= 0.344
In[48]:= (Search for the fifth Eigenvalue, Lambda5.)
LambdaValue 0.541
ICGuess 10
A[x_] Cos[(2Pix)/L] 1.1
MyODE2 A'[x]phi2'[x] A[x]phi2''[x] lambda2A[x]phi2[x] 0
My2IC1 phi2[0] 0
My2IC2 phi2'[0] ICGuess
L 20;
MySol2 First[phi2/.NDSolve[
{MyODE2/.lambda2 LambdaValue,
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
Plot[MySol2[x],{x,0,L], PlotStyle Thick]
(This is a plot of the solution with the second eigenvalue)
Plot[MySol2'[x],{x,0,L], PlotStyle Thick]
(This is a plot of the derivative of the solution.)
Out[48]= 0.541
Out[49]= 10
Out[50]= 1.1 Cos
x
10

6 PDE Day 17. m


Out[51]= lambda2 1.1 Cos
x
10
phi2[x]
1
10
Sin
x
10
phi2

[x] 1.1 Cos


x
10
phi2

[x] 0
Out[52]= phi2[0] 0
Out[53]= phi2

[0] 10
Out[56]=
5 10 15 20
20
20
40
60
80
Out[57]=
5 10 15 20
20
20
40
In[58]:= Lambda5 LambdaValue
Out[58]= 0.541
In[59]:= (Search for the sixth Eigenvalue, Lambda3.)
LambdaValue 0.789
ICGuess 10
A[x_] Cos[(2Pix)/L] 1.1
MyODE2 A'[x]phi2'[x] A[x]phi2''[x] lambda2A[x]phi2[x] 0
My2IC1 phi2[0] 0
My2IC2 phi2'[0] ICGuess
L 20;
MySol2 First[phi2/.NDSolve[
{MyODE2/.lambda2 LambdaValue,
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
Plot[MySol2[x],{x,0,L], PlotStyle Thick]
(This is a plot of the solution with the second eigenvalue)
Plot[MySol2'[x],{x,0,L], PlotStyle Thick]
(This is a plot of the derivative of the solution.)
PDE Day 17. m 7
Out[59]= 0.789
Out[60]= 10
Out[61]= 1.1 Cos
x
10

Out[62]= lambda2 1.1 Cos


x
10
phi2[x]
1
10
Sin
x
10
phi2

[x] 1.1 Cos


x
10
phi2

[x] 0
Out[63]= phi2[0] 0
Out[64]= phi2

[0] 10
Out[67]=
5 10 15 20
10
10
20
30
40
Out[68]=
5 10 15 20
30
20
10
10
20
In[69]:= Lambda6 LambdaValue
Out[69]= 0.789
In[70]:= (Uniform versus NonUniform Eigenvalues.)
In[71]:= (Below we have created a list of our six eigenvalues we found above.
These are the nonuniform eigenvalues.)
NonUniformEigenValues List[Lambda1,Lambda2,Lambda3,Lambda4,Lambda5,Lambda6]
Out[71]= {0.00222, 0.0751, 0.189, 0.344, 0.541, 0.789]
8 PDE Day 17. m
In[72]:= (These are the uniform eigenvalues.)
Clear[n,L,Lambda]
L20
For[n 0, n6, n1,
Lambda (((2n1.0)Pi)/(2L))^2;
Print[Lambda];
]
(Notice that the first is larger than the nonuniform first eigenvalue we have found.
This is because the heat settles much quicker in the uniform bar since there is no trapped
as with the nonuniform bar. In the nonuniform bar, the center is very thin, therfore it
pass through to the left, non insulated side, trapping it on the right side.)
Out[73]= 20
0.0061685
0.0555165
0.154213
0.302257
0.499649
0.746389
In[75]:= (Testing Orthogonality of the NonUniform Eigenfunctions.)
In[76]:= EigenFunction1 First[phi2/.NDSolve[
{MyODE2/.lambda2 NonUniformEigenValues[[1]],
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
EigenFunction2 First[phi2/.NDSolve[
{MyODE2/.lambda2 NonUniformEigenValues[[2]],
My2IC1,
My2IC2
],
phi2,{x,0,L]]];
(WWe are going to scale the eigenfunctions to normalize them so that we can compare the integration
their product to see if it is close to zero relative to 1.)
In[78]:= ScaleFactor1 1/(NIntegrate[EigenFunction1[x]^2 A[x], {x,0,L]])^(0.5)
ScaleFactor2 1/(NIntegrate[EigenFunction2[x]^2 A[x], {x,0,L]])^(0.5)
Out[78]= 0.000369061
Out[79]= 0.00931822
PDE Day 17. m 9
In[80]:= NIntegrate[ScaleFactor1EigenFunction1[x] ScaleFactor2EigenFunction2[x]A[x],{x,0,L]]
Out[80]= 0.00612448
In[81]:= (Since this number is small relative to 1, the nonuniform eigenfunctions
are orthogonal, which we expected based on the SturmLiouville Problem.)
10 PDE Day 17. m

Anda mungkin juga menyukai