From 5c2180ab027f42c8d0b7cc760e6a9d1c3bbf9248 Mon Sep 17 00:00:00 2001 From: Gabriel Gerlero Date: Sun, 17 Dec 2023 23:15:58 -0300 Subject: [PATCH] Rename SorptivityProblem to SorptivityCauchyProblem --- docs/src/problems.md | 2 +- src/Fronts.jl | 2 +- src/integration.jl | 14 +++++++------- src/problems.jl | 24 ++++++++++++------------ src/shooting.jl | 8 +++++--- test/test_cauchy.jl | 4 ++-- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/docs/src/problems.md b/docs/src/problems.md index 4b1a35cd..576e2955 100644 --- a/docs/src/problems.md +++ b/docs/src/problems.md @@ -9,7 +9,7 @@ Problem DirichletProblem FlowrateProblem CauchyProblem -SorptivityProblem +SorptivityCauchyProblem FiniteProblem FiniteDirichletProblem FiniteReservoirProblem diff --git a/src/Fronts.jl b/src/Fronts.jl index 03bb17ec..9e584b25 100644 --- a/src/Fronts.jl +++ b/src/Fronts.jl @@ -46,7 +46,7 @@ export Equation, DiffusionEquation, RichardsEquation, diffusivity, flow_diffusiv export d_do, d_dr, d_dt, boltzmann export sorptivity export Problem, - DirichletProblem, FlowrateProblem, CauchyProblem, SorptivityProblem, monotonicity + DirichletProblem, FlowrateProblem, CauchyProblem, SorptivityCauchyProblem, monotonicity export BoltzmannODE export MathiasAndSander export solve diff --git a/src/integration.jl b/src/integration.jl index 89520c61..d9f4b01e 100644 --- a/src/integration.jl +++ b/src/integration.jl @@ -25,7 +25,7 @@ end """ boltzmann(prob::CauchyProblem) -> DifferentialEquations.ODEProblem - boltzmann(prob::SorptivityProblem) -> DifferentialEquations.ODEProblem + boltzmann(prob::SorptivityCauchyProblem) -> DifferentialEquations.ODEProblem Transform `prob` into an ODE problem in terms of the Boltzmann variable `o`. @@ -33,10 +33,10 @@ The ODE problem is set up to terminate automatically (`ReturnCode.Terminated`) w See also: [`DifferentialEquations`](https://diffeq.sciml.ai/stable/) """ -function boltzmann(prob::Union{CauchyProblem, SorptivityProblem}) +function boltzmann(prob::Union{CauchyProblem, SorptivityCauchyProblem}) if prob isa CauchyProblem u0 = @SVector [prob.b, prob.d_dob] - elseif prob isa SorptivityProblem + elseif prob isa SorptivityCauchyProblem u0 = @SVector [prob.b, d_do(prob.eq, prob.b, prob.S)] end @@ -54,7 +54,7 @@ end const _ODE_ALG = RadauIIA5() const _ODE_MAXITERS = 1000 -function _init(prob::Union{CauchyProblem, SorptivityProblem}, +function _init(prob::Union{CauchyProblem, SorptivityCauchyProblem}, ::BoltzmannODE; limit = nothing, verbose = true) @@ -82,7 +82,7 @@ function _reinit!(integrator, prob::CauchyProblem) return integrator end -function _reinit!(integrator, prob::SorptivityProblem) +function _reinit!(integrator, prob::SorptivityCauchyProblem) @assert -sign(prob.S) == sign(integrator.sol.u[1][2]) reinit!(integrator, @SVector [prob.b, d_do(prob.eq, prob.b, prob.S)]) return integrator @@ -90,7 +90,7 @@ end """ solve(prob::CauchyProblem[, alg::BoltzmannODE; verbose]) -> Solution - solve(prob::SorptivityProblem[, alg::BoltzmannODE; verbose]) -> Solution + solve(prob::SorptivityCauchyProblem[, alg::BoltzmannODE; verbose]) -> Solution Solve the problem `prob`. @@ -107,7 +107,7 @@ Capillarity, 2023, vol. 6, no. 2, p. 31-40. See also: [`Solution`](@ref), [`BoltzmannODE`](@ref) """ -function solve(prob::Union{CauchyProblem, SorptivityProblem}, +function solve(prob::Union{CauchyProblem, SorptivityCauchyProblem}, alg::BoltzmannODE = BoltzmannODE(); verbose = true) odesol = solve!(_init(prob, alg, verbose = verbose)) diff --git a/src/problems.jl b/src/problems.jl index a7538176..8eeb5b45 100644 --- a/src/problems.jl +++ b/src/problems.jl @@ -223,14 +223,14 @@ monotonicity(prob::CauchyProblem)::Int = sign(prob.d_dob) sorptivity(prob::CauchyProblem) = sorptivity(prob.eq, prob.b, prob.d_dob) """ - SorptivityProblem(eq; b, S[, ob]) <: Problem{typeof(eq)} - SorptivityProblem(D; b, S[, ob]) <: Problem{DiffusionEquation{1}} + SorptivityCauchyProblem(eq; b, S[, ob]) <: Problem{typeof(eq)} + SorptivityCauchyProblem(D; b, S[, ob]) <: Problem{DiffusionEquation{1}} Semi-infinite problem with a known boundary value and soprtivity (and unknown initial condition). # Arguments - `eq::Equation`: governing equation. -- `D`: diffusivity function. Shortcut for `SorptivityProblem(DiffusionEquation(D), ...)`. +- `D`: diffusivity function. Shortcut for `SorptivityCauchyProblem(DiffusionEquation(D), ...)`. # Keyword arguments - `b`: imposed boundary value. @@ -242,7 +242,7 @@ Semi-infinite problem with a known boundary value and soprtivity (and unknown in julia> D(θ) = θ^4 D (generic function with 1 method) -julia> prob = Fronts.SorptivityProblem(D, b=2, S=1) +julia> prob = Fronts.SorptivityCauchyProblem(D, b=2, S=1) ⎧ ∂θ/∂t = ∂(D(θ)*∂θ/∂r)/∂r, r>0,t>0 ⎨ θ(0,t) = 2, t>0 ⎩ S = 1 @@ -250,25 +250,25 @@ julia> prob = Fronts.SorptivityProblem(D, b=2, S=1) See also: [`Equation`](@ref), [`sorptivity`](@ref) """ -struct SorptivityProblem{Teq, _T, _To, _TS} <: Problem{Teq} +struct SorptivityCauchyProblem{Teq, _T, _To, _TS} <: Problem{Teq} eq::Teq b::_T S::_TS ob::_To - function SorptivityProblem(eq::Equation{1}; b, S, ob = 0) + function SorptivityCauchyProblem(eq::Equation{1}; b, S, ob = 0) new{typeof(eq), typeof(b), typeof(ob), typeof(S)}(eq, b, S, ob) end - function SorptivityProblem(eq::Equation; b, S, ob) + function SorptivityCauchyProblem(eq::Equation; b, S, ob) @argcheck ob > zero(ob) new{typeof(eq), typeof(b), typeof(ob), typeof(S)}(eq, b, S, ob) end end -function SorptivityProblem(D; b, S, ob = 0) - SorptivityProblem(DiffusionEquation(D), b = b, S = S, ob = ob) +function SorptivityCauchyProblem(D; b, S, ob = 0) + SorptivityCauchyProblem(DiffusionEquation(D), b = b, S = S, ob = ob) end -function Base.show(io::IO, prob::SorptivityProblem) +function Base.show(io::IO, prob::SorptivityCauchyProblem) if iszero(prob.ob) println(io, "⎧ ", prob.eq, ", r>0,t>0") println(io, "⎨ ", prob.eq.sym, "(0,t) = ", prob.b, ", t>0") @@ -281,6 +281,6 @@ function Base.show(io::IO, prob::SorptivityProblem) end end -monotonicity(prob::SorptivityProblem)::Int = -sign(prob.S) +monotonicity(prob::SorptivityCauchyProblem)::Int = -sign(prob.S) -sorptivity(prob::SorptivityProblem) = prob.S +sorptivity(prob::SorptivityCauchyProblem) = prob.S diff --git a/src/shooting.jl b/src/shooting.jl index 1ac8cb62..5e3cfb91 100644 --- a/src/shooting.jl +++ b/src/shooting.jl @@ -131,13 +131,14 @@ function solve(prob::FlowrateProblem; alg::BoltzmannODE = BoltzmannODE(), resid = prob.i - oneunit(prob.i) * monotonicity(prob) S = 2prob.Qb / prob._αh / ob - integrator = _init(SorptivityProblem(prob.eq, b = b_hint, S = S, ob = ob), + integrator = _init(SorptivityCauchyProblem(prob.eq, b = b_hint, S = S, ob = ob), alg, limit = limit, verbose = false) if iszero(direction) - _reinit!(integrator, SorptivityProblem(prob.eq, b = prob.i, S = zero(S), ob = ob)) + _reinit!(integrator, + SorptivityCauchyProblem(prob.eq, b = prob.i, S = zero(S), ob = ob)) solve!(integrator) @assert integrator.sol.retcode != ReturnCode.Success @@ -157,7 +158,8 @@ function solve(prob::FlowrateProblem; alg::BoltzmannODE = BoltzmannODE(), b_trial = bracket_bisect(prob.i, b_hint) for niter in 1:maxiters - _reinit!(integrator, SorptivityProblem(prob.eq, b = b_trial(resid), S = S, ob = ob)) + _reinit!(integrator, + SorptivityCauchyProblem(prob.eq, b = b_trial(resid), S = S, ob = ob)) solve!(integrator) @assert integrator.sol.retcode != ReturnCode.Success diff --git a/test/test_cauchy.jl b/test/test_cauchy.jl index 10251476..d01cc70e 100644 --- a/test/test_cauchy.jl +++ b/test/test_cauchy.jl @@ -44,13 +44,13 @@ end end -@testset "SorptivityProblem" begin +@testset "SorptivityCauchyProblem" begin @testset "exact" begin # Reference: Philip (1960) Table 1, No. 13 # https://doi.org/10.1071/PH600001 D = θ -> 0.5 * (1 - NaNMath.log(θ)) - prob = SorptivityProblem(D, b = 1, S = 1) + prob = SorptivityCauchyProblem(D, b = 1, S = 1) @test sorptivity(prob) == 1 θ = solve(prob)