Skip to content

SCCNonlinearProblem has no field u0 in SCCNonlinearSolve 1.7 #758

@mx-p9a

Description

@mx-p9a

Describe the bug 🐞

When using Modelingtoolkit, I am running into this error for [email protected] (not 1.6).
Note that for the MWE, I did not include the modelingtoolkit models and instead run SCCNonlinearSolve directly.

Expected behavior

Modelingtoolkit problem to just solve.

Minimal Reproducible Example 👇

# MWE: SCCNonlinearProblem missing `u0` field in SCCNonlinearSolve v1.7.0
# 
# ERROR: FieldError: type SCCNonlinearProblem has no field `u0`, 
#        available fields: `probs`, `explicitfuns!`, `f`, `p`, `parameters_alias`
#
# The bug is in SCCNonlinearSolve.jl line 39:
#   u0 = u0 !== nothing ? u0 : prob.u0
# But SCCNonlinearProblem does not have a `u0` field.
#

# --- Setup with BROKEN version ---
using Pkg
Pkg.activate(temp=true)
Pkg.add([
    PackageSpec(name="SciMLBase"),
    PackageSpec(name="SCCNonlinearSolve"),
    PackageSpec(name="NonlinearSolve"),
])


using SciMLBase
import SCCNonlinearSolve
import NonlinearSolve

println("SCCNonlinearSolve version: ", pkgversion(SCCNonlinearSolve))

# Create simple nonlinear subproblems
f1(u, p) = u[1]^2 - 2.0
f2(u, p) = u[1] - 1.0

prob1 = NonlinearProblem(f1, [1.0])
prob2 = NonlinearProblem(f2, [1.0])

# Create explicit functions (identity - just pass through)
explicitfun1!(p, sols) = nothing
explicitfun2!(p, sols) = nothing

# Create the SCC problem
scc_prob = SciMLBase.SCCNonlinearProblem(
    (prob1, prob2),
    (explicitfun1!, explicitfun2!),
    nothing,  # parameters
    false     # parameters_alias
)

println("Created SCCNonlinearProblem successfully")
println("Attempting to solve...")

# This triggers the bug - solve() is called without explicit u0,
# so it tries `prob.u0` but SCCNonlinearProblem has no `u0` field
sol = SciMLBase.solve(scc_prob)

println("Solution: ", sol.retcode)

Error & Stacktrace ⚠️

ERROR: LoadError: FieldError: type SCCNonlinearProblem has no field `u0`, available fields: `probs`, `explicitfuns!`, `f`, `p`, `parameters_alias`
Stacktrace:
 [1] getproperty(prob::SCCNonlinearProblem{Vector{Float64}, false, Tuple{NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f1), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}, NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f2), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}}, Tuple{typeof(explicitfun1!), typeof(explicitfun2!)}, NonlinearFunction{false, SciMLBase.FullSpecialize, Returns{Nothing}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, Nothing, Val{false}}, name::Symbol)
   @ SciMLBase ~/.julia/packages/SciMLBase/hHrRi/src/problems/nonlinear_problems.jl:547
 [2] solve(prob::SCCNonlinearProblem{Vector{Float64}, false, Tuple{NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f1), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}, NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f2), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}}, Tuple{typeof(explicitfun1!), typeof(explicitfun2!)}, NonlinearFunction{false, SciMLBase.FullSpecialize, Returns{Nothing}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, Nothing, Val{false}}, alg::SCCNonlinearSolve.SCCAlg{Nothing, Nothing}; sensealg::Nothing, u0::Nothing, p::Nothing, kwargs::@Kwargs{})
   @ SCCNonlinearSolve ~/.julia/packages/SCCNonlinearSolve/6Z5wl/src/SCCNonlinearSolve.jl:39
 [3] solve(prob::SCCNonlinearProblem{Vector{Float64}, false, Tuple{NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f1), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}, NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f2), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}}, Tuple{typeof(explicitfun1!), typeof(explicitfun2!)}, NonlinearFunction{false, SciMLBase.FullSpecialize, Returns{Nothing}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, Nothing, Val{false}}; sensealg::Nothing, u0::Nothing, p::Nothing, kwargs::@Kwargs{})
   @ SCCNonlinearSolve ~/.julia/packages/SCCNonlinearSolve/6Z5wl/src/SCCNonlinearSolve.jl:28
 [4] solve(prob::SCCNonlinearProblem{Vector{Float64}, false, Tuple{NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f1), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}, NonlinearProblem{Vector{Float64}, false, SciMLBase.NullParameters, NonlinearFunction{false, SciMLBase.FullSpecialize, typeof(f2), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem, Nothing, Nothing}}, Tuple{typeof(explicitfun1!), typeof(explicitfun2!)}, NonlinearFunction{false, SciMLBase.FullSpecialize, Returns{Nothing}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, Nothing, Val{false}})
   @ SCCNonlinearSolve ~/.julia/packages/SCCNonlinearSolve/6Z5wl/src/SCCNonlinearSolve.jl:26
 [5] top-level scope
   @ ~/code/scepter/ScepterMTK.jl/mwe_sccnonlinearsolve_bug.jl:61
 [6] include(mod::Module, _path::String)
   @ Base ./Base.jl:306
 [7] exec_options(opts::Base.JLOptions)
   @ Base ./client.jl:317
 [8] _start()
   @ Base ./client.jl:550
