Paul Summers Final Write Up
Paul Summers Final Write Up
Method
Paul Summers
December 5, 2012
U
2U
2 =0
t
x
U
2 x = 0
t
The system I chose to study was that of a hot object in a cold medium,
and document the time progression of various cases. This system is fairly
straight forward to relate to as it a situation we frequently encounter in daily
life. Heat transfer follows a few classical rules:
-Heat flows from hot to cold (Hight T to low T)
-Heat flows at rate proportional to the spacial 2nd derivative. This rate
is
-A change in heat results in a change in T
T = mCv Q
-Total heat energy must be conserved.
Such systems in general are equilibrium seeking, non-oscillatory systems
which approach the equilibrium state (constant T) asymptotically as time
progresses.
In my system we consider a grid of 100x100 particles with m = Cv = 1 and
constant across the whole grid. While this system is rather simplistic, it
still allows us to model and solve many complex and interesting distributions
of heat features.
i
h 2
2m
u
t
= F (u, x, t, u
, u)
x x2
2.1
1D Crank-Nicolson
In one dimension, the CNM for the heat equation comes to:
(n is the time step, i is the position):
a
un+1
uni
i
n
n
n
=
[(un+1 2un+1
+ un+1
i
i1 ) + (ui+1 2ui + ui1 )]
t
2(x)2 i+1
which allowing r =
at
2(x)2
simplifies to:
n+1
n
n
n
run+1
) run+1
i+1 + (1 + 2rui
i1 = rui+1 + (1 2rui ) + rui1
2.2 2D Crank-Nicolson
which can be solved for un+1
rather simply from the equation:
i
Au
n+1 = B u
n
where A and B are tridiagonal matrices and u
n is the vector representation
of the 1D grid at time n.
2.2
2D Crank-Nicolson
In two dimensions, the CNM for the heat equation comes to:
un+1
uni
a
i
=
[(un+1 +un+1 +un+1 +un+1 4un+1
)+(uni+1,j +uni1,j +uni,j+1 +uni,j1 4uni )]
i
t
2(x)2 i+1,j i1,j i,j+1 i,j1
assuming x = y and letting =
at
(x)2
gives us:
n+1
n
n+1
n
n+1
n
n+1
n
n
(1+2)un+1
i,j (ui+1,j +ui1,j +ui,j+1 +ui,j1 ) = (12)ui,j + (ui+1,j +ui1,j +ui,j+1 +ui,j1 )
2
2
or if we allow the use of the operators x2 and y2 where:
x2 fi,j = fi+1,j 2fi,j + fi1,j
2 2 n+1
x y )ui,j = (1 + x2 + y2 )uni,j
2
2
2
2
which is very nice and pretty, but not too much fun solve. So we go in search
of a different equation to solve. Let us consider:
(1
x )(1 y2 )un+1
x )(1 + y2 )uni,j
i,j = (1 +
2
2
2
2
0
*0
*
2 2 2
2 2 2
2 n
x y +
yx2 )un+1
=
(1
+
)u
i,j
2
2
2 2
2 x 2 y
2 y 2 x i,j
2.2 2D Crank-Nicolson
The advantage of this new form is that it allow us to solve in two steps
with the help of an intermediate value u
(1
2
x )ui,j = (1 + y2 )uni,j
2
2
2 n+1
y )ui,j = (1 + x2 )ui,j
2
2
which is confirmed to be a valid method by multiplying the upper by
(1 + 2 x2 ) and the lower by (1 2 x2 ) which yields:
(1
(1
x )(1 y2 )un+1
x )(1 x2 )ui,j = (1 + x2 )(1 + y2 )uni,j
i,j = (1 +
2
2
2
2
2
2
2
x )(1 y2 )un+1
x )(1 + y2 )uni,j
i,j = (1 +
2
2
2
2
which is exactly what we were going for. This 2 step process allows us to
handle 1 dimension at a time which allows the use of matrix notation just like
before, almost. By naively solving the 1D case twice, we would be tempted
to solve for
(1 x2 )ui,j = (1 + x2 )uni,j
2
2
2 n+1
(1 y )ui,j = (1 + y2 )ui,j
2
2
which looks close, but is not correct. The issue lies in that previously, we
were always taking derivatives in the same dimension we were evaluating, i.e.
taking x derivatives along the x axis of a vector or matrix. But now we have
to compare the x2 and y2 operators. Naturally we chose to evaluate a whole
row/column of the grid at once, and so the operator in the same direction is
easy (matrix-vector multiplication like in 1D) but the other operator gives us
some trouble. The issue with the off-axis operator is that unlike the on-axis
operator the j+1 and j-1 terms are not on the row/column you are currently
evaluating, and so could not simply be solved using traditional vector/matrix
multiplication since as those j+1 and j-1 values would not be in the vector.
A solution becomes clear when we take a step back, and realize we dont
need to try and find some matrix-like solution, rather all we needed is the
vector result of the operator, and so we can simply apply the off-axis operator
via the roll function. Once we have the off-axis operator figured, the rest of
the program falls into place and we are ready to test.
(1
3
3.1
Testing
Numeric Accuracy
After testing for a few differing values of x and we become satisfied with
the accuracy of the simulation given t = .25, which will be the default
unless otherwise noted.
3.2
Energy Conservation
We then can go on to test the energy conservation of our system. For a test
run of 1024 steps with a complex initial heat map we find the average energy
of the system to stay constant!
3.3
Unconditional Stability
Though we can see significant lack of accuracy from the cross section and
heat map at t = 20, the system does stay stable, conservers energy, and even
happens upon the correct equilibrium solution!
3.4
We will discuss the evolution of a paraboloid later, but for now we can use
it as a helpful example of the periodic boundary conditions of our system.
As you can see, rotational symmetry is broken due to the non-symmetric
distribution of neighbors, resulting in an angled checker-board pattern. It
should be noted that effect is not a computational error, but rather an artifact
of the boundary conditions.
3.5
Testing Conclusion
10
4
4.1
Case Studies
Small Ring
We have already covered the case of a delta function in our error analysis, so
let us move on to a similar but more exciting case, a small hot ring.
The ring begins to cool much like we would have expected, keeping its circular
shape, but then after 128 steps when t 30, we see an interesting shift. The
twin peaks we can the cross section begin to move towards each other,
before merging and resembling the gaussian shape we would expect from a
delta function. This makes sense because to a large enough approximation
(x r) a hot circle does resemble a delta function, so its not surprising to
find that they have similar solutions after a reasonable amount of time has
passed.
11
4.2
U-Shaped Disturbance
We can first see the hard edges round out on the U, giving it a more truly
round U shape. We then begin to see bay left at the center of the U begin
to heat much faster than the surroundings, similar to the heating of the inside
of the circle. But eventually, like always the heat profile begins to resemble
that of a gaussian, though this time it appears less symmetric, not doubt an
artifact of its asymmetric initial condition.
12
4.3 Rods
4.3
Rods
We again see the sharp edges very quickly cool and round out. This can
be explained by the high 2nd derivative at these sharp edges resulting in
a rapid cooling. The opposite effect can be noted on the interior, which is
relatively flat and does not cool much until it begins to have a significant
curve to it. This is a nice visual example of how the magnitude of the spacial
2nd derivative determines the rate of cooling, as indicated was indicated by
the original heat equation.
13
4.4 Cone
4.4
Cone
To further prove this point, we can consider the case of a cone, where initial
the 2nd derivative is 0 everywhere except at the tip and edges.
14
4.5 Paraboloid
4.5
Paraboloid
15
Conclusion
As a final visual treat, here is a full run of 1024 steps on a complex heat
map. See if you can spot any heat features we may have discussed earlier!
I hope you have found this short introduction and explanation of the 2D
Heat Equation modeled by the Crank-Nicolson method as interesting as I
found the topic. If you have any questions, please feel free to ask away!
16
References
17