Skip to content

Commit

Permalink
update interface to catch errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
weinbe58 committed Jan 3, 2024
1 parent ccdcc74 commit 10b2f68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
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)

Check warning on line 25 in src/dp8/solver.jl

View check run for this annotation

Codecov / codecov/patch

src/dp8/solver.jl#L25

Added line #L25 was not covered by tests
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")

Check warning on line 33 in src/interface.jl

View check run for this annotation

Codecov / codecov/patch

src/interface.jl#L33

Added line #L33 was not covered by tests

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")

Check warning on line 38 in src/interface.jl

View check run for this annotation

Codecov / codecov/patch

src/interface.jl#L38

Added line #L38 was not covered by tests
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

0 comments on commit 10b2f68

Please sign in to comment.