File tree Expand file tree Collapse file tree 2 files changed +38
-11
lines changed Expand file tree Collapse file tree 2 files changed +38
-11
lines changed Original file line number Diff line number Diff line change @@ -246,30 +246,56 @@ function Base.:(==)(sys1::SDESystem, sys2::SDESystem)
246
246
end
247
247
248
248
function __num_isdiag_noise (mat)
249
- for j in axes (mat, 2 )
249
+ for i in axes (mat, 1 )
250
250
nnz = 0
251
- for i in axes (mat, 1 )
251
+ for j in axes (mat, 2 )
252
252
if ! isequal (mat[i, j], 0 )
253
253
nnz += 1
254
254
end
255
255
end
256
256
if nnz > 1
257
- return false
257
+ return ( false )
258
258
end
259
259
end
260
260
true
261
261
end
262
262
function __get_num_diag_noise (mat)
263
- map (axes (mat, 2 )) do j
264
- for i in axes (mat, 1 )
265
- if ! isequal (mat[i, j], 0 )
266
- return mat[i, j]
263
+ map (axes (mat, 1 )) do i
264
+ for j in axes (mat, 2 )
265
+ mij = mat[i, j]
266
+ if ! isequal (mij, 0 )
267
+ return mij
267
268
end
268
269
end
269
270
0
270
271
end
271
272
end
272
273
274
+ # function __num_isdiag_noise(mat)
275
+ # for j in axes(mat, 2)
276
+ # nnz = 0
277
+ # for i in axes(mat, 1)
278
+ # if !isequal(mat[i, j], 0)
279
+ # nnz += 1
280
+ # end
281
+ # end
282
+ # if nnz > 1
283
+ # return false
284
+ # end
285
+ # end
286
+ # true
287
+ # end
288
+ # function __get_num_diag_noise(mat)
289
+ # map(axes(mat, 2)) do j
290
+ # for i in axes(mat, 1)
291
+ # if !isequal(mat[i, j], 0)
292
+ # return mat[i, j]
293
+ # end
294
+ # end
295
+ # 0
296
+ # end
297
+ # end
298
+
273
299
function generate_diffusion_function (sys:: SDESystem , dvs = unknowns (sys),
274
300
ps = full_parameters (sys); isdde = false , kwargs... )
275
301
eqs = get_noiseeqs (sys)
Original file line number Diff line number Diff line change @@ -726,10 +726,10 @@ end
726
726
@testset " Non-diagonal noise check" begin
727
727
@parameters σ ρ β
728
728
@variables x (tt) y (tt) z (tt)
729
- @brownian a b c
730
- eqs = [D (x) ~ σ * (y - x) + 0.1 a * x + 0.1 b * y ,
731
- D (y) ~ x * (ρ - z) - y + 0.1 b * y,
732
- D (z) ~ x * y - β * z + 0.1 c * z]
729
+ @brownian a b c d e f
730
+ eqs = [D (x) ~ σ * (y - x) + 0.1 a * x + d ,
731
+ D (y) ~ x * (ρ - z) - y + 0.1 b * y + e ,
732
+ D (z) ~ x * y - β * z + 0.1 c * z + f ]
733
733
@mtkbuild de = System (eqs, tt)
734
734
735
735
u0map = [
749
749
@test_throws ErrorException solve (prob, SOSRI ()). retcode== ReturnCode. Success
750
750
# ImplicitEM does work for non-diagonal noise
751
751
@test solve (prob, ImplicitEM ()). retcode == ReturnCode. Success
752
+ @test size (ModelingToolkit. get_noiseeqs (de)) == (3 , 6 )
752
753
end
753
754
754
755
@testset " Diagonal noise, less brownians than equations" begin
You can’t perform that action at this time.
0 commit comments