Ontheonedimensional Stefanproblem - DiVA portal647481/FULLTEXT01.pdf · Ontheonedimensional...
Transcript of Ontheonedimensional Stefanproblem - DiVA portal647481/FULLTEXT01.pdf · Ontheonedimensional...
On the one dimensionalStefan problemwith some numerical analysis
Tobias Jonsson
Spring 2013Thesis, 15hpBachelor of Mathematics, 180hpDepartment of Mathematics and Mathematical Statistics
SammanfattningI den här uppsatsen presenteras Stefanproblemet med två olika randvillkor, ettkonstant och ett tidsberoende. Det här problemet är ett klassiskt exempel på ettfrirandsproblem där randen rör sig med tiden, inom partiella differentialekva-tioner. För det endimensionella fallet visas specifika egenskaper och det viktigaStefanvillkoret härleds. Betydelsen av maximumprinciper och existensen av enunik lösning diskuteras. För att lösa problemet numeriskt, görs en analys igränsvärdet t→ 0. Approximativa lösningar fås till Stefanproblemet, som visasgrafiskt med tillhörande feluppskattningar.
AbstractIn this thesis we present the Stefan problem with two boundary conditions,one constant and one time-dependent. This problem is a classic example of afree boundary problem in partial differential equations, with a free boundarymoving in time. Some properties are being proved for the one-dimensional caseand the important Stefan condition is also derived. The importance of themaximum principle, and the existence of a unique solution are being discussed.To numerically solve this problem, an analysis when the time t goes to zerois being done. The approximative solutions are shown graphically with propererror estimates.
Contents1 Introduction 4
1.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2 Historical background . . . . . . . . . . . . . . . . . . . . . . . . 51.3 Physical background . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 One dimensional Stefan problem 82.1 The Stefan condition . . . . . . . . . . . . . . . . . . . . . . . . . 82.2 The melting problem in one dimension . . . . . . . . . . . . . . . 11
2.2.1 Rescaling the problem into a dimensionless form . . . . . 122.2.2 Similarity solution . . . . . . . . . . . . . . . . . . . . . . 132.2.3 Nonlinearity . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3 The maximum principle . . . . . . . . . . . . . . . . . . . . . . . 182.4 Existence and uniqueness . . . . . . . . . . . . . . . . . . . . . . 20
3 Numerical analysis 213.1 Finite difference method . . . . . . . . . . . . . . . . . . . . . . . 21
3.1.1 Forward Euler scheme . . . . . . . . . . . . . . . . . . . . 213.1.3 Crank-Nicholson scheme . . . . . . . . . . . . . . . . . . . 24
3.2 Analysis when t→ 0 . . . . . . . . . . . . . . . . . . . . . . . . . 263.2.1 Constant boundary condition . . . . . . . . . . . . . . . . 263.2.2 Time-dependent boundary condition . . . . . . . . . . . . 28
3.3 Numerical method for solving the Stefan problem . . . . . . . . . 293.3.1 Constant boundary condition . . . . . . . . . . . . . . . . 293.3.2 Time-dependent boundary condition . . . . . . . . . . . . 33
3.4 Error analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4 Discussion 384.1 Future studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5 List of notations 39
F Appendix 40
G Appendix 47
Bibliography 54
1 IntroductionA Stefan Problem is a specific type of boundary value problem for a partialdifferential equation concerning heat distribution in a phase changing medium.Since the evolving interface is a priori unknown, a part of the solution will beto determine the boundary. An example is the diffusion of heat in the melt-ing of ice, and as the melting occurs the boundary of the ice will be changingposition. The problem is by some authors denoted as a "free boundary valueproblem" due to the boundary of the domain is a priori unknown [1] [5] [6].To distinct the case of a moving boundary (associated with a time-dependantproblem) from the problem with stationary boundary a few authors denote thelatter as a "moving boundary problem" [3]. To stick with the common notation,the term "free boundary problem" will be used in this thesis and denote boththe time-dependant and the stationary boundary.
To achieve a unique solution for a Stefan Problem there needs to be two bound-ary condition, one to determine the a priori unknown boundary itself and one isas usual a suitable condition on the fixed boundary. The natural occurrence ofa Stefan problem is mostly associated with the melting and solidification prob-lems, however there also exist some Stefan-like problems, for instance the fluidflow in porous media or even shock waves in gas dynamics [12].
A precise formulation of a Stefan problem is not possible, however we can listsome characteristic factors regarding this type of problems. To mention a few ex-amples of common features we have: (1) The heat distribution and heat transferis described by equations, (2) there exist a distinct interface (or phase change-boundary) between two phases (or more), which are distinguishable from eachother, (3) the temperature of the interface is a priori known [6].
To facilitate the reading, a list of notations used throughout the text is givenat the end of the thesis.
1.1 ObjectivesThe objectives of this thesis is to get a mathematical understanding of theproblem with an unknown free boundary in one dimension. That includes toexplain the mathematical model, derive the analytic solution and discuss thevalidity of the solution. For an even more explaining picture we would like toinclude two different kinds of boundary condition and also a numerical analysis,with simulated solutions. Due to the fact of numerical approximations, an erroranalysis is of course required.
4
1.2 Historical backgroundThe first known paper about diffusion of heat in a medium with a change ofphase state was published by the french mathematicians Gabriel Lamé andBenoît Paul Émile Clapeyron in 1831 [7]. The stated problem was to cool aliquid filling the halfspace x > 0 and determine the thickness of the generatedsolid crust, with a constant boundary condition at x = 0. They discovered thatthe thickness of the crust is proportional to the square root of the time, but nodetermination of the coefficient of proportionally was attached.
Almost 60 years later in 1889 was this question picked up and stated in amore general form by the Austrian physicist and mathematician Joseph Stefan[12]. Joseph Stefan published four papers describing mathematical models forreal physical problems with a change of phase state. This was the first generalstudy of this type of problem, since then free boundary problems are called Ste-fan problems. Of the four papers published it was the one about ice formationin the polar seas that has drawn the most attention, which can be found in[14]. The given mathematical solution was actually found earlier by the Ger-man physicist and mathematician Franz Ernst Neumann in 1860. It is calledthe Neumann solution [15].
1.3 Physical backgroundThe melting of ice and solidification of water are two examples of somethingcalled a phase transformation, which is a discontinuous change of the propertiesin the substance. The different states of aggregation in the transition are calledphases and they share the same physical properties (for instance density andchemical composition), therefore a phase is more specific then a state of matter.As a phase transition occurs, there will appear a latent heat which either isabsorbed or released by the body/thermodynamic system without changing thetemperature. Heat itself is a mechanism of energy transport between objectsdue to a difference in temperature. It is synonymous with heat flow and we sayit is the flow of energy from a hotter body to a colder one. Temperature canbe seen as a measure of an object’s "willingness" or more precise probability togive up energy. Heat flow may be understood with statistical mechanics whichuses probability theory applied on thermodynamics. For further reading, thereexists a good and gentle introduction to thermodynamics and statistical physics[13]. In the case of heat conduction, i.e., heat transfer by direct contact, onemight wonder at what rate the heat flows between a hot object and a cold one.To obtain an equation describing the heat distribution, consider any open andpiece-wise smooth region Ω where Ω ⊂ Rn, with a boundary ∂Ω. By naturalassumption the rate of change of a total quantity should be equal to the netflux through the boundary ∂Ω:
d
dt
∫Ω
u dV = −∫∂Ω
F · ν dS =∫
Ω−divF dV, (1.1)
where u is the density of some quantity (such as heat), ν being the unit normalpointing inwards and F being the flux density. In the last equality of equation(1.1) we used Gauss’s theorem under the condition that the flux function Fdefined on the domain Ω is continuously differentiable. Assuming that u and ut
5
exist and are continuous, we can use Leibniz’s rule for differentiation under theintegral sign on the first integral in equation (1.1),
∫Ω
∂u
∂tdV =
∫Ω−divF dV. (1.2)
We present here a classical result:
Theorem 1.3.1. Let f be any function such f ∈ C(Ω) where Ω ⊂ Rn,
If∫V
f dV (x) = 0, for all test volumes V ⊂ Ω, then
f ≡ 0 on Ω. (1.3)
Proof. Assume f 6≡ 0, then at a point x0 ∈ Ω, f(x0) = λ > 0 (The proof for theother case is similarly). But since f is continuous we have for any ε, for instanceε = λ
2 > 0, there is a δ > 0 such that if
|x− x0| < δ, x ∈ Ω⇒
|f(x)− f(x0)| < ε = λ
2
(1.4)
which implies that
λ
2 < f(x) < 3λ2 (1.5)
and by integrating the inequality above (1.5) over the test volume V∫V
f(x) dx >∫V
λ
2 dx = λ
2 × volume(V ) > 0. (1.6)
Therefore we can conclude that ∫V
f(x) dx > 0 (1.7)
we must have a contradiction and thus is f ≡ 0.
By writing equation (1.2) as ∫Ω
∂u
∂t+ divF dV = 0 (1.8)
we must conclude from Theorem 1.3.1 that
ut = −divF. (1.9)
6
The flux density F is often proportional to the negative gradient of u (minussince the flow is from higher heat to lower heat):
F = −αDu (α > 0) (1.10)
where α is the thermal diffusivity. Assuming that α is constant, we get byequation (1.10) and equation (1.9) the heat equation:
ut = α div(Du) = α∆u. (1.11)
7
2 One dimensional Stefan problemWe will now formulate the most simple form of a mathematical model describingphase transitions. The classical Stefan problem is a solidification and a melt-ing problem, for example the transition between ice and water. To acquire asolution for the classical Stefan problem, the heat equation needs to be solved.As mentioned before, a boundary condition on the evolving boundary is neededto get a unique solution. It is called "the Stefan condition" and will be derivedbelow. In this chapter we will follow the ideas from [2].
2.1 The Stefan conditionThe evolving unknown interface is denoted as x = s(t), where x is the positionin space; s(t) is the free boundary and t is the time. To derive the Stefancondition we need to make some assumptions. As the transitions occur therewill be a small volume change, although here, we will ignore this property infavour for simplicity. By physical reason the temperature should be continuousat the interface x = s(t) between the phases:
limx→s(t)+
uS(x, t) = limx→s(t)−
uL(x, t) = um for all t. (2.1)
The phase-change temperature between the two phases is assumed to be of con-stant value, um. At a fixed time t = t0 consider a domain Ω with two differentphases separated at x = s(t0), which can be seen in Figure 1. We assume planesymmetry to have the temperature u to depend on only t and x.
Ω1(Liquid phase)
Ω2(Solid phase)
s(t) x
Figure 1: Domain Ω separated into two phases at x = s(t) which are Ω1 =Ω ∩ x < s(t) and Ω2 = Ω ∩ x > s(t).
Assume the case of the interface evolving to the right, i.e, when the solid ismelting. Thus we should expect that u ≥ um in the liquid phase and u ≤ um inthe solid phase. At time t = t0 consider a portion of the interface, for simplicityin the shape of a disk A with area S. Later at time t1 > t0 the position ofthe interface has changed to s(t1) > s(t0). Meanwhile a cylinder of volumeS × (s(t1)− s(t0)) has melted and therefore released a quantity of heat Q:
Q = S(s(t1)− s(t0))× ρl, (2.2)
where l is the specific latent heat and ρ is the density. The heat flux
8
φL = −KLDuL (2.3)φS = −KSDuS (2.4)
where Ki is the is the material’s conductivity for liquid with i = L and solidi = S, and we assume u ∈ C1. By energy conservation it is natural to assumethat the total heat absorbed in equation (2.2) is equal to
Q =∫ t1
t0
∫A
[φL · x+ φS · (−x)]dAdτ =∫ t1
t0
∫A
[−KLDuL(s(τ), τ) · x−KSDuS(s(τ), τ) · (−x)]dAdτ,(2.5)
where x is the unit vector in the x−direction. Integrating expression (2.5) overthe spatial coordinates gives
Q = A∫ t1
t0
[−KL∂uL∂x
(s(τ), τ) +KS∂uS∂x
(s(τ), τ)]dτ (2.6)
we assume this to be equal to expression (2.2). Equating equation (2.2) and(2.6), we get
(s(t1)− s(t0)) ρl =∫ t1
t0
[−KL
∂uL∂x
(s(τ), τ) +KS∂uS∂x
(s(τ), τ)]dτ (2.7)
divide by (t1 − t0) and take the limit t1 −→ t0 ends up with:
lρ limt1→t0
s(t1)− s(t0)t1 − t0
= limt1→t0
1t1 − t0
∫ t1
t0
[−KL
∂uL∂x
(s(τ), τ) +KS∂uS∂x
(s(τ), τ)]dτ.
(2.8)
Theorem 2.1.1 (The Intermediate Value Theorem). Let f : [a, b] → R andf ∈ C, then f attains all values between the endpoints f(a) and f(b).
Proof. Is given by for instance [10]
Theorem 2.1.2 (The Extreme value theorem). A continuous function f ona bounded and closed interval [a, b], attains both a maximum and a minimumvalue at least once.
Proof. Is given by for instance [10]
Theorem 2.1.3 (The Mean-Value Theorem for integrals). If f : [a, b] → R andf ∈ C on [a, b], then there exists a number c ∈ [a, b] such that∫ b
a
f(x) dx = (b− a)f(c). (2.9)
9
Proof. It follows from Theorem 2.1.2 that a continuous function f(x) has aminimum value m and a maximum value M on a interval [a, b]. From themonotonicity of integrals and m ≤ f(x) ≤M , it follows that
mI =∫ b
a
m dx ≤∫ b
a
f(x)dx ≤∫ b
a
M dx = MI (2.10)
where
I ≡∫ b
a
dx = b− a (2.11)
using equation (2.11) and dividing by I (assuming I > 0) in equation (2.10)gives
m ≤ 1b− a
∫ b
a
f(x)dx ≤M. (2.12)
From the extreme value theorem we know that both m and M is attained atleast once by the integral. Therefore the Intermediate value theorem says thatthe function f attains all values in [m,M ], more specific it exists a c ∈ [a, b]such that
f(c) = 1b− a
∫ b
a
f(x)dx. (2.13)
We can with help of Theorem 2.1.3 write equation (2.8) as
lρs′(t1) = limt1→t0
1t1 − t0
× (t1 − t0)f(c) (2.14)
where we introduced a new function (for simplicity)
f(c) ≡ −KLux(s(c), c) +KSux(s(c), c) (2.15)
and c ∈ [t0, t1]. But as t0 → t1 and f is continuous (u ∈ C1), then
lρs′(t1) = f(t1). (2.16)
However since the same procedure could be done at any time t instead of t1, wecould instead write
lρs′(t) = f(t) (2.17)
and hence with our expression for f we reach
lρds
dt= KSux(s(t), t)−KLux(s(t), t) (2.18)
which is called the Stefan condition and is a boundary condition on the freeboundary [2].
10
2.2 The melting problem in one dimensionThe one-dimensional one phase problem could be represented as a semi-infinitesolid, for instance a thin block of ice occupying 0 ≤ x <∞ at the solidificationtemperature u = 0. An assumption needed is that we ignore any volume changein the solidification. At the fixed boundary of the thin block of ice x = 0 therecould be many different type of "flux functions" f(t). For instance we couldhave a constant temperature which is above the solidification temperature i.eu0 > 0, or a function depending on time. We assume that the temperature inthe solid phase is being constant. Thus the problem is to find the temperaturedistribution in the liquid phase and the location of the free boundary s(t). Evenif there will be two phases present, the problem is called a one-phase problemsince it is only the liquid phase which is unknown.
The liquid region, 0 ≤ x < s(t)∂u∂t = KL
CLρ∂2u∂x2 = αL
∂2u∂x2 , The heat equation 0 < x < s(t), t > 0,
u(0, t) = f(t), Boundary condition, t>0,
u(x, 0) = 0, Initial condition.
The free boundary, x = s(t)
lρdsdt = −KL
∂u∂x , Stefan condition,
s(0) = 0, Initial position of the melting interface,
u(s(t), t) = 0, The Dirichlet condition at the interface,
i.e freezing temperature
Phase 2 −The solid region, s(t) < x <∞,
u(x, t) = 0, For all t, x ≥ s(t).(2.19)
The boundary condition at x = 0 could be anything, but in this thesis we willfollow [9] and consider the following cases:
(i) f(t) = 1,
(ii) f(t) = et − 1.(2.20)
Actually both of our problems could be solved exactly according to [9].
11
2.2.1 Rescaling the problem into a dimensionless form
The goal here is to rescale the problem into a more convenient form, and sincewe have a mathematical approach we only need to make sure that the newexpressions satisfy the necessary equations. Consider the following change ofvariables
u→ av,
t→ γτ(2.21)
where γ and a are constants. Put
a = γ2 = α (2.22)
where α 6= 0. With help of (2.21) and (2.22) we can show that the system ofequations in (2.19) could be transformed into
vτ = vxx, (2.23)
βddτ s(γτ) = −vx(s(γτ), γτ) (2.24)
v(x, 0) = 0 (2.25)v(0, γτ) = f(γτ)γ (2.26)
where β is lρKL
. Replace the functions by
s(γτ)→ σ(τ)f(γτ)→ F (τ)/γv(x, γτ)→ λ(x, τ)
(2.27)
and now
λτ (x, τ) = λxx(x, τ)
βddτ σ(τ) = −λx(σ(τ), τ)
(2.28)
however, in this thesis we make a mathematical approach, so we change theletters
σ → s
τ → t
λ→ u
F → f.
(2.29)
And we get the rescaled problem as
ut = uxx
u(0, t) = f(t)u(x, 0) = 0
βdsdt = −ux(s(t), t).
(2.30)
12
2.2.2 Similarity solution
Here will we consider the Stefan problem defined in system (2.19) with condition(i) at the boundary x = 0 and derive an explicit expression for the solution,
ut = αLuxx, 0 < x < s(t), t > 0 (2.31)u(s(t), t) = 0, t ≥ 0 (2.32)
lρdsdt = −KLux(s(t), t), t > 0 (2.33)
s(0) = 0 (2.34)u(0, t) = u0 > 0, t > 0. (2.35)
If we first consider the ordinary rescaled heat equation ut − uxx = 0 a solu-tion on the bounded domain 0 < x < s(t) is found by a change of variableswith dilatation scaling. By similar argument we try to introduce the similarityvariable
ξ = x√t
(2.36)
and thus seeks a solution of the form
u(x, t) = F (ξ(x, t)) (2.37)
where F (ξ) is an unknown function yet to be found. Substituting equation(2.37) in the heat equation (2.31) gives
∂u
∂t(x, t) = dF
dξ∂ξ
∂t= −x
2t√t
dFdξ (2.38)
∂u
∂x(x, t) = dF
dξ∂ξ
∂x= 1√
t
dFdξ (2.39)
αL∂2u
∂x2 (x, t) = αL1√t
ddξ
(dFdξ
)∂ξ
∂x= αL
1t
d2F
dξ2 . (2.40)
Equation (2.38) and (2.40) gives the second order linear homogeneous differen-tial equation
d2F
dξ2 + ξ
2αLdFdξ = 0 (2.41)
which can be solved with an integrating factor
M(ξ) = e
∫ ξs0
s2αL
ds = C1eξ2
4αL (2.42)
where C1 is an integration constant. M(x) in equation (2.42) is multiplied withequation (2.41) and by identifying the product rule we have
d2F
dξ2 M(ξ) + ξ
2αLM(ξ)dFdξ = d
dξ
(M(ξ)dFdξ
)= 0 (2.43)
and by integrating equation (2.43) we get
13
M(ξ)dFdξ = C2 (2.44)
where C2 is an integration constant. From the fundamental theorem of calculusthe solution of equation (2.44) is
F (ξ) = C
∫ ξ
0e− s2
4αL ds+D (2.45)
where D is an integration constant. By using the substitution y = s√2αL
,equation (2.45) could be written in terms of the error function (defined in ’Listof notations’)
F (ξ) = A erf(
ξ
2√αL
)+D (2.46)
and thus the solution to equation (2.31) is
u(x, t) = F ( x√t) = Aerf
(x
2√tαL
)+D. (2.47)
From the boundary condition at x = 0 and x = s(t) we get
D = u0 (2.48)
and
A = 0− u0
erf(λ) (2.49)
whereλ ≡ s(t)
2√tαL
(2.50)
since A in equation (2.49) is a constant, it follows that λ must also be constant,thus
s(t) = 2λ√αLt (2.51)
and with the constants A and D, the solution is:
u(x, t) = u0 −u0
erf(λ)erf(
x
2√αLt
). (2.52)
About the parameter λThe Stefan condition at the free boundary x = s(t) is
lρdsdt = −KLux(s(t), t) (2.53)
and the time derivative of s(t) is
ds(t)dt = d
dt(2λ√αLt
)= λ
√αL√t
(2.54)
and for the other derivative in the Stefan condition we need to first take thespatial derivative of the solution u given by equation (2.52)
14
ux(x, t) = − u0
erf(λ)2√π
ddx
∫ x
2√αLt
0e−y
2dy = − u0
erf(λ)1√π
e− x2
4αLt
√αLt
(2.55)
and at x = s(t)
ux(s(t), t) = − u0
erf(λ)e−λ
2
√αLt√π. (2.56)
By putting in equation (2.56) and (2.54) in the Stefan condition (2.53) andsolving for λ, we get the following transcendental equation
λeλ2erf(λ) = KL
ρlαL
u0√π
= CL(u0)√πl≡ StL√
π(2.57)
where StL is the Stefan number [1].
Summing up the solution of u(x, t) and s(t), and the condition for λ, givesu(x, t) = u0 − u0
erf(λ)erf(
x2√αLt
)s(t) = 2λ
√αLt
λeλ2erf(λ) = StL√
π.
(2.58)
15
2.2.3 Nonlinearity
If we look at the problem before the free boundary s(t) we have only the heatequation, which is a linear equation. Now we want to analyse the problem howit behaves at the free boundary x = s(t). As shown in section 2.1 with energyconservation, the boundary condition at the free boundary is
−KL∂u
∂x(s(t), t) = lρ
dsdt . (2.59)
The value at the free boundary is
u(s(t), t) = 0 (2.60)for any t, where s(t) ∝
√t, which can be seen in Figure 2.
t
x=s(
t)
Liquidphase
Solidphase
Figure 2: The free boundary s(t) against time t.
The curve of the free boundary in the (x, t)-plane could be described with
r(t) = (x(t), t) = (s(t), t). (2.61)The rate of change of the temperature u is then the directional derivative of ualong v = dr
dt .
v ·Du = ∂u
∂x
dsdt + ∂u
∂t= 0 (2.62)
and thus
∂u
∂x= −
∂u∂tdsdt. (2.63)
16
By multiplying equation (2.59) with equation (2.63) gives
−KL
(∂u
∂x(s(t), t)
)2= −lρ∂u
∂t(s(t), t) = − lK
C
∂2u
∂x2 (s(t), t) (2.64)
which implies that the Stefan problem is a nonlinear problem.
17
2.3 The maximum principleIn our domain of interest, the solution is given by the heat equation, which wegive a discussion about here.
A very common and important tool in the study of partial differential equationsis the maximum principle. The maximum principle is nothing more than a gen-eralization of the single variable calculus fact that the maximum of a functionf is achieved at one of the endpoints a and b of the interval [a, b] where f ′′ > 0.Hence we could say more generally that functions which satisfy a differentialinequality in any domain Ω posses a maximum principle, since their maximumis achieved on the boundary ∂Ω. The maximum principle help us obtain infor-mation about the solution of a differential equation even without any explicitinformation of the solution itself. For example, the maximum principle is animportant tool when an approximative solution is searched for. The followingtheory could be found in [11].
Definition 2.3.1 (The parabolic boundary). Since the heat equation is oftenprescribed with its temperature initially and at the endpoints. The most naturalapproach is to consider the region
ET = (x, t) : 0 < x < l(t), 0 < t ≤ T (2.65)
in the (x, t)-plane. We suppose that the temperature is known on the remainingsides of ET :
S1 : x = 0, 0 ≤ t ≤ T, S2 : 0 ≤ x ≤ l(t), t = 0,
S3 : x = l(t), 0 ≤ t ≤ T.
Lemma 2.3.2. Assume the function u(x, t) ∈ C2(1) and satisfies the differential
inequality
L[u] ≡ ∂2u
∂x2 −∂u
∂t> 0 (2.66)
in ET . Then u cannot attain its maximum value at the interior of the closureET of ET .
Proof. Assume that u obtain its maximum value at an interior point P = (x0, t0)of E. As the point P is a critical point, the derivative ut is 0 and since it is amaximum uxx(x0, t0) ≤ 0. However this contradicts L[u] > 0 and thus cannotu have a maximum at an interior point.
Theorem 2.3.3 (The weak maximum principle). Suppose the function u(x, t)satisfies the differential inequality
L[u] ≡ ∂2u
∂x2 −∂u
∂t≥ 0 (2.67)
in the rectangular region ET given by (2.65). Then the maximum value of u onthe closure ET must occur on one of the remaining boundaries S1, S2 orS3.
18
Proof. Let M be the largest value of u that occur on S1, S2 and S3 and assumethat there is a point in the interior P = (x0, t0) where u(x0, t0) = M1 > M .
Define the help function
w(x) = M1 −M2l2 (x− x0)2, (2.68)
from w and u we define the function
v(x, t) ≡ u(x, t) + w(x). (2.69)
On the boundaries S1, S2 andS3 we have u ≤M and 0 < x < l and thus
v(x, t) ≤M + M1 −M2 < M1. (2.70)
At the interior point (x0, t0) we have
v(x0, t0) = u(x0, t0) + 0 = M1 (2.71)
and in ET we have
L[v] ≡ L[u] + L[w] = L[u] + M1 −Ml2
> 0. (2.72)
From the conditions (2.70) and (2.71) we can conclude that the maximumv(x0, t0) must be attained either on the interior of E or along
S4 : 0 < x < l <, t = T
From lemma 2.3.2 we know that the inequality (2.72) gives us no possibilityfor an interior maximum. If we instead would have a maximum on S4, we get∂2v∂x2 ≤ 0 which implies that ∂v
∂t
∣∣t=T < 0. Hence must v have a larger value at an
earlier time t < T and from this contradiction we can see that our assumptionu(x0, t0) > M is wrong.
Remark. Notice that Theorem 2.3.3 is only the weak maximum principle andthe theorem permits the maximum to occur on the interior points as well, inaddition to the boundary [11].
Theorem 2.3.4 (The strong maximum principle). Suppose that there is a(x0, t0) inET such that u(x0, t0) = maxET u. Then is u(x, t) ≡ u(x0, t0) forall (x, t) ∈ ET .
Proof. The proof could be found in [11]
19
2.4 Existence and uniquenessTo be "allowed" to use any kind of numerical analysis in this thesis it is essentialto show that this problem is well-posed. A well-posed problem for a partialdifferential equation is required to satisfy following criteria, e.g. [4]:
1. A solution to the problem exists
2. The solution is unique
and
3. The solution depends continuously on the given data
To give any conclusions about the solution to a partial differential equation, werequire the existence of a unique solution. If we would not have one uniquesolution any prediction made, would depend on which of the solutions we havechosen to be the "right" one. The last requirement is important in the problemsfrom physical applications, since it is preferable if our solution would not changemuch when the initial conditions are perturbed.We therefore need to present and give a proof of the existence and uniquenessof the Stefan Problem defined in (2.19). In this thesis we present a special caseof the theorem stated in the book by Friedman [5, p.216], due to less generalboundary conditions in (2.19).
Theorem 2.4.1 ([5], Theorem 1, page 216). For boundary condition u(0, t) =f(t) (which is continuously differentiable) and u(x, 0) =constant there exists aunique solution u(x, t), s(t) of the system in (2.19) for all t <∞.
Proof. The proof is beyond the scope of this thesis and could be found in thebook by Avner Friedman [5, p.222].
When we now know that there truly exist one unique solution to (2.19) we canshow the following theorem:
Theorem 2.4.2 ([5], Theorem 1, page 217). If u and s(t) gives a solution to(2.19) for all t < σ, where σ is a finite number, then x = s(t) is a monotonenon-decreasing function.
Proof. From the weak Maximum Principle given by Theorem 2.3.3 we know thatu(x, t) ≥ 0 for 0 < x < s(t). Since the temperature u is 0 at the boundary x =s(t), the rate of change in temperature with respect to x at the free boundaryx = s(t) is lesser or equal to 0. Thus we get from the Stefan condition thatdsdt ≥ 0, i.e, the free boundary s(t) is monotone non-decreasing.
20
3 Numerical analysisThe theory of partial differential equation is of fundamental importance fornumerical analysis. At the undergraduate level the main goal in partial differ-ential equations is to find solutions that could be expressed explicitly in termsof elementary functions. There exist several methods of finding those solutionsto various problem, but to most problems an explicit solution could not befound. When this occurs, numerical methods are useful to give some furtherinformation about the problem and the solutions. In differential equations thecontributions from analysis often lies in to find conditions to ensure uniquenessand existence of the solution, not construct the explicit solution. Both the caseof the existence of an unique solution and the reverse case are interesting tostudy in their own way. When searched for existence and uniqueness in analy-sis, the problems are posed on an infinite dimensional space. This is a contrastto numerical analysis, where the problems are discrete and posed on a finite di-mensional space. In addition to the existence and uniqueness which are neededto be found valid for different discretizations, error estimates are also requiredto be found for the approximations.
There does not exist any general numerical algorithm to every PDE you mayencounter, but in reality there are a lot of different types of numerical schemesdepending on what problem you need to approximate. To approximate the so-lution of a partial differential equation with numerical methods, the procedurescan be largely decomposed into two types. In the first procedure the solution issearched for at a finite number of nodes in the domain of definition. The otherprocedure is about expanding the solution as a sum of basis functions definedon the domain of definition and find the coefficients for this expansion. In thisthesis we are only going to look at the first procedure, namely a finite differencemethod.
3.1 Finite difference methodThe main idea of the finite difference method is to use approximation of theappearing derivatives in a PDE by sums and differences of function values. Thefunction values are defined on a discrete set of points (nodes), which often areuniformly spaced. In this thesis the 1 dimensional heat equation is considered.Two methods will be used, the Forward Euler scheme and Crank-Nicholsonscheme.
3.1.1 Forward Euler scheme
Forward Euler is a numerical method for approximating solutions to differentialequations. This method is explicit since we can express the solution at timestep n+ 1 in terms of the values of former step n. To demonstrate this methodlet us start out with a simple example:
21
ut = uxx (x, t) ∈ (0, 1)× (0,∞),
u(x, 0) = v(x) in (0, 1),
u(0, t) = u(1, t) = 0, for t > 0.
(3.1)
The first step of this procedure is to make space and time discrete. Put
x→ xj = x0 + jh j = 0, 1, 2...M ,
t→ tn = t0 + nk n = 0, 1, 2...
where x0 = t0 = 0, M the number of nodes, k the size of the time step and h isspatial step given by
h = 1M. (3.2)
We denote the numerical solution Unj of u as
Unj ≈ u(jh, nk). (3.3)
which is the approximative solution of u at time step n and spatial step j. Forthe spatial derivatives, introduce the forward and backward difference quotientswith respect to space and time as
∂xUnj = Unj+1−U
nj
h , ∂xUnj = Unj+1−U
nj
h
∂xUnj = Unj −U
nj−1
h ∂xUnj = Unj −U
nj−1
h .(3.4)
The Forward Euler example stated in equation (3.1) is written as
∂tU
nj = ∂x∂xU
nj for j = 1, ...,M.1, n ≥ 0
Un0 = UnM = 0, for n > 0,
U0j = Vj = v(xj), for j = 0, ...,M.
(3.5)
By introducing the mesh ratio λ = kh2 and solving for Un+1
j in equation (3.5),we get
Un+1j = λ(Unj−1 + Unj+1) + (1− 2λ)Unj (3.6)
Un+10 = Un+1
M = 0 (3.7)U0j = v(xj) (3.8)
and equation (3.6) in matrix form
Un+1 = AUn (3.9)
where Un denotes the (M − 1)−vector related to Un and A is a symmetrictridiagonal coefficient matrix given by:
22
A =
1− 2λ λ 0 . . . 0
λ 1− 2λ λ. . .
...
0. . . . . . . . . 0
.... . . λ 1− 2λ λ
0 . . . 0 λ 1− 2λ
. (3.10)
This method is however only first order accurate in time, and second order inspace as can seen in the Theorem 3.1.2 below. This means that the error intime will dominate unless the time step k is much smaller than the spatial steph. The Forward Euler scheme is stable when the mesh ratio λ ≤ 1
2 ,[8, thm 9.5].
Theorem 3.1.2. Let Un and u be the solutions of (3.5) and (3.1), withλ = k
h2 ≤ 12 and u being fourth order continuous differentiable, then
‖Un − un‖∞,h ≤ Ctnh2maxt≤tn|u(x, t)|C4 , for t ≥ 0,
Proof. See [8, thm 9.5].
Theorem 3.1.2 gives us an error estimate for the numerical approximation, andfor this numerical scheme we have a quite restrictive stability condition betweentime step k and spatial step h. With this method it is not possible to have thesame order of magnitude in k and h and still maintain stability.
To give an example of what happens to the numerical simulation with a λ ≥ 1/2,we plot the maximum norm against tn with the forward Euler scheme shown inFigure 3.
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.090
0.5
1
1.5
2
tn
||Un −
un || ∞
Euler forward with λ = 1/1.9
Figure 3: Plot of the maximum norm of the error against time for the forwardEuler scheme with λ > 1/2.
23
3.1.3 Crank-Nicholson scheme
Another finite difference scheme is the Crank-Nicholson method which is animplicit method, which uses a symmetry around a middle point, (xj , tn+1/2),where
tn+1/2 = tn+1 + tn
k. (3.11)
Due to the implicit scheme an algebraic system must thus be solved for each timestep. The example given in equation (3.1) with the Crank-Nicholson method isthen defined as
∂tU
n+1j = 1
2∂x∂x(Unj + Un+1j ) for j = 1, ...,M − 1, n ≥ 0
Un+10 = Un+1
M = 0, for n > 0,
U0j = Vj = v(xj), for j = 0, ...,M.
(3.12)
Rewriting the first equation in (3.12) as
(I − 12k∂x∂x)Un+1
j = (I + 12k∂x∂x)Unj (3.13)
where I is the (M − 1)-Identity matrix, and then using the defined differencequotients and collecting similar terms, we get
(1 + λ)Un+1j − 1
2λ(Un+1j−1 + Un+1
j+1 ) = (1− λ)Unj + 12λ(Unj−1 + Unj+1). (3.14)
The matrix form is
BUn+1 = AUn (3.15)where both A and B are tridiagonal matrices given by
B =
1 + λ − 12λ 0 . . . 0
− 12λ 1 + λ − 1
2λ. . .
...
0. . . . . . . . . 0
.... . . − 1
2λ 1 + λ − 12λ
0 . . . 0 − 12λ 1 + λ
and
A =
1− λ 12λ 0 . . . 0
12λ 1− λ 1
2λ. . .
...
0. . . . . . . . . 0
.... . . 1
2λ 1− λ 12λ
0 . . . 0 12λ 1− λ
.
24
Solving equation (3.15) we get the solution at time (n+ 1)
Un+1 = B−1AUn. (3.16)
Previously we had the forward Euler method with only a first order of accuracyin time, which together with the stability criteria limited our numerical analysis.We can see in the Theorem 3.1.4 that the Crank-Nicholson method is secondorder accurate in time. This method give us no time step restriction.
Theorem 3.1.4. Let Un and u be the solutions of (3.12) and (3.1), with ubeing sixth order continuous differentiable, then
‖Un − un‖2,h ≤ Ctn(h2 + k2)maxt≤tn|u(x, t)|C6 , for t ≥ 0,
Proof. The proof of this Theorem could be found in [8].
25
3.2 Analysis when t→ 0The problem (2.19) gets a degeneracy as t→ 0, since the thickness of the meltregion is initially zero according to equation (2.34). To solve this problem, wedo a change of variable as in the paper by S.L. Mitchell and M. Vynnycky [9].Another goal here is to attain an initial condition for the new variables. It isa good idea to work in the transformed coordinates suggested by the analyticalsolution given by (2.47), and we therefore set
ξ = xs(t) , u = h(t)F (ξ, t), (3.17)
where h(t) is chosen to ensure that we get a well-posed problem as t→ 0. Thespace derivative, in the new coordinates are
∂u
∂x= h(t) ∂
∂ξ
(F (ξ, t)
) ∂ξ∂x
= h(t)s(t)
∂F
∂ξ, (3.18)
and
∂2u
∂x2 = ∂
∂ξ
(h(t)s(t)
∂F
∂ξ
) ∂ξ∂x
= h
s(t)2∂2F
∂ξ2 , (3.19)
moreover, the time derivative ut takes the form
∂u
∂t= dh(t)
dt F + h(t)(∂F
∂t+ ∂F
∂ξ
∂ξ
∂t
)= dh
dt F + h
(∂F
∂t− ξ
s
dsdt∂F
∂ξ
). (3.20)
By equating ut and uxx and multiplying s2 on both sides we end up with
h∂2F
∂ξ2 = s
[sdhdt F + sh
∂F
∂t− ξdsdt
∂F
∂ξ
]. (3.21)
3.2.1 Constant boundary condition
Let β = lρK , and for the boundary conditions (i) in (2.20) we have
h∂2F
∂ξ2 = s
[sdhdt F + sh
∂F
∂t− ξdsdt
∂F
∂ξ
](3.22)
subject to
F = 0, at ξ = 1, (3.23)
F = 1h(t) , at ξ = 0, (3.24)
βs(t)dsdt = −h∂F∂ξ
, at ξ = 1. (3.25)
We need to pick a function h(t) such that F is independent of t as t→ 0. Sincethe numerator in equation (3.24) is constant, we can choose any constant value
26
to be h(t), to attain the necessary boundary condition, as in system (2.19). Asimple and good choice is therefore h(t) = 1. By using equation (2.51) withα = 1, we get s(t) = 2λ
√t. Equation (3.21) will thus reduce to
∂2F
∂ξ2 = −2λ2ξ∂F
∂ξ, (3.26)
with the boundary conditions
F (1) = 0 F (0) = 1 2λ2β = −∂F∂ξ
∣∣∣∣ξ=1
. (3.27)
The equation (3.26) could be solved in a similar way as the previous differentialequation found in equation (2.41) and thus is the solution
F (ξ) = 1− erf(λξ)erf(λ) , (3.28)
this solution is valid in t→ 0. Where the constant λ satisfies (2.57).
27
3.2.2 Time-dependent boundary condition
The case (ii) in (2.20) is a time-dependent condition and we need to make surethat F (0, t) is independent of time in the limit t→ 0. The boundary conditionis
F = e(t)−1h(t) at ξ = 0 (3.29)
and to choose h(t), we look at the Taylor expansion of et − 1 around t = 0
f(t) ∼ t+ t2
2 + t3
6 +O(t4). (3.30)
Hence in the limit as t→ 0 an appropriate choice would be h(t) = t. The Stefancondition will thus take the form
s(t)dsdt = O(t) (3.31)
and by integrating both sides with initial condition s(0) = 0, we get an expres-sion for the free boundary
s(t) = γt, (3.32)
where γ is a proportionality constant, which according to Theorem 2.4.2 mustbe positive. System (3.22) with h(t) = 1 will in the limit t→ 0 be
∂2F
∂ξ2 = 0 (3.33)
subject to
F (1) = 0 F (0) = 1 γ2β = −∂F∂ξ
∣∣∣∣ξ=1
(3.34)
and the solution is
F (ξ) = 1− ξ. (3.35)
From the Stefan condition we get
γ = ± 1√β, (3.36)
where the positive solution is chosen, as proven in Theorem 2.4.2.
28
3.3 Numerical method for solving the Stefan problemAs seen previously the Crank-Nicholson method is a sufficient stable methodfor the heat equation. We will therefore use the Crank-Nicolson scheme toapproximate the solution of the Stefan problem under the assumption that thediscretization of ξ and t is uniform.
3.3.1 Constant boundary condition
For the first case in equation (3.24) at ξ = 0, we have h(t) = 1 and to simplifythe algebra, we put z ≡ s2. The system in equation (3.22) will therefore takethe appearance:
∂2F∂ξ2 = z ∂F∂t −
ξ2
dzdt∂F∂t ,
F = 0, at ξ = 1,β2
dzdt = −∂F∂ξ , at ξ = 1,
F = 1, at ξ = 0,
(3.37)
with the condition z(0) = 0. We apply a discretization using the same methodas in section (3.1.3) to acquire the Crank-Nicolson scheme. The scheme uses acentral difference at time tn+1/2 and a second-order central difference for thespatial derivative at position ξj . By applying the Crank-Nicolson method as insection (3.1.3), we will end up with
12
(Fn+1j+1 − 2Fn+1
j + Fn+1j−1
h2
)+(Fnj+1 − 2Fnj + Fnj−1
h2
)= zn+1/2
[Fn+1j − Fnj
k
]
−ξj2zn+1 − zn
k
[12
(Fn+1j+1 − F
n+1j−1
2h
)+ 1
2
(Fnj+1 − Fnj−1
2h
)].
(3.38)The system (3.38) is according to (3.12) valid for j = 1, 2, ...,M − 1 and n =0, 1, 2, ... . The boundary conditions become
β2
(zn+1−zn
k
)= − 1
2
(Fn+1M+1−F
n+1M−1
2h
)− 1
2
(FnM+1−F
nM−1
2h
)Fn+1
0 = 1
Fn+1M = 0.
(3.39)
To be able to approximate this numerically we need to write (3.38) in matrixform, and take into account that F = 1 at ξ = 0. Using the same notation andregrouping system (3.38) we have
L = 12h2
(Fn+1j+1 −2Fn+1
j +Fn+1j−1
)− z
n+1/2
kFn+1j + z′
8hξj(Fn+1j+1 −F
n+1j−1
)(3.40)
29
and
R = − 12h2
(Fnj+1 − 2Fnj + Fnj−1
)− zn+1/2
kFnj −
z′
8k ξj(Fnj+1 − Fnj−1
), (3.41)
wherez′ = zn+1−zn
k zn+1/2 = zn+1+zn2 (3.42)
and L and R denote the side at time (n + 1) and (n). To take care of theboundary condition Fn+1
0 = 1 we evaluate equation (3.40) (equation (3.41) isdone in a similar way) at j = 1 :
Lj=1 = 12h2
(Fn+1
2 −2Fn+11 +Fn+1
0=1
)− z
n+1/2
kFn1 + z′
8k ξ1(Fn+1
2 −Fn+10
=1
). (3.43)
Sort out the two constant vectors(due the boundary condition) we could putthem together into one constant vector
C ≡
12h2 − z′
8hξ1
0...
0
. (3.44)
Furthermore the coefficient matrix of the first parenthesis in equation (3.40) is
A = 12h2
−2 1 0 . . . 0
1 −2 1. . .
...
0. . . . . . . . . 0
.... . . 1 −2 1
0 . . . 0 1 −2
(3.45)
and the second coefficient matrix in equation (3.40) is
B = 18h
0 ξ1 0 . . . . . . 0
−ξ2 0 ξ2. . . . . .
...
0 −ξ3 0 ξ3 . . . 0
0. . . . . . . . . . . . 0
.... . . . . . −ξM−2 0 ξM−2
0 . . . . . . 0 −ξM−1 0
. (3.46)
Then the system (3.38) could be written in matrix form as
30
(A− zn+1/2
kI + z′B
)Fn+1 =
(− zn+1/2
kI − z′B −A
)Fn − 2C, (3.47)
where I is the (M − 1)−Identity matrix, andDenote the two tridiagonal matrix in equation (3.47) as L and R (as in left andright) and then equation (3.47) could be written as
LFn+1 = RFn − 2C (3.48)
where
L =(A− zn+1/2
k I + z′B), R =
(− zn+1/2
k I − z′B −A). (3.49)
and
C =
12h2 − z′
8hξ1
0...
0
. (3.50)
The approximated Stefan condition in equation (3.39) include the extrapolatedvalues Fn+1
M+1 and FnM+1. To approximate this problem we evaluate equation(3.38) at j = M and thus we can eliminate the extrapolated values by somealgebra. This will lead us to the following polynomial equation of second orderfor zn+1
βξM2k (zn+1)2 +
[− βξM
kzn + 2βr
v+ Fn+1
M − FnM]zn+1 + βξM
2k (zn)2
−2βrvzn + (2r + zn)FnM − 2r(Fn+1
M−1 + FnM−1) = 0.(3.51)
31
Flow chart The constant boundary condition
1. Start by introducing all the constants, "Allocate" memory for the vectors,and give the initial conditions their values.
2. From equation (2.57) we can use the Newton-Raphson method (found inthe appendix) to approximate the physical constant λ related to the givenvalue of β.
3. Start iterating a time loop for the whole problem. Because equation (3.38)involves z at time level (n+ 1), we need to iterate the value until a giventolerance is reached.
4. We use the starting guess for the free boundary to be the previous valuez(n) and with help of (3.51) we can update zn+1 until the tolerance isreached.
5. Convert back the values for the temperature and the free boundary. Savevalues at each time step for the exact solutions for both the free boundaryand the temperature, for later usage.
6. Plot both the numerical and the exact values for both the temperatureand the free boundary against time. Plot the error in the numerical tem-perature and the numerical free boundary against time.
32
3.3.2 Time-dependent boundary condition
For the second case in equation (3.24), h(t) = t
t∂2F∂ξ2 = s
[sF + st∂F∂t − ξt
dsdt∂F∂ξ
],
F = 0, at ξ = 1,
βsdsdt = −t∂F∂ξ , at ξ = 1,
F = et−1t , at ξ = 0.
(3.52)
By applying the Crank-Nicolson method as in section (3.1.3), we will end upwith
tn+ 12
[12
(Fn+1j+1 − 2Fn+1
j + Fn+1j−1
h2
)+ 1
2
(Fnj+1 − 2Fnj + Fnj−1
h2
)]=
(sn+ 1
2)2 1
2(Fn+1j + Fnj
)+ tn+ 1
2(sn+ 1
2)2Fn+1
j − Fnjk
−
ξjtn+ 1
2 sn+ 12 s′
[12
(Fn+1j+1 − F
n+1j−1
)+ 1
2
(Fnj+1 − Fnj−1
)], (3.53)
wheretn+ 1
2 = tn+1+tn2 sn+ 1
2 = sn+1+sn2 s′ = sn+1−sn
k . (3.54)
The system (3.53) is according to (3.12) valid for j = 1, 2, ...,M − 1 and n =0, 1, 2, ... . The boundary conditions become
βsn+ 12 s′ = − 1
2 tn+ 1
2
(Fn+1M+1−F
n+1M−1
2h
)− 1
2 tn+ 1
2
(FnM+1−F
nM−1
2h
)(3.55)
12
(Fn+1
0 + Fn0
)= 1
2
(etn+1−1
tn+1 + etn−1tn
)(3.56)
Fn+1M = 0. (3.57)
The system (3.53) involves s at the next time level, so an iteration is needed.We use the value at level n as starting guess for sn+1. To update the valueof sn+1 we use the Stefan condition in (3.55). However does equation (3.55)involve the two extrapolated values FnM+1 and Fn+1
M+1. To remove those values,we evaluate equation (3.53) at j = M and this leads to a quartic expression interms of sn+1 :
2r(tn+1+tn)(Fn+1M−1+FnM−1)−4β
v
[r+ξM
4h((sn+1)2−(sn)2)]((sn+1)2−(sn)2
)= 0.
(3.58)
33
To be able to approximate this numerically we need to write (3.53) in matrix
form, and take into account that 12
(Fn+1
0 + Fn0
)= 1
2
(etn+1−1
tn+1 + etn−1tn
)at
ξ = 0. Denote the left hand side of equation (3.53) as LH and evaluate at j = 1
LHj=1 := tn+ 12
2h2
[Fn+1
2 − 2Fn+11 + Fn+1
0 + Fn2 − Fn1 + Fn0
], (3.59)
and the right hand side of (3.53) at j = 1
RHj=1 :=(sn+ 1
2)2Fn+ 1
21 + tn+ 1
2(sn+ 1
2)2Fn+1
1 − Fn1k
− ξ1tn+ 1
2 sn+ 12 s′
4h[Fn+1
2 − Fn+10 + Fn2 − Fn0
] (3.60)
and then by replacing 12
(Fn+1
0 +Fn0
)with 1
2
(etn+1−1
tn+1 + etn−1tn
)in both RHj=1
and LHj=1, and collect the terms in a time-dependent vector as
D(t) =
(tn+ 1
22h2 −
ξ1tn+ 1
2 sn+ 12 sn+1−sn
k
4h
)(etn+1−1
tn+1 + etn−1tn
)0...
0
. (3.61)
Regrouping equation (3.53) we get
LFn+1 = RFn +D(t) (3.62)
with L := tn+ 12A−
(sn+ 1
2)2( 1
2 + tn+ 12
k
)I + tn+ 1
2 sn+ 12 s′B
R := −tn+ 12A+
(sn+ 1
2)2( 1
2 −tn+ 1
2k
)I − tn+ 1
2 sn+ 12 s′B
(3.63)
where I is the (M − 1)−Identity matrix, and the two other coefficient matrixare
A = 12h2
−2 1 0 . . . 0
1 −2 1. . .
...
0. . . . . . . . . 0
.... . . 1 −2 1
0 . . . 0 1 −2
(3.64)
34
and
B = 14h
0 ξ1 0 . . . . . . 0
−ξ2 0 ξ2. . . . . .
...
0 −ξ3 0 ξ3 . . . 0
0. . . . . . . . . . . . 0
.... . . . . . −ξM−2 0 ξM−2
0 . . . . . . 0 −ξM−1 0
. (3.65)
35
Flow chart The time-dependent boundary condition
1. Start by introducing all the constants, "Allocate" memory for the vectors,and give the initial conditions their values.
2. Start iterating a time loop for the whole problem, and because equation(3.53) involves s at time level (n+ 1), we need to iterate the value until agiven tolerance is reached for every time step.
3. Take care of the case with 0/0 separately at n = 1, where the values inthe limit t→ 0 is analysed previously in section (3.2.2).
4. Due boundary condition at ξ = 0 we get a time constant vector D forevery time step.
5. Introduce the right and left coefficient matrix for the expression LFn+1 =RFn +D and solve for Fn+1.
6. Solve the quartic equation with Newton-Raphson method (found in ap-pendix) with initial guess of sn+1 = sn.
7. When a sufficient good value of sn+1 is found we add the boundary con-ditions at ξ = 0 and ξ = 1. Avoid the 0/0 case at n = 1.
8. Convert back the values for the temperature and the free boundary. Savevalues at each time step for the exact solutions for both the free boundaryand the temperature, for later usage.
9. Plot both the numerical and the exact values for both the temperatureand the free boundary against time. Plot the error in the numerical tem-perature and the numerical free boundary against time.
36
3.4 Error analysisIn this section we would like to discuss the methods used around the numericalanalysis to measure the error.To investigate the error in the numerical analysis, we use the discrete l2-normdenoted by l2,h [8, p.133] for the temperature.The error in the l2-norm at time tn is given by
En := ‖Un − un‖2,h =
h M∑j=0
(U(xj , tn)− Unj )
1/2
, (3.66)
where U(xj , tn) is the exact solution at (xj , tn) and Unj is the numerical solution.The error for the free boundary at time tn is given by∣∣s(tn)− sn
∣∣. (3.67)
System (3.38) and (3.53) involves zn+1 and sn+1. To be able to get those valuewe do an iteration on zn+1 respectively sn+1 for a given tolerance ε using thesame value at level n as a starting guess. We get the new update from theStefan condition (3.39), and keep on updating until the tolerance is reached. Ifwe denote zn+1
m and sn+1m as the m : th iterated value of zn+1 and sn+1, we can
write a convergence criterion as∣∣zn+1m+1 − zn+1
m
∣∣ < ε∣∣sn+1m+1 − sn+1
m
∣∣ < ε.
37
4 DiscussionIn this thesis we have introduced the one-dimensional Stefan problem definedon a semi-infinite interval with two different type of boundary conditions. Theimportant Stefan condition for the free boundary was derived under the con-dition of equal densities for the two phases. That is not realistic, and evenfor water the small difference will give a volume change in the transition. Dueto the change in volume, another term will occur in the heat equation andalso change the appearance for the Stefan condition. By taking consideration ofthis small but realistic feature, the whole problem of ours will get more complex.
Another simplification in this thesis was the start temperature of the solid phase.If the (for our case) solid phase had another temperature then the melting point,a heat flux will flow back into the liquid phase. And thus attain another termfor the Stefan condition (seen in equation (2.1)). Furthermore we will need tosolve two different heat equations, separately describing the temperature in eachphase.
The numerical simulations was made with the Crank-Nicholson method, whichhave a second order accuracy in both time and space. This method uses animplicit discretization about (n+ 1
2 ), instead of a more straightforward explicitone. The numerical implementation is harder, but as shown previously, theexplicit scheme imposes both lesser accuracy and a restriction of our time step.
4.1 Future studiesIt does clearly exist a lot of opportunities to continue with similar problems thatI have been working on this semester. In this thesis only one time-dependentboundary condition was analysed and it does exist some other more realistic andexciting conditions, for instance; oscillating functions which could be describingthe variation of temperature over a day. Even further it could be possible toexpand the model, find an adequate real life problem. It would be very inter-esting to simulate nature itself.
Furthermore, this was a one-phase problem so we could extend our interestfor a problem with the temperature changing over time in both of the phases,two-phase problem. So the temperature would change in both the liquid phaseand the solid phase. For any problem we have discussed in this thesis, we haveskipped the density difference between the phases, which causes the liquid phaseto attain another velocity vector due to volume changes in the phase transition.
For the confident and brave person, the option to go up a dimension does alwaysexist. Look at some weak solutions and maybe discover something exciting. Butas far as that I have understood, the level of complexity do increase substantiallyas we go up in dimensions.
38
5 List of notationsx = s(t) The position of the free boundary.
C The specific heat capacity.
ρ The density of the specific material.
K Thermal conductivity.
α Thermal diffusivity.
l Latent heat.
Open set A set which does not contain any of its boundary points.
Rn The n-dimensional real Euclidian space, where R = R1.
Du Gradient vector := (ux1, ux2, ..., uxn).
Divu The divergence of a vector valued function :=∑ni=1
∂Fi∂xi
.
∂V The boundary of V .
V The closure is defined as ∂V ∪ V .
C A function defined on a set is said to be of class C (or C0) if it is continuous.
Thus, C is the class of all continuous functions.
CK A function defined on a set is of class CK if the first K derivatives exists and are
continuous.
Smooth or C∞. A function is said to be smooth if it has derivatives of all orders.
Test volume An open and connected subset of Rn whose boundary is "smooth" enough, but in
this essay we demand only C1 boundary.
C2(1) A function u is of class C2
(1) when its time derivative ut is continuous and its
spatial derivatives ux and uxx are continuous.
L A linear operator acting on functions.
erf(x) The error function, which is defined as erf(x) = 2√π
∫ x0 e−t2 dt.
O(hk) Truncation error - An approximation is of order k with respect to h, which mean
that the error is proportional to hk.
‖x‖ Norm, a measure of length or size of a vector in a vector space.
‖x‖∞ Maximum norm, the largest value of the vector x.
‖x‖2 l2-norm, is defined as(∑n
i=1 |xi|2)1/2
.
39
F AppendixTo visualize the approximate solutions for our problem given in (2.19), wepresent the plots here. We follow the paper by Mitchell and Vynnycky [9]and put
M = 10k = h = 1/Mβ = 0.2, 2 For boundary condition (i)β = 1 For boundary condition (ii),
where β = lρKL
and the boundary conditions both are given in the system (2.19).
Plots for the constant boundary condition with β = 2Using the method described in section 3.3.1 we present below the approximatesolutions for the temperature u and the free boundary s(t), shown in Figure 4and Figure 5. The error in s(t) and u which is defined in section 3.4, are alsogiven below, in Figure 7 and Figure 6.
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
x
U
Numerical solutionAnalytical solution
Figure 4: Plot of the temperature against the position for both the numericaland the analytical solution. β = 2.
40
0 0.2 0.4 0.6 0.8 10.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
tn
s(t)
Numerical solutionAnalytical solution
Figure 5: Plot of the free boundary against the time for both the numerical andthe analytical solution. β = 2.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.81.18
1.185
1.19
1.195
1.2
1.205
1.21
1.215
1.22x 10
−4
tn
En
Figure 6: Plot of l2−error for the temperature against time, with β = 2.
41
0 0.2 0.4 0.6 0.8 1
10−4
10−3
tn
|s(t
n )−sn |
Figure 7: Plot of the error in the free boundary s(t) for β = 2.
42
Plots for the constant boundary condition with β = 0.2Using the method described by section 3.3.1 we present below the approximatesolutions for the temperature u and the free boundary s(t), shown in Figure 8and Figure 9. The error in s(t) and u which is defined in section 3.4, are alsogiven below, in Figure 10 and Figure 11.
0 0.5 1 1.5 20
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
x
U
Numerical solutionAnalytical solution
Figure 8: Plot of the temperature against the position for both the numericaland the analytical solution. β = 0.2.
0 0.2 0.4 0.6 0.8 1
0.8
1
1.2
1.4
1.6
1.8
2
2.2
tn
s(t)
Numerical solutionAnalytical solution
Figure 9: Plot of the free boundary against the time for both the numerical andthe analytical solution. β = 0.2.
43
0 0.2 0.4 0.6 0.8 1
10−4
10−3
10−2
tn
|s(t
n )−sn |
Figure 10: Plot of the error in the free boundary s(t) for β = 0.2.
0 0.2 0.4 0.6 0.8 10
1
2
x 10−4
tn
En
Figure 11: Plot of l2−error for the temperature with β = 0.2.
44
Plots for the time-dependent boundary condition withβ = 1Using the method described by section 3.3.2 we present below the approximatesolutions for the temperature u and the free boundary s(t), given in Figure 12and Figure 13. The error in s(t) and u which is defined in section 3.4, are alsogiven below, in Figure 14 and Figure 15.
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
x
U
Numerical solutionAnalytical solution
Figure 12: Plot of the temperature against the position for both the numericaland the analytical solution.
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
tn
s
Numerical solutionAnalytical solution
Figure 13: Plot of the free boundary against the time for both the numerical andthe analytical solution.
45
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
10−4
10−3
10−2
tn
|s(t
n )−sn |
Error for the free boundary
Figure 14: Error in the free boundary s(t) against time.
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
1.12
1.14
1.16
1.18
1.2
1.22
1.24
1.26
1.28
1.3x 10
−4
tn
||U(t
n )−U
n || 2
Error for the temperature
Figure 15: Error in the temperature U against time tn.
46
GApp
endix
The
Stefan
Problem
-Con
stan
tbo
unda
rycond
ition
cle
ar
all
clo
se
all
%−−−−−−−−−−−−−−
CO
NST
AN
TS−−−−−−−−−−−−−−−−
%
%N
um
ber
of
no
de
sM
=1
0;
%S
pa
tia
lst
ep
siz
eh
h=
1/M
;%
tim
est
ep
siz
ek
k=h
;
%T
he
re
cip
ro
ca
ls
te
fan
nu
mb
er,
fou
nd
inth
es
te
fan
co
nd
itio
nb
eta
=0
.2;
%T
os
imp
lify
,d
en
ote
r=k
/h
^2
;v=
k/
h;
%P
hy
sic
al
co
nst
an
t,
de
cid
ed
by
the
st
efa
nc
on
dit
ion
lam
bd
a=
new
ton
(b
eta
);
%N
um
ber
of
tim
es
te
ps
NT
=M
;
%"
All
oc
at
e"
mem
ory
Err
or_
s=z
er
os
(M,1
);
Err
or_
F=
ze
ro
s(M
+1
,1)
;F
=z
er
os
(M+
1,1
);
F_
an
aly
tic
al=
ze
ro
s(M
+1
,1)
;F
_o
ld=
ze
ro
s(M−
1,1
);
F_
new
=F
_o
ld;
z=z
er
os
(2
,1)
;z
_e
rro
r=1
e−
12
;%
Th
ec
on
sta
nt
ve
cto
r,
tak
ing
ca
reo
fth
eb
ou
nd
ary
co
nd
itio
nF
_0=
1C
=z
er
os
(s
ize
(F
_o
ld)
);
Err
or_
U=
ze
ro
s(N
T,1
);
%T
he
no
de
va
lue
sfo
r\
xi
xi_
po
s=
(0:M
)∗
h;
%T
ime
ve
cto
rfo
ra
llti
me
ste
ps
t=
(0:N
T)
∗k
;
%C
oe
ffic
ien
tM
atr
ixe=
on
es
(M−
1,1
);
A=
1/
(2∗
h^
2)
∗s
pd
iag
s(
[e−
2∗e
e],−
1:1
,M−
1,M−
1)
;
xi_
ab
ov
e=x
i_p
os
(1
:M−
1)
';x
i_b
elo
w=
xi_
po
s(
3:M
+1
)';
B=
sp
dia
gs
([−
xi_
be
low
xi_
ab
ov
e],
[−1
1]
,M−
1,M−
1)
;B
=1
/(8
∗h
)∗B
;
I=sp
ey
e(M−
1)
;
%−−−−−−−−−
init
ial
co
nd
itio
ns−−−−−−−−−−−−
F=
1−e
rf
(la
mb
da
∗x
i_p
os
)/
er
f(
lam
bd
a)
;F
_o
ld=
F(
2:M
)';
%−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
%C
on
sta
nt
co
eff
icie
nt
for
eq
ua
tio
nre
ga
rdin
gZ
n+
1a=
be
ta∗
xi_
po
s(M
+1
)/
(2∗
k)
;
%it
er
at
ion
for
z^
(n
+1
)a
nd
the
init
ial
gu
ess
z(2
)=z
(1)
,i.
ez
^(
n+
1)=
z^
nfo
rn
=1
:NT
z_
err
or=
1e−
12
;w
hil
ez
_e
rro
r>1
e−
13
%z
(n+
1/
2)
an
d(
dz
/d
t)
^n
z_
ha
lf=
(z
(2)+
z(1
))
/2
;z_
pri
m=
(z(2
)−z
(1)
)/
k;
%T
he
co
eff
icie
nt
ma
trix
for
the
mo
dif
ed
he
at
eq
ua
tio
n:
La
nd
R,
%L
∗U
n+1=
H∗
Un
C(1
)=−
xi_
po
s(2
)∗
1/
(8∗
h)
∗z_
pri
m+
1/
(2∗
h^
2)
;L
=(A−
z_
ha
lf/
k∗
I+z_
pri
m∗B
);
R=−
(z_
ha
lf/
k∗
I+A
+z_
pri
m∗B
);
%S
olv
efo
rU
^(
n+
1)
wit
ho
ur
gu
ess
F_
new
=L
\(R
∗F
_o
ld−
2∗C
);
%S
ome
co
eff
icie
nt
sfo
rth
eq
ua
dra
tic
eq
ua
tio
ng
ivin
gz
^(
n+
1)
b=−
be
ta∗
xi_
po
s(M
+1
)/k
∗z
(1)
+2∗
be
ta∗
r/
v;
c=b
eta
∗x
i_p
os
(M+
1)
/(2
∗k
)∗
(z
(1)
)^2−
2∗
be
ta∗
r/
v∗
z(1
)−
2∗r
∗(F
_n
ew(
M−
1)+
F_
old
(M−
1)
);
%r
oo
ts
for
the
qu
ad
rati
ce
qu
ati
on
reg
ard
ing
zn+
1z
1=
(−b+
sq
rt
(b^2−
4∗
a∗
c)
)/
(2∗
a)
;z
2=
(−b−
sq
rt
(b^2−
4∗
a∗
c)
)/
(2∗
a)
;
%c
he
ck
ifw
eg
et
co
mp
lex
ro
ot
s
47
ifb
^2<
4∗
a∗
cd
isp
('C
om
ple
xr
oo
ts
for
z(n
+1
)')
bre
ak
;en
d
%S
av
es
the
old
va
lue
of
z(n
+1
)z
old
=z
(2)
;
%z
sho
uld
be
po
sit
ive
,fo
rn
atu
ral
rea
son
s,
up
pd
ate
for
z(n
+1
)if
z1>
z2
z(2
)=z
1;
els
ez
(2)=
z2
;en
dz
_e
rro
r=a
bs
(z
(2)−
zo
ld)
;en
d
%A
dd
the
bo
un
da
ryc
on
dit
ion
sF
(2
:M)=
F_
new
;F
(1)
=1
;F(end)
=0
;
%−−−−
co
nv
ert
ba
ckth
ev
alu
es
of
the
fre
eb
ou
nd
ary
at
t^
(n
+1
)−−−−−
%
s_n
um
=s
qr
t(
z(2
))
;%
Th
ee
xa
ct
fun
ct
ion
for
the
fre
eb
ou
nd
ary
s_e
xa
ct=
2∗la
mb
da
∗s
qr
t(
t(n
+1
))
;%
Th
ee
rr
or
for
sa
tti
me
ste
pt
^(
n+
1)
Err
or_
s(n
)=a
bs
(s_
nu
m−
s_e
xa
ct
);
%C
on
ve
rtb
ack
toth
ete
mp
era
ture
U=
h(
t)F
wh
ere
h(
t)=
1U
_nu
m=
1∗F
;%
Th
ee
xa
ct
tem
pe
ratu
rea
tt
^(
n+
1)
U_
exa
ct=
1−e
rf
(x
i_p
os
∗s_
nu
m/
(2∗
sq
rt
(t
(n+
1)
))
)/
er
f(
lam
bd
a)
;
%E
rro
rfo
rth
ete
mp
era
ture
at
tim
est
ep
t^
nE
rro
r_U
(n)=
sq
rt
((
h∗
sum
((
U_
exa
ct−
U_
num
).
^2
))
);
%%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%−−−−−−−−−−−−
TH
EP
LO
TS−−−−−−−−−−−−
%fi
gu
re
(1)
plo
t(
xi_
po
s∗
s_n
um
,U_
num
,'k
x'
,s_
nu
m∗
xi_
po
s,U
_ex
act
,'r−−
')if
n==
1le
ge
nd
('N
um
eri
ca
ls
olu
tio
n'
,'
An
aly
tic
al
so
lut
ion
')en
d
ifn=
=N
T
xla
be
l(
'x')
yla
be
l(
'U')
end
ho
ldo
n
fig
ur
e(2
)p
lot
(t
(n+
1)
,s_
nu
m,
'kx
',t
(n+
1)
,s_
ex
ac
t,
'ro
')if
n==
1le
ge
nd
('N
um
eri
ca
ls
olu
tio
n'
,'
An
aly
tic
al
so
lut
ion
')en
d
ifn=
=N
Tx
lab
el
('t
^n
')y
lab
el
('s
')en
dh
old
on
%p
lot
(t
(n+
1)
,s,
'kx
',
t(n
+1
),s
_e
xa
ct
,'r
o')
%h
old
on
%fi
gu
re
(2)
%su
bp
lot
(2
,1,2
)%
plo
t(
xi_
po
s∗
s,U
,'k
x'
,x
i_p
os
∗s
,U_
exa
ct,
'r−−
')%
ho
ldo
n%
leg
en
d(
'Bla
ck
isn
um
eri
ca
l')
%a
xis
([0
10
1])
%x
lab
el
('x
')%
yla
be
l(
'U')
F_
old
=F
_n
ew;
z=
[z(2
)z
(2)
];p
au
se(0
.1)
end
ho
ldo
ff
%T
he
Err
or
inth
ete
mp
era
ture
ag
ain
st
tim
efi
gu
re
(4)
plo
t(
t(2:end
),E
rro
r_U
,'k−−
')le
ge
nd
('E
rro
rfo
rth
ete
mp
era
ture
')x
lab
el
('t
^n
')y
lab
el
('
||U
(t
^n
)−U
^n
||_
2')
fig
ur
e(3
)p
lot
(t
(2:end
),E
rro
r_s
,'k
x')
leg
en
d(
'Err
or
for
the
fre
eb
ou
nd
ary
')x
lab
el
('t
^n
')y
lab
el
('
|s
(t
^n
)−s
^n
|')
48
The
Stefan
Problem
-Tim
e-de
pend
entbo
unda
rycond
ition
cle
ar
all
clo
se
all
%−−−−−−−−−−−−−−
CO
NST
AN
TS−−−−−−−−−−−−−−−−
%
%N
um
ber
of
no
de
sM
=1
0;
%S
pa
tia
lst
ep
siz
eh
h=
1/M
;%
tim
est
ep
siz
ek
k=h
;
%T
he
re
cip
ro
ca
ls
te
fan
nu
mb
er,
fou
nd
inth
es
te
fan
co
nd
itio
nb
eta
=1
;%
To
sim
pli
fy,
de
no
ter=
k/
h^
2;
v=k
/h
;
%P
hy
sic
al
co
nst
an
t,
de
cid
ed
by
the
st
efa
nc
on
dit
ion
lam
bd
a=
1/
sq
rt
(b
eta
);
%N
um
ber
of
tim
es
te
ps
NT
=M
;
%"
All
oc
at
e"
mem
ory
%E
rro
r_s=
ze
ro
s(M
,1)
;E
rro
r_U
=z
er
os
(M+
1,1
);
F=
ze
ro
s(M
+1
,1)
;F
_a
na
lyti
ca
l=z
er
os
(M+
1,1
);
F_
old
=z
er
os
(M−
1,1
);
F_
new
=F
_o
ld;
s=z
er
os
(2
,1)
;s_
err
or=
1e−
12
;D
=z
er
os
(s
ize
(F
_o
ld)
);
%T
he
no
de
va
lue
sfo
r\
xi
xi_
po
s=
(0:M
)∗
h;
%T
ime
ve
cto
rfo
ra
llti
me
ste
ps
t=
(0:N
T)
∗k
;
%C
oe
ffic
ien
tM
atr
ixe=
on
es
(M−
1,1
);
A=
1/
(2∗
h^
2)
∗s
pd
iag
s(
[e−
2∗e
e],−
1:1
,M−
1,M−
1)
;
xi_
ab
ov
e=x
i_p
os
(1
:M−
1)
';x
i_b
elo
w=
xi_
po
s(
3:M
+1
)';
B=
sp
dia
gs
([−
xi_
be
low
xi_
ab
ov
e],
[−1
1]
,M−
1,M−
1)
;B
=1
/(4
∗h
)∗B
;I=
spe
ye
(M−
1)
;
%−−−−−−−−−
init
ial
co
nd
itio
ns−−−−−−−−−−−−
F=
1−x
i_p
os
;F
_o
ld=
F(
2:M
)';
%−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
for
n=
1:N
Ts_
err
or=
1e−
12
;it
t=
0;
%it
er
at
ion
for
s^
(n
+1
)a
nd
the
init
ial
gu
ess
s(2
)=s
(1)
wh
ile
s_e
rro
r>
1e−
13
%s
at
tim
ep
os
ito
nn
+1
/2
s_h
alf
=(s
(2)+
s(1
))
/2
;%
Th
efo
rwa
rdti
me
dif
fer
en
ce
qu
oti
en
tfo
rs
s_p
rim
=(s
(2)−
s(1
))
/k
;%
ta
tn
+1
/2
t_h
alf
=(t
(n+
1)+
t(n
))
/2
;
%%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%F
ixin
gth
eti
me
co
nst
an
tD
(t
)%−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
%
c2=
xi_
po
s(2
)∗
t_h
alf
∗s_
pri
m∗
s_h
alf
/(4
∗h
);
c1=
t_h
alf
/(2
∗h
^2
);
%A
vo
idth
e0/
0−
ca
se,
sin
ce
t(1
)=0
ifn=
=1
Y=
(ex
p(
t(n
+1
))−
1)/
(t
(n+
1)
)+
1;
els
e
Y=
(ex
p(
t(n
+1
))−
1)/
(t
(n+
1)
)+(e
xp
(t
(n)
)−
1)/
(t
(n)
);
end
D(1
)=
(c2−
c1
)∗Y
;%−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
%
%%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%T
he
co
eff
icie
nt
ma
trix
for
F^
n+
1a
nd
F^
n;
LF
^n
+1
=R
F^
n
%−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
%
L=
t_h
alf
∗A−
((s_
ha
lf)
^2/
2+
t_h
alf
∗(
s_h
alf
)^2
/k
)∗
I+t_
ha
lf∗
s_h
alf
∗s_
pri
m∗B
;
49
R=−
t_h
alf
∗A+
((s_
ha
lf)
^2/
2−
t_h
alf
∗(
s_h
alf
)^2
/k
)∗
I−t_
ha
lf∗
s_h
alf
∗s_
pri
m∗B
;
%−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
%
%S
olv
efo
rth
en
ewv
alu
ea
tle
ve
ln
+1
F_
new
=L
\(R
∗F
_o
ld+
D)
;
%T
he
qu
ar
tic
eq
ua
tio
nin
term
so
fs
^n
+1
,
wh
ere
x:=
s^
n+
1fu
n=
@(
x)
2∗
r∗
(t
(n+
1)+
t(n
))
∗(F
_n
ew(M−
1)+
F_
old
(M−
1)
)−4∗
be
ta/
v∗
(r+
xi_
po
s(M
+1
)/
(4∗
h)
∗(
x^2−
(s
(1)
)^
2)
)∗
(x
^2−
(s
(1)
)^
2)
;%
Sa
ve
sth
eo
ldv
alu
eo
fs
(n+
1)
be
for
eth
eu
pd
ate
s_o
ld=
s(2
);
%N
ewto
n−ra
ph
son
met
ho
dw
ith
st
ar
tin
gg
ue
sso
fs
^n
s(2
)=n
ewto
n3
(fu
n,
s(1
))
;
%S
av
es
the
er
ro
rin
the
fre
eb
ou
nd
ary
at
the
m:
thit
er
at
ion
for
s^
n+
1s_
err
or=
ab
s(
s(2
)−s_
old
);
end
%%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%A
dd
ing
bo
un
da
ryc
on
dit
ion
s%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%F
(2
:M)=
F_
new
;%
Av
oid
ing
the
0/
0a
tn
=1
ifn=
=1
F(1
)=
1;
els
eF
(1)=
(ex
p(
t(n
+1
))−
1)/
(t
(n+
1)
)+(e
xp
(t
(n)
)−
1)/
(t
(n)
)−F
en
dp
oin
t;
end
F(end)
=0
;
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%
%−−−−
co
nv
ert
ba
cka
llth
ev
alu
es
at
t^
(n
+1
)−−−−−
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%
U_
num
=F
∗t
(n+
1)
;s_
nu
m=
s(2
);
%T
he
ex
ac
tfu
nc
tio
nfo
rth
efr
ee
bo
un
da
rya
nd
the
tem
pe
ratu
res_
ex
ac
t=1/
sq
rt
(b
eta
)∗
t(n
+1
);
%T
he
er
ro
rfo
rs
at
tim
est
ep
t^
(n
+1
)E
rro
r_s
(n+
1)=
ab
s(s
_n
um−
s_e
xa
ct
);
%T
he
ex
ac
tte
mp
era
ture
at
tim
ele
ve
lt
^(
n+
1)
U_
exa
ct=
exp
(t
(n+
1)−
s_e
xa
ct
∗x
i_p
os
)−
1;
%E
rro
rfo
rth
ete
mp
era
ture
at
tim
est
ep
t^
(n
+1
)E
rro
r_U
(n+
1)=
sq
rt
((
h∗
sum
((
U_
exa
ct−
U_
num
).
^2
))
);
%%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%−−−−−−−−−−−−
TH
EP
LO
TS−−−−−−−−−−−−
%fi
gu
re
(1)
plo
t(
xi_
po
s∗
s_n
um
,U_
num
,'k
x'
,s_
nu
m∗
xi_
po
s,U
_ex
act
,'r−−
')if
n==
1le
ge
nd
('N
um
eri
ca
ls
olu
tio
n'
,'
An
aly
tic
al
so
lut
ion
')en
d
ifn=
=N
Tx
lab
el
('x
')y
lab
el
('U
')
end
ho
ldo
n
fig
ur
e(2
)p
lot
(t
(n+
1)
,s_
nu
m,
'kx
',t
(n+
1)
,s_
ex
ac
t,
'ro
')if
n==
1le
ge
nd
('N
um
eri
ca
ls
olu
tio
n'
,'
An
aly
tic
al
so
lut
ion
')en
d
ifn=
=N
Tx
lab
el
('t
^n
')y
lab
el
('s
')en
dh
old
on
%%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%−−−−−−−−
Ov
erw
rite
the
old
va
lue
sfo
rth
en
ex
tti
me
loo
p−−−−−−−
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
%%
F_
old
=F
_n
ew;
Fe
nd
po
int=
F(1
);
s=
[s(2
)s
(2)
];
end
%T
he
Err
or
inth
efr
ee
bo
un
da
rya
ga
ins
tti
me
fig
ur
e(3
)p
lot
(t
,E
rro
r_s
,'k−−
')le
ge
nd
('E
rro
rfo
rth
efr
ee
bo
un
da
ry')
xla
be
l(
't^
n')
yla
be
l(
'|
s(
t^
n)−
s^
n|
')
%T
he
Err
or
inth
ete
mp
era
ture
ag
ain
st
tim
efi
gu
re
(4)
50
plo
t(
t,E
rro
r_U
,'k−−
')le
ge
nd
('E
rro
rfo
rth
ete
mp
era
ture
')x
lab
el
('t
^n
')y
lab
el
('
||U
(t
^n
)−U
^n
||_
2')
51
The
New
tonRap
hson
metho
d-constant
boun
dary
cond
ition
fun
ct
ion
[x
old
]=
new
ton
(b
eta
)
f=
@(
x)
sq
rt
(p
i)∗
be
ta∗
x∗
exp
(x
^2
)∗
er
f(
x)−
1;
fpri
m=
@(
x)
sq
rt
(p
i)∗
be
ta∗
(ex
p(
x^
2)
∗e
rf
(x
)+2∗
x^2
∗ex
p(
x^
2)
∗e
rf
(x
)+
2∗x
/s
qr
t(
pi)
);
xo
ld=
10
;w
hil
e1
xn
ew=
xo
ld−
f(
xo
ld)
/fp
rim
(x
old
);
tem
p=x
old
;
xo
ld=
xn
ew;
ifa
bs
(te
mp−
xo
ld)<
0.0
00
1b
rea
k;
end
end
end
52
The
New
tonRap
hson
metho
d-time-de
pend
entcond
ition
fun
ct
ion
[x
old
]=
new
ton
3(
f,
xo
ld)
%f
=@
(x
)s
qr
t(
pi)
∗b
eta
∗x
∗ex
p(
x^
2)
∗e
rf
(x
)−
1;
%fp
rim
=@
(x
)s
qr
t(
pi)
∗b
eta
∗(
exp
(x
^2
)∗
er
f(
x)+
2∗x
^2∗
exp
(x
^2
)∗
er
f(
x)+
2∗x
/s
qr
t(
pi)
);
fun
ct
ion
[fp
rim
]=fp
rim
(x
old
,h)
fpri
m=
(f
(x
old
+h
)−f
(x
old
))
/h
;en
d
it=
0;
%x
old
=1
0;
wh
ile
1x
new
=x
old−
f(
xo
ld)
/fp
rim
(x
old
,0.0
00
00
1)
;
tem
p=x
old
;it
=it
+1
;x
old
=x
new
;if
ab
s(
tem
p−x
old
)<0
.00
01
bre
ak
;en
d
end
end
53
Bibliography[1] V. Alexiades and A.D. Solomon. Mathematical Modeling of Melting and
Freezing Processes. Hemisphere Publishing Corporation, Washington, 1993.
[2] D. Andreucci. Lecture notes on the Stefan problem. 2002.
[3] J. Crank. Free and Moving Boundary Problems. Hemisphere PublishingCorporation, Washington, 1993.
[4] L.C. Evans. Partial Differential Equations. American Mathematical Soci-ety, Providence, Rhose Island, 2010.
[5] A. Friedman. Partial Differential Equations of Parabolic Type. Prentice-Hall, Inc, Englewood Cliffs, N.J., 1964.
[6] S.C. Gupta. The Classical Stefan Problem - Basic Concepts, Modelling andAnalysis. Elsevier Science B.V, Amsterdam, 2003.
[7] G. Lamé and B.P. Clapeyron. Mémoire sur la solidification par refroidisse-ment d’un globe liquide. Ann. Chem. Phys 47, pp. 250-256, 1831.
[8] S. Larsson and V. Thomée. Partial Differential Equations with NumericalMethods. Springer, Berlin, 2005.
[9] S.L. Mitchell and M. Vynnycky. Finite-difference methods with increasedaccuracy and correct initialization for one-dimensional Stefan problems.Applied Mathematics and Computation 215 1609-1621, 2009.
[10] F. Morgan. Real Analysis and Applications. American Mathematical Soci-ety, Providence, Rhode Island, 2005.
[11] M.H. Protter and H.F. Weinberger. Maximum Principles in DifferentialEquations. Prentice-Hall, Inc, London, 1967.
[12] L.I. Rubenstein. The Stefan Problem. American Mathematical Society,Providence, Rhode Island, 1971.
[13] D.V. Schroeder. An Introduction to Thermal Physics. Addison WesleyLongman, Boston, Massachusetts, 2000.
[14] J. Stefan. Über die Theorie der Eisbildung, insbesondere über die Eisbil-dung im Polarmeere. Ann. Physik Chemie 42, pp. 269–286, 1891.
[15] C. Vuik. Some historical notes about the Stefan problem. Nieuw Archiefvoor Wiskunde, 4e serie 11 (2): 157–167, 1993.
54