diff --git a/src/systems/systems.jl b/src/systems/systems.jl index 3391e59369..a166ff8d8a 100644 --- a/src/systems/systems.jl +++ b/src/systems/systems.jl @@ -128,14 +128,16 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal @views copyto!(sorted_g_rows[i, :], g[g_row, :]) end # Fix for https://github.com/SciML/ModelingToolkit.jl/issues/2490 - if isdiag(sorted_g_rows) - # If the noise matrix is diagonal, then we just give solver just takes a vector column of equations + if sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1 + # If there's only one brownian variable referenced across all the equations, + # we get a Nx1 matrix of noise equations, which is a special case known as scalar noise + noise_eqs = sorted_g_rows[:, 1] + is_scalar_noise = true + elseif isdiag(sorted_g_rows) + # If the noise matrix is diagonal, then the solver just takes a vector column of equations # and it interprets that as diagonal noise. noise_eqs = diag(sorted_g_rows) is_scalar_noise = false - elseif sorted_g_rows isa AbstractMatrix && size(sorted_g_rows, 2) == 1 - noise_eqs = sorted_g_rows[:, 1] - is_scalar_noise = true else noise_eqs = sorted_g_rows is_scalar_noise = false