Skip to content

Commit fc34034

Browse files
Merge pull request #1163 from SciML/nonlinear
automatically put nonlinear systems in canonical form
2 parents 3173e03 + 7d2d9de commit fc34034

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ function NonlinearSystem(eqs, states, ps;
6565
systems=NonlinearSystem[],
6666
connection_type=nothing,
6767
)
68-
eqs = collect(eqs)
68+
# Move things over, but do not touch array expressions
69+
eqs = [0 ~ x.rhs - x.lhs for x in collect(eqs)]
70+
6971
if !(isempty(default_u0) && isempty(default_p))
7072
Base.depwarn("`default_u0` and `default_p` are deprecated. Use `defaults` instead.", :NonlinearSystem, force=true)
7173
end

test/nonlinearsystem.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ end
3737

3838
# Define a nonlinear system
3939
eqs = [0 ~ σ*(y-x),
40-
0 ~ x*-z)-y,
41-
0 ~ x*y - β*z]
40+
y ~ x*-z),
41+
β*z ~ x*y]
4242
ns = NonlinearSystem(eqs, [x,y,z], [σ,ρ,β])
4343
jac = calculate_jacobian(ns)
4444
@testset "nlsys jacobian" begin
@@ -156,4 +156,3 @@ end
156156
@test isequal(union(Set(states(sys1)), Set(states(sys2))), Set(states(sys3)))
157157
@test isequal(union(Set(equations(sys1)), Set(equations(sys2))), Set(equations(sys3)))
158158
end
159-

0 commit comments

Comments
 (0)