Skip to content

Commit 00f42a0

Browse files
MasonProtterChrisRackauckas
authored andcommitted
add test that scalar noise across multiple equations works properly
1 parent 28733ee commit 00f42a0

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/systems/systems.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal
135135
elseif sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1
136136
##-------------------------------------------------------------------------------
137137
## TODO: re-enable this code once we add a way to signal that the noise is scalar
138-
# sorted_g_rows[:, 1] # Take a vector slice so solver knows there's no mixing
138+
# sorted_g_rows[:, 1]
139139
##-------------------------------------------------------------------------------
140140
sorted_g_rows
141141
else

test/sdesystem.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,13 +684,25 @@ let
684684
@test_broken solve(prob, SOSRI()).retcode == ReturnCode.Success
685685
end
686686

687-
let
687+
let # test to make sure that scalar noise always recieve the same kicks
688+
@variables x(t) y(t)
689+
@brownian a
690+
eqs = [D(x) ~ a,
691+
D(y) ~ a]
692+
693+
@mtkbuild de = System(eqs, t)
694+
prob = SDEProblem(de, [x => 0, y => 0], (0.0, 10.0), [])
695+
sol = solve(prob, ImplicitEM())
696+
@test sol[end][1] == sol[end][2]
697+
end
698+
699+
let # test that diagonal noise is corrently handled
688700
@parameters σ ρ β
689701
@variables x(t) y(t) z(t)
690702
@brownian a b c
691-
eqs = [D(x) ~ σ * (y - x) + 0.1a * x,
703+
eqs = [D(x) ~ σ * (y - x) + 0.1a * x,
692704
D(y) ~ x *- z) - y + 0.1b * y,
693-
D(z) ~ x * y - β * z + 0.1c * z]
705+
D(z) ~ x * y - β * z + 0.1c * z]
694706

695707
@mtkbuild de = System(eqs, t)
696708

@@ -707,5 +719,6 @@ let
707719
]
708720

709721
prob = SDEProblem(de, u0map, (0.0, 100.0), parammap)
722+
# SOSRI only works for diagonal and scalar noise
710723
@test solve(prob, SOSRI()).retcode == ReturnCode.Success
711724
end

0 commit comments

Comments
 (0)