in expression starting at /Users/mx/code/scepter/ScepterMTK.jl/mwe_sccnonlinearsolve_bug.jl:61

Environment (please complete the following information):

  • Temp project
  Activating new project at `/var/folders/7y/gscz13l92lg37k3dypjlfbdh0000gn/T/jl_lT7hud`
   Resolving package versions...
    Updating `/private/var/folders/7y/gscz13l92lg37k3dypjlfbdh0000gn/T/jl_lT7hud/Project.toml`
  [8913a72c] + NonlinearSolve v4.12.0
⌃ [9dfe8606] + SCCNonlinearSolve v1.6.0
  [0bca4576] + SciMLBase v2.128.0
    Updating `/private/var/folders/7y/gscz13l92lg37k3dypjlfbdh0000gn/T/jl_lT7hud/Manifest.toml`
  [47edcb42] + ADTypes v1.20.0
  [7d9f7c33] + Accessors v0.1.43
  [79e6a3ab] + Adapt v4.4.0
  [4fba245c] + ArrayInterface v7.22.0
  [4c555306] + ArrayLayouts v1.12.2
  [70df07ce] + BracketingNonlinearSolve v1.6.0
  [d360d2e6] + ChainRulesCore v1.26.0
  [38540f10] + CommonSolve v0.2.4
  [bbf7d656] + CommonSubexpressions v0.3.1
  [34da2185] + Compat v4.18.1
  [a33af91c] + CompositionsBase v0.1.2
  [2569d6c7] + ConcreteStructs v0.2.3
  [187b0558] + ConstructionBase v1.6.0
  [163ba53b] + DiffResults v1.1.0
  [b552c78f] + DiffRules v1.15.1
  [a0c0ee7d] + DifferentiationInterface v0.7.13
  [ffbed154] + DocStringExtensions v0.9.5
  [4e289a0a] + EnumX v1.0.5
  [f151be2c] + EnzymeCore v0.8.17
  [e2ba6199] + ExprTools v0.1.10
  [55351af7] + ExproniconLite v0.10.14
  [9aa1b823] + FastClosures v0.3.2
  [1a297f60] + FillArrays v1.15.0
  [6a86dc24] + FiniteDiff v2.29.0
  [f6369f11] + ForwardDiff v1.3.0
  [069b7b12] + FunctionWrappers v1.1.3
  [77dc65aa] + FunctionWrappersWrappers v0.1.3
  [46192b85] + GPUArraysCore v0.2.0
  [3587e190] + InverseFunctions v0.1.17
  [92d709cd] + IrrationalConstants v0.2.6
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [692b3bcd] + JLLWrappers v1.7.1
  [ae98c720] + Jieko v0.2.1
  [ba0b0d4f] + Krylov v0.10.3
  [5078a376] + LazyArrays v2.9.4
  [87fe0de2] + LineSearch v0.1.4
  [7ed4a6bd] + LinearSolve v3.54.0
  [2ab3a3ac] + LogExpFunctions v0.3.29
  [e6f89c97] + LoggingExtras v1.2.0
  [1914dd2f] + MacroTools v0.5.16
  [bb5d69b7] + MaybeInplace v0.1.4
  [2e0e35c7] + Moshi v0.3.7
  [77ba4419] + NaNMath v1.1.3
  [8913a72c] + NonlinearSolve v4.12.0
  [be0214bd] + NonlinearSolveBase v2.9.0
  [5959db7a] + NonlinearSolveFirstOrder v1.10.0
  [9a2c21bd] + NonlinearSolveQuasiNewton v1.11.0
  [26075421] + NonlinearSolveSpectralMethods v1.6.0
  [d236fae5] + PreallocationTools v0.4.34
  [aea7be01] + PrecompileTools v1.3.3
  [21216c6a] + Preferences v1.5.1
  [3cdcf5f2] + RecipesBase v1.3.4
  [731186ca] + RecursiveArrayTools v3.42.0
  [189a3867] + Reexport v1.2.2
  [ae029012] + Requires v1.3.1
  [7e49a35a] + RuntimeGeneratedFunctions v0.5.16
