Skip to content

Commit 25f9ed8

Browse files
committed
add test, fix
1 parent 2b98a12 commit 25f9ed8

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/systems/diffeqs/sdesystem.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -768,11 +768,7 @@ function DiffEqBase.SDEProblem{iip, specialize}(
768768
noise_rate_prototype = noise_rate_prototype, kwargs...)
769769
end
770770

771-
function DiffEqBase.SDEProblem{iip, specialize}(
772-
sys::ODESystem, u0map = [], tspan = get_tspan(sys),
773-
parammap = DiffEqBase.NullParameters();
774-
sparsenoise = nothing, check_length = true,
775-
callback = nothing, kwargs...) where {iip, specialize}
771+
function DiffEqBase.SDEProblem(sys::ODESystem, args...; kwargs...)
776772

777773
if any(ModelingToolkit.isbrownian, unknowns(sys))
778774
error("SDESystem constructed by defining Brownian variables with @brownian must be simplified by calling `structural_simplify` before a SDEProblem can be constructed.")

test/sdesystem.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,3 +868,24 @@ end
868868
@test length(ModelingToolkit.get_noiseeqs(sys)) == 1
869869
@test length(observed(sys)) == 1
870870
end
871+
using ModelingToolkit, StochasticDiffEq
872+
using ModelingToolkit: t_nounits as t, D_nounits as D
873+
874+
@testset "Error when constructing SDESystem without `structural_simplify`" begin
875+
@parameters σ ρ β
876+
@variables x(t) y(t) z(t)
877+
@brownian a
878+
eqs = [D(x) ~ σ * (y - x) + 0.1a * x,
879+
D(y) ~ x *- z) - y + 0.1a * y,
880+
D(z) ~ x * y - β * z + 0.1a * z]
881+
882+
@named de = System(eqs, t)
883+
de = complete(de)
884+
885+
u0map = [x => 1.0, y => 0.0, z => 0.0]
886+
parammap ==> 10.0, β => 26.0, ρ => 2.33]
887+
888+
@test_throws ErrorException("SDESystem constructed by defining Brownian variables with @brownian must be simplified by calling `structural_simplify` before a SDEProblem can be constructed.") SDEProblem(de, u0map, (0.0, 100.0), parammap)
889+
de = structural_simplify(de)
890+
@test SDEProblem(de, u0map, (0.0, 100.0), parammap) isa SDEProblem
891+
end

0 commit comments

Comments
 (0)