Skip to content

Commit 5a7b780

Browse files
committed
don't use dynamical_rule but prob
1 parent 9a202ca commit 5a7b780

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

ext/src/CoupledSDEs.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ function DynamicalSystemsBase.CoupledSDEs(
118118
noise_process=nothing,
119119
seed=UInt64(0)
120120
)
121-
return CoupledSDEs(dynamic_rule(ds), current_state(ds), p;
121+
prob = referrenced_sciml_prob(ds)
122+
# we want the symbolic jacobian to be transfered over
123+
# dynamic_rule(ds) takes the deepest nested f wich does not have a jac field
124+
return CoupledSDEs(prob.f, current_state(ds), p;
122125
g, noise_strength, covariance, diffeq, noise_prototype, noise_process, seed)
123126
end
124127

@@ -130,9 +133,11 @@ deterministic part of `ds`.
130133
"""
131134
function DynamicalSystemsBase.CoupledODEs(
132135
sys::CoupledSDEs; diffeq=DEFAULT_DIFFEQ, t0=0.0)
136+
prob = referrenced_sciml_prob(sys)
137+
# we want the symbolic jacobian to be transfered over
138+
# dynamic_rule(ds) takes the deepest nested f wich does not have a jac field
133139
return CoupledODEs(
134-
dynamic_rule(sys), SVector{length(sys.integ.u)}(sys.integ.u), sys.p0;
135-
diffeq=diffeq, t0=t0
140+
prob.f, SVector{length(sys.integ.u)}(sys.integ.u), sys.p0; diffeq=diffeq, t0=t0
136141
)
137142
end
138143

src/core_systems/jacobian.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ For in-place systems, `jacobian` returns the Jacobian rule as a function
2020
at the state `u`, parameters `p` and time `t` and save the result in `J0`.
2121
"""
2222
function jacobian(ds::CoreDynamicalSystem{IIP}) where {IIP}
23-
if hasproperty(ds, :integ) &&
24-
ds.integ.f isa SciMLBase.AbstractDiffEqFunction && !isnothing(ds.integ.f.jac)
25-
jac = ds.integ.f.jac
23+
if ds isa ContinuousTimeDynamicalSystem
24+
prob = referrenced_sciml_prob(ds)
25+
if prob.f isa SciMLBase.AbstractDiffEqFunction && !isnothing(prob.f.jac)
26+
jac = prob.f.jac
27+
else
28+
jac = _jacobian(ds, Val{IIP}())
29+
end
2630
else
2731
jac = _jacobian(ds, Val{IIP}())
2832
end

test/jacobian.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function iip(du, u, p, t)
99
return nothing
1010
end
1111

12-
#%%
12+
1313
@testset "IDT=$(IDT), IIP=$(IIP)" for IDT in (true, false), IIP in (false, true)
1414
SystemType = IDT ? DeterministicIteratedMap : CoupledODEs
1515
rule = IIP ? iip : oop
@@ -48,7 +48,8 @@ end
4848
@test jac.jac_oop isa RuntimeGeneratedFunction
4949
@test jac([1.0, 1.0], [], 0.0) == [3 0;0 -3]
5050

51-
@testset "CoupledSDEs" begin # just to check if MTH @brownian does not give any problems
51+
@testset "CoupledSDEs" begin
52+
# just to check if MTK @brownian does not give any problems
5253
using StochasticDiffEq
5354
@brownian β
5455
eqs = [D(u[1]) ~ 3.0 * u[1]+ β,

0 commit comments

Comments
 (0)