MovingBoundaryProblems1D
Documentation for MovingBoundaryProblems1D.
This is a package for solving one-dimensional single phase moving boundary problems using the finite volume method. The problems that can be solved using this package take the form
\[\begin{align*} \begin{array}{rcll} \dfrac{\partial u(x, t)}{\partial t} & = & \dfrac{\partial}{\partial x}\left(D\left(u(x, t), x, t\right)\dfrac{\partial u(x, t)}{\partial x}\right) + R\left(u(x, t), x, t\right) & 0 < x < L(t),\, t>0, \\[9pt] \dfrac{\partial u(0, t)}{\partial x} & = & a_0\left(u(0, t), t\right) & x = 0,\,t>0, \\[9pt] \dfrac{\partial u(L(t), t)}{\partial x} & = & a_1\left(u(L(t), t), t\right) & x=L(t),\,t>0, \\[9pt] \dfrac{\mathrm dL}{\mathrm dt} & = & a_2\left(u(L(t), t), t\right) + b_2\left(u(L(t), t), t\right)\dfrac{\partial u(L(t), t)}{\partial x} & x = L(t),\,t>0, \\[9pt] u(x, 0) & = & u_0(x) & 0 \leq x \leq L(0), \\[9pt] L(0) & = & L_0. \end{array} \end{align*}\]
You can also use Dirichlet boundary conditions rather than Neumann boundary conditions for $u(0, t)$ and $u(L(t), t)$. We also provide methods for computing steady states of the above problem. Examples of how to use the package are given in the sidebar.
MovingBoundaryProblems1D.BoundaryConditions
MovingBoundaryProblems1D.Dirichlet
MovingBoundaryProblems1D.MBGeometry
MovingBoundaryProblems1D.MBProblem
MovingBoundaryProblems1D.Neumann
MovingBoundaryProblems1D.Robin
MovingBoundaryProblems1D.SteadyMBProblem
MovingBoundaryProblems1D.scaled_mesh_points
MovingBoundaryProblems1D.BoundaryConditions
— TypeBoundaryConditions{L<:Union{<:Dirichlet, <:Neumann},R<:Union{<:Dirichlet, <:Neumann},M<:Robin}
The boundary conditions for the MBProblem
.
Fields
lhs::L
: The left-hand side boundary condition. Must beDirichlet
orNeumann
.rhs::R
: The right-hand side boundary condition. Must beDirichlet
orNeumann
.moving_boundary::M
: The moving boundary condition. Must beRobin
.
See also Dirichlet
, Neumann
, and Robin
for the types of boundary conditions you can construct.
MovingBoundaryProblems1D.Dirichlet
— TypeDirichlet{F,P} <: AbstractBoundaryCondition{F,P}
A Dirichlet boundary condition with fields f
and p
(default p = nothing
), with f
being a function of the form f(u, p)
and p
being the parameters for f
.
A Dirichlet boundary condition takes the form
\[u(a, t) ↤ f(u(a, t), t, p),\]
where a
is one of the endpoints.
Constructors
Dirichlet(f::Function, p = nothing) -> Dirichlet(f, p)
Dirichlet(; f, p = nothing) -> Dirichlet(f, p)
Dirichlet(v::Number) -> Dirichlet((u, t, p) -> oftype(u, v), nothing)
MovingBoundaryProblems1D.MBGeometry
— TypeMBGeometry{T}
Definition of the geometry for a moving boundary problem problem.
Fields
mesh_points::T
: The mesh points. Must be sorted and satisfymesh_points[begin] = 0
andmesh_points[end] = 1
(if they do not satisfy this, they are scaled first).spacings::T
: The spacings between the mesh points.volumes::T
: The volumes of the cells defined by the mesh points.
Constructors
To construct the geometry, you can directly call the default constructor,
MBGeometry(mesh_points, spacings, volumes)
or you can call the convenience constructor,
MBGeometry(mesh_points)
which will compute the spacings and volumes for you.
See also MBProblem
.
MovingBoundaryProblems1D.MBProblem
— TypeMBProblem{T,DF,DP,RF,RP,L,R,M,IC,IE,FT}
Definition of an MBProblem
.
Fields
geometry::MBGeometry{T}
: The geometry of the problem.boundary_conditions::BoundaryConditions{L, R, M}
: The boundary conditions.diffusion_function::DF
: The diffusion function, of the form(u, x, t, p) -> Number
, wherep = diffusion_parameters
.diffusion_parameters::DP
: The parameters for the diffusion function.reaction_function::RF
: The reaction function, of the form(u, x, t, p) -> Number
, wherep = reaction_parameters
.reaction_parameters::RP
: The parameters for the reaction function.initial_condition::IC
: The initial condition, withinitial_condition[i]
corresponding to the value atgeometry.mesh_points[i]
andt = initial_time
.initial_endpoint::IE
: The initial endpoint. This is the value of the moving boundary att = initial_time
.initial_time::FT
: The initial time.final_time::FT
: The final time.
See also SteadyMBProblem
.
Constructors
You can use the default constructor, but we also provide the constructor
MBProblem(;
geometry,
boundary_conditions,
diffusion_function,
diffusion_parameters = nothing,
reaction_function = Returns(0.0),
reaction_parameters = nothing,
initial_condition,
initial_endpoint,
initial_time = 0.0,
final_time)
which provides some default values. Moreover, instead of providing geometry
and boundary_conditions
, you can use
MBProblem(mesh_points, lhs, rhs, moving_boundary; kwargs...)
which will construct geometry = MBGeometry(mesh_points)
and boundary_conditions = BoundaryConditions(lhs, rhs, moving_boundary)
. The kwargs...
are as above, except without geometry
and boundary_conditions
of course.
To solve the MBProblem
, just use solve
as you would in DifferentialEquations.jl. For example,
sol = solve(prob, TRBDF2(linsolve=KLUFactorization()), saveat=0.1)
solves the problem using the TRBDF2()
algorithm, with the associated linear systems solved with the sparse solver KLUFactorization()
, and the solution will be saved every 0.1
units of time from initial_time
up to, and including, final_time
. The solution in this case will be such that sol.u[i]
has the values of u
in sol.u[i][begin:(end-1)]
, and the position of the moving boundary at sol.t[i]
in sol.u[i][end]
. See also scaled_mesh_points
for the corresponding grid points.
MovingBoundaryProblems1D.Neumann
— TypeNeumann{F,P} <: AbstractBoundaryCondition{F,P}
A Neumann boundary condition with fields f
and p
(default p = nothing
), with f
being a function of the form f(u, t, p)
and p
being the parameters for f
.
A Neumann boundary condition takes the form
\[\dfrac{\partial u}{\partial x}(a, t) = f(u(a, t), t, p),\]
where a
is one of the endpoints.
Constructors
Neumann(f::Function, p = nothing) -> Neumann(f, p)
Neumann(; f, p = nothing) -> Neumann(f, p)
Neumann(v::Number) -> Neumann((u, t, p) -> oftype(u, v), nothing)
MovingBoundaryProblems1D.Robin
— TypeRobin{F,P} <: AbstractBoundaryCondition{F,P}
A Robin boundary condition with fields f
and p
(default p = nothing
), with f
being a function of the form f(u, t, p)
that returns a Tuple
(a₂, b₂)
and p
being the parameters for f
.
A Robin boundary condition takes the form
\[dL/dt = a₂(u, t, p) + b₂(u, t, p)∂u/∂x,\]
where f(u, t, p) = (a₂(u, t, p), b₂(u, t, p))
.
Constructors
Robin(f::Function, p = nothing) -> Robin(f, p)
Robin(; f, p = nothing) -> Robin(f, p)
Robin(a::Number, b::Number) -> Robin((u, t, p) -> (oftype(u, a), oftype(u, b)))
Robin(a₂::Function, b₂::Function, p = nothing) -> Robin((u, t, p) -> (a₂(u, t, p), b₂(u, t, p)), p)
MovingBoundaryProblems1D.SteadyMBProblem
— TypeSteadyMBProblem{M}
Defines a steady-state problem for a moving boundary problem. Only has a single field, prob::MBProblem
.
You can solve
this problem as you would a NonlinearProblem
, e.g. with
solve(prob, alg)
where alg
is e.g. DynamicSS(TRBDF2()))
from SteadyStateDiffEq.jl.
MovingBoundaryProblems1D.scaled_mesh_points
— Methodscaled_mesh_points(prob::MBProblem, sol)
Given the solution sol
to an MBProblem
prob, returns the scaled grid points at each time.