Skip to content

Commit

Permalink
fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
weinbe58 committed Dec 20, 2023
1 parent 4b7e0d2 commit a2fe211
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/dp5_impl/mod.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module DP5Impl

using ..DormandPrince: DormandPrince, DP5Solver, Vars, Consts, Options, Report
# external imports
using DormandPrince: DP5Solver, Consts, Options, Vars, Report, Idid, Checks


include("helpers.jl")
include("checks.jl")
Expand Down
24 changes: 12 additions & 12 deletions src/dp5_impl/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ function dp5_integrate(
check_beta(solver.options) ||
check_safety_factor(solver.options)
=#
check_max_allowed_steps(solver.options) || return Report(solver.vars.x, MAX_ALLOWED_STEPS_NEGATIVE, INPUT_NOT_CONSISTENT, 0, 0, 0, 0)
check_uround(solver.options) || return Report(solver.vars.x, UNSUPPORTED_UROUND, INPUT_NOT_CONSISTENT, 0, 0, 0, 0)
check_beta(solver.options) || return Report(solver.vars.x, CURIOUS_BETA, INPUT_NOT_CONSISTENT, 0, 0, 0, 0)
check_safety_factor(solver.options) || return Report(solver.vars.x, CURIOUS_SAFETY_FACTOR, INPUT_NOT_CONSISTENT, 0, 0, 0, 0)
check_max_allowed_steps(solver.options) || return Report(solver.vars.x, DormandPrince.MAX_ALLOWED_STEPS_NEGATIVE, DormandPrince.INPUT_NOT_CONSISTENT, 0, 0, 0, 0)
check_uround(solver.options) || return Report(solver.vars.x, DormandPrince.UNSUPPORTED_UROUND, DormandPrince.INPUT_NOT_CONSISTENT, 0, 0, 0, 0)
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)

###### nstiff - parameters for stiffness detection
# nstiff = solver_options.stiffness_test_activation_step
Expand Down Expand Up @@ -94,22 +94,22 @@ function dopcor(
nfcn += 2
reject = false

idid = LARGER_NMAX_NEEDED
idid = DormandPrince.LARGER_NMAX_NEEDED

###### Basic Integration Step
for _ in 1:solver.options.maximum_allowed_steps
# if nstep > solver.options.maximum_allowed_steps
# # GOTO 78
# # println(" MORE THAN NMAX = ", solver.options.maximum_allowed_steps, " STEPS ARE NEEDED")
# return h, Report(solver.vars.x, INPUT_CHECKS_SUCCESSFUL, LARGER_NMAX_NEEDED , 0, 0, 0, 0)
# return h, Report(solver.vars.x, DormandPrince.INPUT_CHECKS_SUCCESSFUL, DormandPrince.LARGER_NMAX_NEEDED , 0, 0, 0, 0)
# end

if (0.10 * abs(h)) <= abs(solver.vars.x)*solver.options.uround
# GOTO 77
# println("STEP SIZE TOO SMALL, H = ", h)
# return h, Report(solver.vars.x, INPUT_CHECKS_SUCCESSFUL, STEP_SIZE_BECOMES_TOO_SMALL, 0, 0, 0, 0)
# return h, Report(solver.vars.x, DormandPrince.INPUT_CHECKS_SUCCESSFUL, DormandPrince.STEP_SIZE_BECOMES_TOO_SMALL, 0, 0, 0, 0)

idid = STEP_SIZE_BECOMES_TOO_SMALL
idid = DormandPrince.STEP_SIZE_BECOMES_TOO_SMALL
break
end

Expand Down Expand Up @@ -149,12 +149,12 @@ function dopcor(
###### Normal Exit
if solver.vars.last
h = hnew
idid = COMPUTATION_SUCCESSFUL
idid = DormandPrince.COMPUTATION_SUCCESSFUL
break
# return h, Report(
# solver.vars.x,
# INPUT_CHECKS_SUCCESSFUL,
# COMPUTATION_SUCCESSFUL,
# DormandPrince.INPUT_CHECKS_SUCCESSFUL,
# DormandPrince.COMPUTATION_SUCCESSFUL,
# nfcn,
# nstep,
# naccpt,
Expand Down Expand Up @@ -185,7 +185,7 @@ function dopcor(

return h, Report(
solver.vars.x,
INPUT_CHECKS_SUCCESSFUL,
DormandPrince.INPUT_CHECKS_SUCCESSFUL,
idid,
nfcn,
nstep,
Expand Down
7 changes: 3 additions & 4 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ end
# 2. integrate(solver, times) -> iterator
# 3. integrate(callback, solver, times) -> vector of states with callback applied

integrate(solver::AbstractDPSolver, time::Real) = dp5_integrate(solver, time)
integrate(solver::AbstractDPSolver, times::AbstractVector{T}) where {T <: Real} = DP5Iterator(solver, times)
integrate(solver::AbstractDPSolver{T}, time::T) where {T<:Real} = dp5_integrate(solver, time)
integrate(solver::AbstractDPSolver{T}, times::AbstractVector{T}) where {T <: Real} = DP5Iterator(solver, times)


function integrate(callback, solver::AbstractDPSolver{StateVec, T}, times::AbstractVector{T}; sort_times::Bool = true) where {StateVec <: AbstractVector, T <: Real}
function integrate(callback, solver::AbstractDPSolver{T}, times::AbstractVector{T}; sort_times::Bool = true) where {T <: Real}
times = sort_times ? sort(collect(times)) : times

result = []
Expand Down
7 changes: 4 additions & 3 deletions test/errors.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Test
using DormandPrince.DP5Impl:
using DormandPrince:
DP5Solver,
Options,
LARGER_NMAX_NEEDED,
STEP_SIZE_BECOMES_TOO_SMALL,
dopcor
STEP_SIZE_BECOMES_TOO_SMALL

using DormandPrince.DP5Impl: dopcor

function fcn(x, y, f)
f[1] = y[1]^2 - y[1]^3
Expand Down

0 comments on commit a2fe211

Please sign in to comment.