Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow u0 in BVProblem as Vector initial guess #1091

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fastpow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const EXP2FT = (Float32(0x1.6a09e667f3bcdp-1),
fastpow(x::T, y::T) where {T} -> float(T)
Trips through Float32 for performance.
"""
@inline function fastpow(x::T, y::T) where {T<:Real}
@inline function fastpow(x::T, y::T) where {T <: Real}
outT = float(T)
if iszero(x)
return zero(outT)
Expand Down
7 changes: 5 additions & 2 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ function build_null_solution(prob::AbstractDEProblem, args...;
end

timeseries = [Float64[] for i in 1:length(ts)]

if SciMLBase.has_initializeprob(prob.f) && SciMLBase.has_initializeprobpmap(prob.f)
initializeprob = prob.f.initializeprob
nlsol = solve(initializeprob)
Expand Down Expand Up @@ -1427,6 +1427,7 @@ function check_prob_alg_pairing(prob, alg)
prob isa SDDEProblem && !(alg isa AbstractSDEAlgorithm) ||
prob isa DDEProblem && !(alg isa AbstractDDEAlgorithm) ||
prob isa DAEProblem && !(alg isa AbstractDAEAlgorithm) ||
prob isa BVProblem && !(alg isa AbstractBVPAlgorithm) ||
prob isa SteadyStateProblem && !(alg isa AbstractSteadyStateAlgorithm)
throw(ProblemSolverPairingError(prob, alg))
end
Expand Down Expand Up @@ -1460,8 +1461,10 @@ function check_prob_alg_pairing(prob, alg)
if !SciMLBase.allows_arbitrary_number_types(alg)
if isdefined(prob, :u0)
uType = RecursiveArrayTools.recursive_unitless_eltype(prob.u0)
u0_as_initial_guess = (prob isa BVProblem) && (uType <: Vector)
ChrisRackauckas marked this conversation as resolved.
Show resolved Hide resolved
if Base.isconcretetype(uType) &&
!(uType <: Union{Float32, Float64, ComplexF32, ComplexF64})
!(uType <: Union{Float32, Float64, ComplexF32, ComplexF64}) &&
!u0_as_initial_guess
throw(GenericNumberTypeError(alg,
isdefined(prob, :u0) ? typeof(prob.u0) :
nothing,
Expand Down
5 changes: 3 additions & 2 deletions src/termination_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ tolerances.
"""
struct SimpleNonlinearSolveTerminationMode <: AbstractNonlinearTerminationMode
function SimpleNonlinearSolveTerminationMode()
Base.depwarn("`SimpleNonlinearSolveTerminationMode` is deprecated and isn't used \
in any upstream library. Remove uses of this.",
Base.depwarn(
"`SimpleNonlinearSolveTerminationMode` is deprecated and isn't used \
in any upstream library. Remove uses of this.",
:SimpleNonlinearSolveTerminationMode)
return new()
end
Expand Down
Loading