-
-
Notifications
You must be signed in to change notification settings - Fork 51
Add default algorithm dispatches for AbstractSteadyStateProblem #673
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
Add default algorithm dispatches for AbstractSteadyStateProblem #673
Conversation
This PR adds default algorithm dispatches for AbstractSteadyStateProblem to use the same defaults as NonlinearProblem. The implementation mirrors the existing NonlinearProblem dispatches to ensure consistent behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
@@ -37,6 +37,34 @@ function SciMLBase.__solve(prob::NonlinearProblem, ::Nothing, args...; kwargs... | |||
) | |||
end | |||
|
|||
function SciMLBase.__init(prob::SciMLBase.AbstractSteadyStateProblem, ::Nothing, args...; kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function SciMLBase.__init(prob::SciMLBase.AbstractSteadyStateProblem, ::Nothing, args...; kwargs...) | |
function SciMLBase.__init( | |
prob::SciMLBase.AbstractSteadyStateProblem, ::Nothing, args...; kwargs...) |
This commit adds comprehensive tests for the new AbstractSteadyStateProblem dispatches, verifying that: - Both in-place and out-of-place SteadyStateProblems work with default algorithm - The init and solve interfaces work correctly - StaticArrays are supported - Problem conversion from SteadyStateProblem to NonlinearProblem works - Various problem configurations are handled correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
return SciMLBase.__init(nlprob, nothing, args...; kwargs...) | ||
end | ||
|
||
function SciMLBase.__solve(prob::SciMLBase.AbstractSteadyStateProblem, ::Nothing, args...; kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function SciMLBase.__solve(prob::SciMLBase.AbstractSteadyStateProblem, ::Nothing, args...; kwargs...) | |
function SciMLBase.__solve( | |
prob::SciMLBase.AbstractSteadyStateProblem, ::Nothing, args...; kwargs...) |
du[1] = 2 - 2u[1] | ||
du[2] = u[1] - 4u[2] | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
u0 = zeros(2) | ||
prob_iip = SteadyStateProblem(f_iip, u0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sol = solve(prob_iip) | ||
@test SciMLBase.successful_retcode(sol.retcode) | ||
@test maximum(abs, sol.resid) < 1e-6 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sol = solve(prob_iip, nothing) | ||
@test SciMLBase.successful_retcode(sol.retcode) | ||
@test maximum(abs, sol.resid) < 1e-6 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
||
@test sol_nl.u ≈ sol_converted.u atol=1e-10 | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
f_static(u, p, t) = @SVector [2 - 2u[1], u[1] - 4u[2]] | ||
u0_static = @SVector [0.0, 0.0] | ||
prob_static = SteadyStateProblem(f_static, u0_static) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test SciMLBase.successful_retcode(sol.retcode) | ||
@test maximum(abs, sol.resid) < 1e-6 | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
prob1 = SteadyStateProblem(f_oop, [0.5, 0.5]) | ||
sol1 = solve(prob1) | ||
@test SciMLBase.successful_retcode(sol1.retcode) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sol2 = solve(prob2) | ||
@test SciMLBase.successful_retcode(sol2.retcode) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
end |
Summary
This PR adds
__init
and__solve
method dispatches forAbstractSteadyStateProblem
to the default.jl file, allowing AbstractSteadyStateProblem to use the same default algorithms as NonlinearProblem.Changes
SciMLBase.__init
method forAbstractSteadyStateProblem
that matches the NonlinearProblem implementationSciMLBase.__solve
method forAbstractSteadyStateProblem
that matches the NonlinearProblem implementationMotivation
Currently,
AbstractSteadyStateProblem
doesn't have default algorithm dispatches, requiring users to explicitly specify an algorithm. This PR provides sensible defaults by reusing the same robust polyalgorithm defaults that are already battle-tested forNonlinearProblem
.Test Plan
🤖 Generated with Claude Code