Skip to content

Commit c7c5546

Browse files
authored
fix successful step for parallel discrete systems (#238)
1 parent 41da735 commit c7c5546

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicalSystemsBase"
22
uuid = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
33
repo = "https://github.com/JuliaDynamics/DynamicalSystemsBase.jl.git"
4-
version = "3.15.0"
4+
version = "3.15.1"
55

66
[deps]
77
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"

src/derived_systems/parallel_systems.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function ParallelDynamicalSystem(ds::CoreDynamicalSystem, states::Vector{<:Abstr
6363
pds = CoupledODEs(prob, ds.diffeq; internalnorm = inorm)
6464
end
6565
M = ds isa CoupledODEs && isinplace(ds)
66-
prob = referrenced_sciml_prob(ds)
66+
prob = referrenced_sciml_prob(ds)
6767
return ParallelDynamicalSystemAnalytic{typeof(pds), M}(pds, dynamic_rule(ds), prob)
6868
end
6969

@@ -131,11 +131,19 @@ end
131131
# Analytically knwon rule: extensions
132132
###########################################################################################
133133
for f in (:(SciMLBase.step!), :current_time, :initial_time, :isdiscretetime, :reinit!,
134-
:current_parameters, :initial_parameters, :successful_step,
134+
:current_parameters, :initial_parameters,
135135
)
136136
@eval $(f)(pdsa::ParallelDynamicalSystemAnalytic, args...; kw...) = $(f)(pdsa.ds, args...; kw...)
137137
end
138138

139+
function successful_step(pdsa::ParallelDynamicalSystemAnalytic)
140+
if !isdiscretetime(pdsa)
141+
return successful_step(pdsa.ds)
142+
else
143+
return all(x -> (isfinite(x) && !isnan(x)), current_state(pdsa))
144+
end
145+
end
146+
139147
(pdsa::ParallelDynamicalSystemAnalytic)(t::Real, i::Int = 1) = pdsa.ds(t)[i]
140148
dynamic_rule(pdsa::ParallelDynamicalSystemAnalytic) = pdsa.original_f
141149

test/parallel.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ for (ds, idt, iip) in zip(
9494
test_dynamical_system(ds, u0, p0; idt, iip = true, test_trajectory = false)
9595
parallel_integration_tests(ds)
9696
max_lyapunov_test(ds, idt ? lmax_disc : lmax_cont)
97+
@testset "successful step" begin
98+
@test successful_step(ds) == true
99+
end
97100
end
98101
end
99102

@@ -122,7 +125,7 @@ states = [u0, u0 .+ 0.01]
122125
pds_cont_oop = ParallelDynamicalSystem(duffing_oop, states)
123126
pds_cont_iip = ParallelDynamicalSystem(duffing_iip, deepcopy(states))
124127

125-
#generic ds test
128+
#generic ds test
126129
@testset "IIP=$iip" for (ds, iip) in zip((pds_cont_oop, pds_cont_iip,), (true, false))
127130
test_dynamical_system(ds, u0, p0; idt = true, iip = true, test_trajectory = false)
128131
end

0 commit comments

Comments
 (0)