⌃ [9dfe8606] + SCCNonlinearSolve v1.6.0
  [0bca4576] + SciMLBase v2.128.0
  [19f34311] + SciMLJacobianOperators v0.1.12
  [a6db7da4] + SciMLLogging v1.7.1
  [c0aeaf25] + SciMLOperators v1.14.1
  [431bcebd] + SciMLPublic v1.0.0
  [53ae85a6] + SciMLStructures v1.7.0
  [efcf1570] + Setfield v1.1.2
  [727e6d20] + SimpleNonlinearSolve v2.9.0
  [276daf66] + SpecialFunctions v2.6.1
  [90137ffa] + StaticArrays v1.9.15
  [1e83bf80] + StaticArraysCore v1.4.4
  [10745b16] + Statistics v1.11.1
  [2efcf032] + SymbolicIndexingInterface v0.3.46
  [a759f4b9] + TimerOutputs v0.5.29
  [1d5cc7b8] + IntelOpenMP_jll v2025.2.0+0
  [856f044c] + MKL_jll v2025.2.0+0
  [efe28fd5] + OpenSpecFun_jll v0.5.6+0
  [1317d2d5] + oneTBB_jll v2022.0.0+1
  [0dad84c5] + ArgTools v1.1.2
  [56f22d72] + Artifacts v1.11.0
  [2a0f44e3] + Base64 v1.11.0
  [ade2ca70] + Dates v1.11.0
  [8ba89e20] + Distributed v1.11.0
  [f43a241f] + Downloads v1.7.0
  [7b1f6079] + FileWatching v1.11.0
  [9fa8497b] + Future v1.11.0
  [b77e0a4c] + InteractiveUtils v1.11.0
  [ac6e5ff7] + JuliaSyntaxHighlighting v1.12.0
  [4af54fe1] + LazyArtifacts v1.11.0
  [b27032c2] + LibCURL v0.6.4
  [76f85450] + LibGit2 v1.11.0
  [8f399da3] + Libdl v1.11.0
  [37e2e46d] + LinearAlgebra v1.12.0
  [56ddb016] + Logging v1.11.0
  [d6f4376e] + Markdown v1.11.0
  [ca575930] + NetworkOptions v1.3.0
  [44cfe95a] + Pkg v1.12.1
  [de0858da] + Printf v1.11.0
  [9a3f8284] + Random v1.11.0
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization v1.11.0
  [6462fe0b] + Sockets v1.11.0
  [2f01184e] + SparseArrays v1.12.0
  [f489334b] + StyledStrings v1.11.0
  [fa267f1f] + TOML v1.0.3
  [a4e569a6] + Tar v1.10.0
  [cf7118a7] + UUIDs v1.11.0
  [4ec0a83e] + Unicode v1.11.0
  [e66e0078] + CompilerSupportLibraries_jll v1.3.0+1
  [deac9b47] + LibCURL_jll v8.15.0+0
  [e37daf67] + LibGit2_jll v1.9.0+0
  [29816b5a] + LibSSH2_jll v1.11.3+1
  [14a3606d] + MozillaCACerts_jll v2025.5.20
  [4536629a] + OpenBLAS_jll v0.3.29+0
  [05823500] + OpenLibm_jll v0.8.7+0
  [458c3c95] + OpenSSL_jll v3.5.4+0
  [bea87d4a] + SuiteSparse_jll v7.8.3+2
  [83775a58] + Zlib_jll v1.3.1+2
  [8e850b90] + libblastrampoline_jll v5.15.0+0
  [8e850ede] + nghttp2_jll v1.64.0+1
  [3f19e933] + p7zip_jll v17.7.0+0
  • Output of versioninfo()
Julia Version 1.12.3
Commit 966d0af0fdf (2025-12-15 11:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 12 × Apple M2 Max
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m2)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)
Environment:
  JULIA_PKG_USE_CLI_GIT = true

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions