Skip to content

Commit

Permalink
Merge pull request #1091 from ErikQQY/qqy/bvp_guess_u0
Browse files Browse the repository at this point in the history
Allow u0 in BVProblem as Vector initial guess
  • Loading branch information
ChrisRackauckas authored Oct 9, 2024
2 parents b28acb7 + 679ed0c commit b4e9f4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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)
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

0 comments on commit b4e9f4b

Please sign in to comment.