Skip to content

Commit

Permalink
Merge pull request #68 from SciML/ap/update
Browse files Browse the repository at this point in the history
Update to latest changes
  • Loading branch information
ChrisRackauckas committed Nov 17, 2023
2 parents 5bcf372 + 5c7b477 commit d334aff
Show file tree
Hide file tree
Showing 11 changed files with 291 additions and 305 deletions.
4 changes: 3 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
style = "sciml"
style = "sciml"
format_markdown = true
annotate_untyped_fields_with_any = false
1 change: 0 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
- Core
version:
- '1'
- '1.6'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
1 change: 0 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ The DiffEqSteadyState.jl package is licensed under the MIT "Expat" License:
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
>
17 changes: 9 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
name = "SteadyStateDiffEq"
uuid = "9672c7b4-1e72-59bd-8a11-6ac3964bc41f"
version = "1.16.1"
version = "2.0.0"

[deps]
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"

[compat]
DiffEqBase = "6.126"
DiffEqCallbacks = "2.9"
NLsolve = "4.2"
DiffEqBase = "6.140"
DiffEqCallbacks = "2.34"
Reexport = "0.2, 1.0"
SciMLBase = "1.90, 2"
julia = "1.6"
SciMLBase = "2"
julia = "1.9"

[extras]
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["OrdinaryDiffEq", "ForwardDiff", "ModelingToolkit", "Test", "Sundials"]
test = ["OrdinaryDiffEq", "NonlinearSolve", "ForwardDiff", "ModelingToolkit", "Test", "SafeTestsets", "Sundials"]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ SteadyStateDiffEq.jl is a component package in the DifferentialEquations ecosyst
It holds the steady state solvers for differential equations.
While completely independent and usable on its own, users interested in using this
functionality should check out [DifferentialEquations.jl](https://github.com/JuliaDiffEq/DifferentialEquations.jl).

## Breaking Changes in v2

1. `NLsolve.jl` dependency has been dropped. `SSRootfind` requires a nonlinear solver to be
specified.
2. `DynamicSS` no longer stores `abstol` and `reltol`. To use separate tolerances for the
odesolve and the termination, specify `odesolve_kwargs` in `solve`.
3. The deprecated termination conditions are dropped, see [NonlinearSolve.jl Docs](https://docs.sciml.ai/NonlinearSolve/stable/basics/TerminationCondition/)
for details on this.
6 changes: 2 additions & 4 deletions src/SteadyStateDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ module SteadyStateDiffEq
using Reexport
@reexport using DiffEqBase

using NLsolve, DiffEqCallbacks
using LinearAlgebra
using SciMLBase
using DiffEqCallbacks, ConcreteStructs, LinearAlgebra, SciMLBase

include("algorithms.jl")
include("solve.jl")

export SSRootfind, DynamicSS

end # module
end
79 changes: 43 additions & 36 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
abstract type SteadyStateDiffEqAlgorithm <: DiffEqBase.AbstractSteadyStateAlgorithm end

struct SSRootfind{F} <: SteadyStateDiffEqAlgorithm
nlsolve::F
end
function SSRootfind(;
nlsolve = (f, u0, abstol) -> (NLsolve.nlsolve(f, u0,
ftol = abstol)))
SSRootfind(nlsolve)
"""
SSRootfind(alg = nothing)
Use a Nonlinear Solver to find the steady state. Requires that a nonlinear solver is
given as the first argument.
!!! note
The default `alg` of `nothing` works only if `NonlinearSolve.jl` is installed and
loaded.
"""
@concrete struct SSRootfind <: SteadyStateDiffEqAlgorithm
alg
end

SSRootfind() = SSRootfind(nothing)

"""
DynamicSS(alg; abstol = 1e-8, reltol = 1e-6, tspan = Inf,
termination_condition = SteadyStateTerminationCriteria(:default; abstol,
reltol))
DynamicSS(alg = nothing; tspan = Inf)
Requires that an ODE algorithm is given as the first argument. The absolute and
relative tolerances specify the termination conditions on the derivative's closeness to
Expand All @@ -24,45 +30,46 @@ Example usage:
```julia
using SteadyStateDiffEq, OrdinaryDiffEq
sol = solve(prob,DynamicSS(Tsit5()))
sol = solve(prob, DynamicSS(Tsit5()))
using Sundials
sol = solve(prob,DynamicSS(CVODE_BDF()),dt=1.0)
sol = solve(prob, DynamicSS(CVODE_BDF()); dt = 1.0)
```
!!! note
If you use `CVODE_BDF` you may need to give a starting `dt` via `dt=....`.*
The default `alg` of `nothing` works only if `DifferentialEquations.jl` is installed and
loaded.
!!! note
If you use `CVODE_BDF` you may need to give a starting `dt` via `dt = ....`.*
"""
struct DynamicSS{A, AT, RT, TS, TC <: NLSolveTerminationCondition} <:
SteadyStateDiffEqAlgorithm
alg::A
abstol::AT
reltol::RT
tspan::TS
termination_condition::TC
@concrete struct DynamicSS <: SteadyStateDiffEqAlgorithm
alg
tspan
end

function DynamicSS(alg; abstol = 1e-8, reltol = 1e-6, tspan = Inf,
termination_condition = NLSolveTerminationCondition(NLSolveTerminationMode.SteadyStateDefault;
abstol,
reltol))
DynamicSS(alg, abstol, reltol, tspan, termination_condition)
end
DynamicSS(alg = nothing; tspan = Inf) = DynamicSS(alg, tspan)

# Backward compatibility:
DynamicSS(alg, abstol, reltol) = DynamicSS(alg; abstol = abstol, reltol = reltol)
function DiffEqBase.prepare_alg(alg::DynamicSS, u0, p, f)
return DynamicSS(DiffEqBase.prepare_alg(alg.alg, u0, p, f), alg.tspan)
end

## SciMLBase Trait Definitions
SciMLBase.isadaptive(::SSRootfind) = false

SciMLBase.isadaptive(alg::SteadyStateDiffEqAlgorithm) = true
for aType in (:SSRootfind, :DynamicSS),
op in (:isadaptive, :isautodifferentiable, :allows_arbitrary_number_types,
:allowscomplex)

SciMLBase.isautodifferentiable(alg::SSRootfind) = true
SciMLBase.allows_arbitrary_number_types(alg::SSRootfind) = true
SciMLBase.allowscomplex(alg::SSRootfind) = true
op == :isadaptive && aType == :SSRootfind && continue

SciMLBase.isautodifferentiable(alg::DynamicSS) = SciMLBase.isautodifferentiable(alg.alg)
function SciMLBase.allows_arbitrary_number_types(alg::DynamicSS)
SciMLBase.allows_arbitrary_number_types(alg.alg)
@eval function SciMLBase.$(op)(alg::$aType)
internal_alg = alg.alg
# Internal Alg is nothing means we will handle everything correctly downstream
internal_alg === nothing && return true
!hasmethod(SciMLBase.$(op), Tuple{typeof(internal_alg)}) && return false
return SciMLBase.$(op)(internal_alg)
end
end
SciMLBase.allowscomplex(alg::DynamicSS) = SciMLBase.allowscomplex(alg.alg)
Loading

2 comments on commit d334aff

@avik-pal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/95508

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.0.0 -m "<description of version>" d334affab411d77fe6a72ebd4b0f2a48401c6dea
git push origin v2.0.0

Please sign in to comment.