Skip to content

Commit b963acd

Browse files
fix: fix SCCNonlinearProblem reordering parameters
1 parent 3d9a8d8 commit b963acd

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ function SciMLBase.SCCNonlinearProblem{iip}(sys::NonlinearSystem, u0map,
792792
new_eqs = eqs[reduce(vcat, eq_sccs)]
793793
@set! sys.unknowns = new_dvs
794794
@set! sys.eqs = new_eqs
795-
sys = complete(sys)
795+
@set! sys.index_cache = subset_unknowns_observed(
796+
get_index_cache(sys), sys, new_dvs, getproperty.(obs, (:lhs,)))
796797
return SCCNonlinearProblem(subprobs, explicitfuns, p, true; sys)
797798
end
798799

test/scc_nonlinear_problem.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,20 @@ end
263263
sol = solve(prob, NewtonRaphson())
264264
@test SciMLBase.successful_retcode(sol)
265265
end
266+
267+
@testset "SCCNonlinearProblem retains parameter order" begin
268+
@mtkbuild fullsys = NonlinearSystem(
269+
[0 ~ x^3 * β + y^3 * ρ - σ, 0 ~ x^2 + 2x * y + y^2, 0 ~ z^2 - 4z + 4],
270+
[x, y, z], [σ, β, ρ])
271+
272+
u0 = [x => 1.0,
273+
y => 0.0,
274+
z => 0.0]
275+
276+
p ==> 28.0,
277+
ρ => 10.0,
278+
β => 8 / 3]
279+
280+
sccprob = SCCNonlinearProblem(fullsys, u0, p)
281+
@test isequal(parameters(fullsys), parameters(sccprob.f.sys))
282+
end

0 commit comments

Comments
 (0)