Skip to content

Commit

Permalink
Merge pull request #17 from QuEraComputing/update-integrate
Browse files Browse the repository at this point in the history
Update interface to catch errors.
  • Loading branch information
weinbe58 committed Jan 3, 2024
2 parents ccdcc74 + b2b21e4 commit b6f2e17
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DormandPrince"
uuid = "5e45e72d-22b8-4dd0-9c8b-f96714864bcd"
authors = ["John Long<jlong@quera.com>", "Phillip Weinberg<pweinberg@quera.com>"]
version = "0.4.0"
version = "0.5.0"

[deps]

Expand Down
2 changes: 1 addition & 1 deletion src/dp5/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include("checks.jl")
#include("helpers.jl")

function DormandPrince.integrate!(
function DormandPrince.integrate_core!(
solver::DP5Solver{T},
xend::T
) where T
Expand Down
6 changes: 5 additions & 1 deletion src/dp8/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include("checks.jl")
#include("helpers.jl")

function DormandPrince.integrate!(
function DormandPrince.integrate_core!(
solver::DP8Solver{T},
xend::T
) where T
Expand All @@ -21,6 +21,10 @@ function DormandPrince.integrate!(
check_beta(solver.options) || return Report(solver.vars.x, DormandPrince.CURIOUS_BETA, DormandPrince.INPUT_NOT_CONSISTENT, 0, 0, 0, 0)
check_safety_factor(solver.options) || return Report(solver.vars.x, DormandPrince.CURIOUS_SAFETY_FACTOR, DormandPrince.INPUT_NOT_CONSISTENT, 0, 0, 0, 0)

if solver.vars.x == xend
return Report(solver.vars.x, DormandPrince.INPUT_CHECKS_SUCCESSFUL, DormandPrince.COMPUTATION_SUCCESSFUL, 0, 0, 0, 0)
end

###### nstiff - parameters for stiffness detection
# nstiff = solver_options.stiffness_test_activation_step

Expand Down
10 changes: 9 additions & 1 deletion src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@ end
# 3. integrate(callback, solver, times) -> vector of states with callback applied

get_current_state(::AbstractDPSolver) = error("not implemented")
integrate!(::AbstractDPSolver{T}, ::T) where T = error("not implemented")
integrate_core!(::AbstractDPSolver{T}, ::T) where T = error("not implemented")

function integrate!(solver::AbstractDPSolver{T}, time::T) where T <: Real
report = integrate_core!(solver, time)
if report.idid != COMPUTATION_SUCCESSFUL
error("integration failed at time $time with report $report")
end
end
function integrate!(callback, solver::AbstractDPSolver{T}, times::AbstractVector{T}; sort_times::Bool = true) where {T <: Real}
times = sort_times ? sort(collect(times)) : times

result = []
for time in times
integrate!(solver, time)

push!(result, callback(time, get_current_state(solver)))
end

Expand Down

2 comments on commit b6f2e17

@weinbe58
Copy link
Member Author

Choose a reason for hiding this comment

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

release via ion

@JuliaRegistrator register branch=main

Release notes:

Release Note

* moving integrate(::AbstractDPSolver, time) to integrate_core in order to catch errors in integrate!

@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/98159

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 v0.5.0 -m "<description of version>" b6f2e177600f7d74d1b988235e7fb51f5f029e4b
git push origin v0.5.0

Please sign in to comment.