FiniteVolumeMethod1D
Documentation for FiniteVolumeMethod1D.
This is a package for solving equations of the form
\[\dfrac{\partial u(x, t)}{\partial x} = \dfrac{\partial}{\partial x}\left(D\left(u, x, t\right)\dfrac{\partial u(x, t)}{\partial x}\right) + R(u, x, t),\]
using the finite volume method over intervals $a \leq x \leq b$ and $t_0 \leq t \leq t_1$, with support for the following types of boundary conditions (shown at $x = a$, but you can mix boundary condition types, e.g. Neumann at $x=a$ and Robin at $x=b$):
\[\begin{align*} \begin{array}{rrcl} \text{Neumann}: & \dfrac{\partial u(a, t)}{\partial t} & = & a_0\left(u(a, t), t\right), \\[9pt] \text{Dirichlet}: & u(a, t) & = & a_0\left(u(a, t), t\right), \end{array} \end{align*}\]
where the Dirichlet condition has $u(a, t)$ mapping from $a_0(u(a, t), t)$ (i.e., it is not an implicit equation for $u(a, t)$).
More information is given in the sidebar, and the docstrings are below.
If you want a more complete two-dimensional version, please see my other package FiniteVolumeMethod.jl.
FiniteVolumeMethod1D.BoundaryConditions
FiniteVolumeMethod1D.Dirichlet
FiniteVolumeMethod1D.FVMGeometry
FiniteVolumeMethod1D.FVMProblem
FiniteVolumeMethod1D.Neumann
FiniteVolumeMethod1D.BoundaryConditions
— TypeBoundaryConditions{L, R}
The boundary conditions for the FVMProblem.
Fields
lhs::L
: The left-hand side boundary condition.rhs::R
: The right-hand side boundary condition.
See also Dirichlet
and Neumann
for the types of boundary conditions you can construct.
FiniteVolumeMethod1D.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)
FiniteVolumeMethod1D.FVMGeometry
— TypeFVMGeometry{T}
Definition of the geometry for a finite volume method problem.
Fields
mesh_points::T
: The mesh points. Must be sorted.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,
FVMGeometry(mesh_points, spacings, volumes)
or you can call the convenience constructor,
FVMGeometry(mesh_points)
which will compute the spacings and volumes for you.
See also FVMProblem
.
FiniteVolumeMethod1D.FVMProblem
— TypeFVMProblem{T,DF,DP,RF,RP,L,R,IC,FT}
Definition of an FVMProblem
.
Fields
geometry::FVMGeometry{T}
: The geometry of the problem.boundary_conditions::BoundaryConditions{L, R}
: 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_time::FT
: The initial time.final_time::FT
: The final time.
Constructors
You can use the default constructor, but we also provide the constructor
FVMProblem(;
geometry,
boundary_conditions,
diffusion_function,
diffusion_parameters = nothing,
reaction_function = Returns(0.0),
reaction_parameters = nothing,
initial_condition,
initial_time = 0.0,
final_time)
which provides some default values. Moreover, instead of providing geometry
and boundary_conditions
, you can use
FVMProblem(mesh_points, lhs, rhs; kwargs...)
which will construct geometry = FVMGeometry(mesh_points)
and boundary_conditions = BoundaryConditions(lhs, rhs)
. The kwargs...
are as above, except without geometry
and boundary_conditions
of course.
To solve the FVMProblem
, just use solve
as you would in DifferentialEquations.jl. For example,
sol = solve(prob, Tsit5(), saveat=0.1)
solves the problem with the Tsit5()
algorithm, saving the solution every 0.1
units of time from initial_time
up to, and including, final_time
.
FiniteVolumeMethod1D.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)