Skip to content

Commit

Permalink
Rename AbstractProblem to AbstractSemiinfiniteProblem
Browse files Browse the repository at this point in the history
  • Loading branch information
gerlero committed Dec 27, 2023
1 parent 09402f8 commit 97631c5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/src/problems.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CurrentModule = Fronts
# Problems

```@docs
AbstractProblem
AbstractSemiinfiniteProblem
DirichletProblem
FlowrateProblem
SorptivityProblem
Expand Down
4 changes: 2 additions & 2 deletions src/Fronts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ include("finite.jl")
export DiffusionEquation, diffusivity, conductivity, capacity
export d_do, d_dr, d_dt, boltzmann
export sorptivity
export AbstractProblem, Problem, DirichletProblem, FlowrateProblem, CauchyProblem,
SorptivityProblem, SorptivityCauchyProblem, monotonicity
export AbstractSemiinfiniteProblem, Problem, DirichletProblem, FlowrateProblem,
CauchyProblem, SorptivityProblem, SorptivityCauchyProblem, monotonicity
export BoltzmannODE
export MathiasAndSander
export solve
Expand Down
19 changes: 12 additions & 7 deletions src/ParamEstim.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ParamEstim

import ..Fronts
using ..Fronts: InverseProblem, AbstractProblem, Solution, ReturnCode, solve
using ..Fronts: InverseProblem, AbstractSemiinfiniteProblem, Solution, ReturnCode, solve
import ..Fronts: sorptivity

using LsqFit: curve_fit
Expand Down Expand Up @@ -75,19 +75,23 @@ function (cf::AbstractCostFunction)(params::AbstractVector,
end

_solve(cf::AbstractCostFunction, params::AbstractVector) = _solve(cf, cf._func(params))
_solve(::AbstractCostFunction, prob::AbstractProblem) = solve(prob, verbose = false)
function _solve(::AbstractCostFunction, prob::AbstractSemiinfiniteProblem)
solve(prob, verbose = false)
end
_solve(::AbstractCostFunction, sol::Solution) = sol

"""
candidate(cf::AbstractCostFunction, ::AbstractVector)
candidate(cf::AbstractCostFunction, ::Fronts.AbstractProblem)
candidate(cf::AbstractCostFunction, ::Fronts.AbstractSemiinfiniteProblem)
candidate(cf::AbstractCostFunction, ::Fronts.Solution)
Return the candidate solution for a given cost function and parameter values, problem, or solution.
"""
candidate(cf::AbstractCostFunction, params::AbstractVector) = candidate(cf,
_solve(cf, params))
candidate(cf::AbstractCostFunction, prob::AbstractProblem) = candidate(cf, _solve(cf, prob))
function candidate(cf::AbstractCostFunction, prob::AbstractSemiinfiniteProblem)
candidate(cf, _solve(cf, prob))
end
candidate(::AbstractCostFunction{false}, sol::Solution) = sol

"""
Expand All @@ -104,8 +108,9 @@ factors affecting the diffusivity are unknown, it is recommended not to fit thos
# Arguments
- `func`: function that takes a vector of parameter values and returns either a `Fronts.Solution` or a
`Fronts.AbstractProblem`. If func returns an `AbstractProblem`, it is solved with `solve`. `Solution`s
with successful `ReturnCode` are passed to the cost function; otherwise, the cost is set to `Inf`.
`Fronts.AbstractSemiinfiniteProblem`. If func returns an `AbstractSemiinfiniteProblem`, it is solved with
`solve`. `Solution`s with successful `ReturnCode` are passed to the cost function; otherwise, the cost is
set to `Inf`.
- `prob`: inverse problem. See [`InverseProblem`](@ref).
# Keyword arguments
Expand All @@ -119,7 +124,7 @@ GERLERO, G. S.; BERLI, C. L. A.; KLER, P. A. Open-source high-performance softwa
inverse solving of horizontal capillary flow.
Capillarity, 2023, vol. 6, no. 2, p. 31-40.
See also: [`candidate`](@ref), [`ScaledSolution`](@ref), [`Fronts.Solution`](@ref), [`Fronts.AbstractProblem`](@ref)
See also: [`candidate`](@ref), [`ScaledSolution`](@ref), [`Fronts.Solution`](@ref), [`Fronts.AbstractSemiinfiniteProblem`](@ref)
---
Expand Down
32 changes: 16 additions & 16 deletions src/problems.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
abstract type AbstractProblem{Eq <: DiffusionEquation} end
abstract type AbstractSemiinfiniteProblem{Eq <: DiffusionEquation} end
Abstract supertype for problems that can be solved with this package.
Expand All @@ -8,7 +8,7 @@ Abstract supertype for problems that can be solved with this package.
See also: [`DiffusionEquation`](@ref)
"""
abstract type AbstractProblem{Eq <: DiffusionEquation} end
abstract type AbstractSemiinfiniteProblem{Eq <: DiffusionEquation} end

"""
monotonicity(prob) -> Int
Expand All @@ -18,8 +18,8 @@ Whether the solution to `prob` must be decreasing (`-1`), constant (`0`) or incr
function monotonicity end

"""
DirichletProblem(eq::DiffusionEquation; i, b[, ob]) <: AbstractProblem{typeof(eq)}
DirichletProblem(D; i, b[, ob]) <: AbstractProblem{DiffusionEquation{1}}
DirichletProblem(eq::DiffusionEquation; i, b[, ob]) <: AbstractSemiinfiniteProblem{typeof(eq)}
DirichletProblem(D; i, b[, ob]) <: AbstractSemiinfiniteProblem{DiffusionEquation{1}}
Semi-infinite problem with a Dirichlet boundary condition.
Expand All @@ -45,7 +45,7 @@ julia> prob = Fronts.DirichletProblem(D, i=1, b=2)
See also: [`DiffusionEquation`](@ref)
"""
struct DirichletProblem{Teq, _T, _To} <: AbstractProblem{Teq}
struct DirichletProblem{Teq, _T, _To} <: AbstractSemiinfiniteProblem{Teq}
eq::Teq
i::_T
b::_T
Expand Down Expand Up @@ -81,7 +81,7 @@ end
monotonicity(prob::DirichletProblem)::Int = sign(prob.i - prob.b)

"""
FlowrateProblem(eq::DiffusionEquation{2}; i, Qb[, angle, height, ob]) <: AbstractProblem{typeof(eq)}
FlowrateProblem(eq::DiffusionEquation{2}; i, Qb[, angle, height, ob]) <: AbstractSemiinfiniteProblem{typeof(eq)}
Semi-infinite radial (polar/cylindrical) problem with an imposed-flowrate boundary condition.
Expand Down Expand Up @@ -111,7 +111,7 @@ julia> prob = Fronts.FlowrateProblem(eq, i=1, Qb=1)
See also: [`DiffusionEquation`](@ref)
"""
struct FlowrateProblem{Teq, _T, _To, _TQ, _Th} <: AbstractProblem{Teq}
struct FlowrateProblem{Teq, _T, _To, _TQ, _Th} <: AbstractSemiinfiniteProblem{Teq}
eq::Teq
i::_T
Qb::_TQ
Expand Down Expand Up @@ -155,8 +155,8 @@ end
monotonicity(prob::FlowrateProblem)::Int = -sign(prob.Qb)

"""
SorptivityProblem(eq::DiffusionEquation; i, S[, ob]) <: AbstractProblem{typeof(eq)}
SorptivityProblem(D; i, S[, ob]) <: AbstractProblem{typeof(eq)}
SorptivityProblem(eq::DiffusionEquation; i, S[, ob]) <: AbstractSemiinfiniteProblem{typeof(eq)}
SorptivityProblem(D; i, S[, ob]) <: AbstractSemiinfiniteProblem{typeof(eq)}
Semi-infinite problem with a known initial condition and soprtivity.
Expand All @@ -182,7 +182,7 @@ julia> prob = Fronts.SorptivityProblem(D, i=0, S=1)
See also: [`DiffusionEquation`](@ref), [`sorptivity`](@ref)
"""
struct SorptivityProblem{Teq, _T, _To, _TS} <: AbstractProblem{Teq}
struct SorptivityProblem{Teq, _T, _To, _TS} <: AbstractSemiinfiniteProblem{Teq}
eq::Teq
i::_T
S::_TS
Expand Down Expand Up @@ -218,8 +218,8 @@ monotonicity(prob::SorptivityProblem)::Int = -sign(prob.S)
sorptivity(prob::SorptivityProblem) = prob.S

"""
CauchyProblem(eq::DiffusionEquation; b, d_dob[, ob]) <: AbstractProblem{typeof(eq)}
CauchyProblem(D; b, d_dob[, ob]) <: AbstractProblem{DiffusionEquation{1}}
CauchyProblem(eq::DiffusionEquation; b, d_dob[, ob]) <: AbstractSemiinfiniteProblem{typeof(eq)}
CauchyProblem(D; b, d_dob[, ob]) <: AbstractSemiinfiniteProblem{DiffusionEquation{1}}
Semi-infinite problem with a Cauchy boundary condition (and unknown initial condition).
Expand All @@ -246,7 +246,7 @@ julia> prob = Fronts.CauchyProblem(D, b=2, d_dob=-0.1)
See also: [`DiffusionEquation`](@ref)
"""
struct CauchyProblem{Teq, _T, _To, _Td_do} <: AbstractProblem{Teq}
struct CauchyProblem{Teq, _T, _To, _Td_do} <: AbstractSemiinfiniteProblem{Teq}
eq::Teq
b::_T
d_dob::_Td_do
Expand Down Expand Up @@ -282,8 +282,8 @@ monotonicity(prob::CauchyProblem)::Int = sign(prob.d_dob)
sorptivity(prob::CauchyProblem) = sorptivity(prob.eq, prob.b, prob.d_dob)

"""
SorptivityCauchyProblem(eq::DiffusionEquation; b, S[, ob]) <: AbstractProblem{typeof(eq)}
SorptivityCauchyProblem(D; b, S[, ob]) <: AbstractProblem{DiffusionEquation{1}}
SorptivityCauchyProblem(eq::DiffusionEquation; b, S[, ob]) <: AbstractSemiinfiniteProblem{typeof(eq)}
SorptivityCauchyProblem(D; b, S[, ob]) <: AbstractSemiiinfiniteProblem{DiffusionEquation{1}}
Semi-infinite problem with a known boundary value and soprtivity (and unknown initial condition).
Expand All @@ -309,7 +309,7 @@ julia> prob = Fronts.SorptivityCauchyProblem(D, b=2, S=1)
See also: [`DiffusionEquation`](@ref), [`sorptivity`](@ref)
"""
struct SorptivityCauchyProblem{Teq, _T, _To, _TS} <: AbstractProblem{Teq}
struct SorptivityCauchyProblem{Teq, _T, _To, _TS} <: AbstractSemiinfiniteProblem{Teq}
eq::Teq
b::_T
S::_TS
Expand Down

0 comments on commit 97631c5

Please sign in to comment.