Skip to content

Commit

Permalink
Fix #160 (#165)
Browse files Browse the repository at this point in the history
* Nest DiffEqBase and OrdinaryDiffEq require macros in __init__

* Update tests

* Try a (perhaps) simpler solution: require only OrdinaryDiffEq

* Minor update in src/common.jl

* Update tests

* Update Project.toml

* Remove unused bits of DiffEqBase

* Update Project.toml: remove DiffEqBase from test deps

* Update docs

* Update docs/Project.toml

* Update taylorize docs
  • Loading branch information
PerezHz authored May 14, 2023
1 parent ef58247 commit 3727bbf
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 28 deletions.
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TaylorIntegration"
uuid = "92b13dbe-c966-51a2-8445-caca9f8a7d42"
repo = "https://github.com/PerezHz/TaylorIntegration.jl.git"
version = "0.11.1"
version = "0.12.0"

[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Expand Down Expand Up @@ -36,7 +36,6 @@ TaylorSeries = "0.14, 0.15"
julia = "1"

[extras]
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Elliptic = "b305315f-e792-5b7a-8f41-49f472929428"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -47,4 +46,4 @@ TaylorSeries = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["DiffEqBase", "Elliptic", "InteractiveUtils", "LinearAlgebra", "Logging", "Pkg", "StaticArrays", "TaylorSeries", "Test"]
test = ["Elliptic", "InteractiveUtils", "LinearAlgebra", "Logging", "Pkg", "StaticArrays", "TaylorSeries", "Test"]
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Elliptic = "b305315f-e792-5b7a-8f41-49f472929428"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand Down
23 changes: 7 additions & 16 deletions docs/src/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@

Here, we show an example of interoperability between `TaylorIntegration.jl` and
[`DifferentialEquations.jl`](https://github.com/JuliaDiffEq/DifferentialEquations.jl), i.e.,
how to use `TaylorIntegration.jl` from the `DifferentialEquations`
ecosystem. The basic requirement is to load `DiffEqBase.jl`, or `OrdinaryDiffEq.jl`
**before** `TaylorIntegration.jl`, which sets-up the common interface.

!!! note
`TaylorIntegration.jl` may be loaded first, but then you **must** load `DiffEqBase.jl`
(and not `OrdinaryDiffEq.jl`); see
[#160](https://github.com/PerezHz/TaylorIntegration.jl/issues/160). Loading
`DiffEqBase.jl` or `OrdinaryDiffEq.jl` first, and then `TaylorIntegration.jl`,
pose no problem.

Below, we shall also use `DiffEqBase.jl` to compare
how to use `TaylorIntegration.jl` from the `DifferentialEquations` ecosystem. The basic
requirement is to load `OrdinaryDiffEq.jl` together with `TaylorIntegration.jl`, which
sets-up the common interface. Below, we shall also use `OrdinaryDiffEq.jl` to compare
the accuracy of `TaylorIntegration.jl` with respect to
high-accuracy methods for non-stiff problems (`Vern9` method).
While `DifferentialEquations` offers many macros to simplify certain
Expand Down Expand Up @@ -165,13 +156,13 @@ H(q0) == J0
Following the `DifferentialEquations.jl`
[tutorial](https://diffeq.sciml.ai/stable/tutorials/ode_example/),
we define an `ODEProblem` for the integration; `TaylorIntegration` can be used
via its common interface bindings with `DiffEqBase.jl`; both packages need to
via its common interface bindings with `OrdinaryDiffEq.jl`; both packages need to
be loaded explicitly.
```@example common
tspan = (0.0, 2000.0)
p = [μ]
using DiffEqBase
using OrdinaryDiffEq
prob = ODEProblem(pcr3bp!, q0, tspan, p)
```

Expand All @@ -180,8 +171,8 @@ We solve `prob` using a 25-th order Taylor method, with a local absolute toleran
solT = solve(prob, TaylorMethod(25), abstol=1e-15);
```

As mentioned above, we load `OrdinaryDiffEq` in order to solve the same problem `prob`
now with the `Vern9` method, which the `DifferentialEquations`
As mentioned above, we will now solve the same problem `prob`
with the `Vern9` method from `OrdinaryDiffEq`, which the `DifferentialEquations`
[documentation](https://diffeq.sciml.ai/stable/solvers/ode_solve/#Non-Stiff-Problems)
recommends for high-accuracy (i.e., very low tolerance) integrations of
non-stiff problems. Note that, besides setting an absolute tolerance `abstol=1e-15`,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/taylorize.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ e1/e3, all1/all3
We now illustrate the possibility of exploiting the macro
when using `TaylorIntegration.jl` from `DifferentialEquations.jl`.
```@example taylorize
using DiffEqBase
using OrdinaryDiffEq
prob = ODEProblem(pendulum!, q0, (t0, tf), nothing) # no parameters
solT = solve(prob, TaylorMethod(25), abstol=1e-20, parse_eqs=true); # warm-up run
Expand Down
2 changes: 1 addition & 1 deletion src/TaylorIntegration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include("lyapunovspectrum.jl")
include("rootfinding.jl")

function __init__()
@require DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" include("common.jl")
@require OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" include("common.jl")
end

end #module
10 changes: 5 additions & 5 deletions src/common.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using DiffEqBase, OrdinaryDiffEq
using OrdinaryDiffEq
using StaticArrays: SVector, SizedArray
using RecursiveArrayTools: ArrayPartition

import DiffEqBase: ODEProblem, solve, ODE_DEFAULT_NORM, @.., addsteps!
import DiffEqBase: ODEProblem, solve, ODE_DEFAULT_NORM

import OrdinaryDiffEq: OrdinaryDiffEqAdaptiveAlgorithm,
OrdinaryDiffEqConstantCache, OrdinaryDiffEqMutableCache,
alg_order, alg_cache, initialize!, perform_step!, @unpack,
@cache, stepsize_controller!, step_accept_controller!, _ode_addsteps!
OrdinaryDiffEqConstantCache, OrdinaryDiffEqMutableCache,
alg_order, alg_cache, initialize!, perform_step!, @unpack,
@cache, stepsize_controller!, step_accept_controller!, _ode_addsteps!

# TODO: check which keywords work fine
const warnkeywords = (:save_idxs, :d_discontinuities, :unstable_check, :save_everystep,
Expand Down
3 changes: 2 additions & 1 deletion test/common.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using TaylorIntegration, Test, DiffEqBase
using TaylorIntegration, Test
using OrdinaryDiffEq
using LinearAlgebra: norm
using StaticArrays
using Logging
Expand Down

2 comments on commit 3727bbf

@PerezHz
Copy link
Owner Author

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 created: JuliaRegistries/General/83546

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 v0.12.0 -m "<description of version>" 3727bbf5df10d681d360df381ca262d2cd5fbb05
git push origin v0.12.0

Please sign in to comment.