Baitoantruyennhiet Vidu
Baitoantruyennhiet Vidu
Baitoantruyennhiet Vidu
nb
In[544]:= ClearAll[A]
A = 0.208
Out[545]= 0.208
The values c1 , c2 , c3 , ... are the Fourier sine coefficients of the constant function 10-7 :
In[549]:= c[n_] = %
nπ 2
Sin 2
Out[549]=
2 500 000 n π
t 2 π2 (t-s)1002
We compute an (t) by the formula an (t) = ∫0 e-An cn ⅆs.
In[550]:= ClearAll[a, n, x, t]
IntegrateExp-A n^2 Pi^2 (t - s) / 100^2 c[n], {s, 0, t}
2 2 nπ 2
ⅇ-0.000205288 n t -0.000620222 + 0.000620222 ⅇ0.000205288 n t Sin 2
Out[551]=
n3
In[553]:= ClearAll[u, x, t, M]
u[x_, t_, M_] := Suma[t, n] Sinn Pi x / 100, {n, 1, M}
We can easily look at some "snapshots" of the solution. For example, we will show the concentration distribution after 10
minutes (600 seconds). Some trial and error may be necessary to determine how many terms in the Fourier series are
required for a qualitatively correct plot. (As discussed in the text, this number decreases as t increases, due to the smooth-
ing of the solution.)
0.00006
0.00005
0.00004
Out[555]= 0.00003
0.00002
0.00001
20 40 60 80 100
The wiggles at the top of the arch suggest that we did not use enough terms in the Fourier series, so we try again with more
terms. (Of course, perhaps those wiggles are really part of the solution. In that case, they will persist when we draw the
graph with more terms.)
82 mathtut2Open.nb
0.00006
0.00005
0.00004
Out[556]= 0.00003
0.00002
0.00001
20 40 60 80 100
0.00006
0.00005
0.00004
Out[557]= 0.00003
0.00002
0.00001
20 40 60 80 100
mathtut2Open.nb 83
In[558]:= Plot[{u[x, 600, 10], u[x, 600, 20], u[x, 600, 40]}, {x, 0, 100}, PlotRange → All]
0.00006
0.00005
0.00004
Out[558]= 0.00003
0.00002
0.00001
20 40 60 80 100
The above graphs suggest that 20 terms is enough for a qualitatively correct graph at t=600.
which is the result of applying the finite element method to the heat equation.
To solve a specific problem, we have to compute the mass matrix M, the stiffness matrix K, the load vector f, and the initial
data α0 . The techniques should by now be familiar.
Example 6.8
An 100 cm iron bar, with ρ=7.88 gcm3 , c=0.437 J/(g K), and κ=0.836 W/(cm K), is chilled to an initial temperature of 0
degrees, and then heated internally with both ends maintained at 0 degrees. The heat source is described by the following
function:
84 mathtut2Open.nb
In[561]:= ClearAll[F, x, t]
F[x_, t_] = 10^(-8) t x (100 - x)^2
t (100 - x)2 x
Out[562]=
100 000 000
Next we define the stiffness matrix (for this constant coefficient problem, there is no need to perform any integrations---we
already know the entries in the stiffness matrix):
In[569]:= ClearAllK, i, j
K = Table0.0, i, 1, n - 1, j, 1, n - 1;
DoKi, i = 2 k / h, i, 1, n - 1
DoKi, i + 1 = -k / h;
Ki + 1, i = Ki, i + 1, i, 1, n - 2
The load vector f = f (t) (which is a vector-valued function) can be computed with the Table command:
mathtut2Open.nb 85
In[580]:= ClearAll[f, t]
f[t_] = TableIntegrateF[x, t] × phi1x, i, x, i * h - h, i * h +
IntegrateF[x, t] × phi2x, i, x, i * h, i * h + h, i, 1, n - 1;
In[582]:= ClearAll[a0]
a0 = Table0.0, i, 1, n - 1;
Now we choose the time step and the number of time steps, and invoke the backward Euler method:
Finally, we set up a table of data and display the result at time t=10. Note that U[[steps+1,1]] is the final time (in this case,
t = 180) and U[[steps+1,2]] is the vector of nodal values of the piecewise linear function approximating u(x, t) for this
value of t.
86 mathtut2Open.nb
4
Out[592]=
3
20 40 60 80 100
In[593]:= ClearAll[u, x, y]
u[x_, y_] = 1 / (1 + (x + y / 2)^2)
1
Out[594]=
y 2
1 + x + 2
mathtut2Open.nb 87
Out[595]=
If you would like to see the surface from a different angle, you can click on the figure and rotate it by moving the mouse
(i.e. put the pointer on the figure, hold down the left mouse button, and move the mouse).
The method of characteristics reduces the PDE in Example 8.6 to the IVP
dv 1
= v2 , v (0) = .
dt 1 + s2
If no initial condition is given, DSolve will return the general solution of the ODE:
88 mathtut2Open.nb
DSolve will solve a system of ODEs (when possible). Here is the system of ODEs from Example 8.7:
dx
= v, x (0) = s,
dt
dy
= y, y (0) = 1,
dt
dv
= x, v (0) = 2 s.
dt
As an example, we compute the Fourier double sine series of the following function f on the unit square: