-
-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug 🐞
Solving a NonlinearProblem with an EnsembleProblem stopped working
Minimal Reproducible Example 👇
using NonlinearSolve, NonlinearSolveHomotopyContinuation
Δsweep = range(-0.01, 0.03, 101)
Kval = 0.01
Fval = 0.002
κval = 0.001
function mean_field(du, u, p)
F, Δ, K, κ, n, m_r, m_i = p
u1, v1 = u
du[1] = -F - (2*K*m_r + 4*K*n + 2*K*u1^2 + 2*K*v1^2 - Δ) * u1 - (2*K*m_i + κ / 2) * v1
du[2] = (2*K*m_i - κ / 2) * u1 + (4*K*n + 2*K*u1^2 + 2*K*v1^2 - Δ - 2*K*m_r) * v1
return nothing
end
function jacobian(du, u, p)
F, Δ, K, κ, n, m_r, m_i = p
u1, v1 = u
du[1, 1] = -0.5*κ + 2*K*m_i + 4*K*u1*v1
du[2,2] = -0.5*κ - 2*K*m_i - 4*K*u1*v1
du[1,2] = - Δ -2*K*m_r + 4*K*n + 2*K*u1^2 + 6*K*v1^2
du[2,1] = Δ - 2*K*m_r - 4*K*n - 6*K*u1^2 - 2*K*v1^2
return nothing
end
# Example parameters with n=0, m_r=0, m_i=0
p = (; F=Fval, Δ=0.01, K=Kval, κ=κval, n=0, m_r=0, m_i=0)
u0 = [0.0, 0.0]
fn = NonlinearFunction(fn; jac=jacobian)
prob = NonlinearProblem{true}(mean_field, u0, p)
sol = solve(prob) # works
alg = HomotopyContinuationJL{true}()
sol = solve(prob, alg) # works
function prob_func(prob, i, repeat)
p = (;F = 0.002, Δ = Δsweep[i], K = 0.01, κ = 0.001, n = 0, m_r = 0, m_i = 0)
MTK.remake(prob; p)
end
ensemble = EnsembleProblem(prob; prob_func)
sol_ensemble = solve(ensemble, alg)
Error & Stacktrace
MethodError: no method matching __solve(::EnsembleProblem{NonlinearProblem{Vector{Float64}, true, @NamedTuple{F::Float64, Δ::Float64, K::Float64, κ::Float64, n::Int64, m_r::Int64, m_i::Int64}, NonlinearFunction{true, SciMLBase.FullSpecialize, typeof(mean_field), UniformScaling{Bool}, Nothing, Nothing, typeof(jacobian), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, SciMLBase.StandardNonlinearProblem}, typeof(prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, ::HomotopyContinuationJL{true, AutoForwardDiff{nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}})
The function `__solve` exists, but no method is defined for this combination of argument types.
Closest candidates are:
__solve(::SciMLBase.AbstractEnsembleProblem, ::A, !Matched::SciMLBase.BasicEnsembleAlgorithm; trajectories, batch_size, progress_aggregate, pmap_batch_size, kwargs...) where A
@ SciMLBase ~/.julia/packages/SciMLBase/LFeTa/src/ensemble/basic_ensemble_solve.jl:164
__solve(!Matched::SciMLBase.AbstractNonlinearProblem, ::NonlinearSolveBase.AbstractNonlinearSolveAlgorithm, Any...; kwargs...)
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/2E600/src/solve.jl:223
__solve(!Matched::SciMLBase.AbstractNonlinearProblem, ::Any...; default_set, second_time, kwargs...)
@ NonlinearSolveBase ~/.julia/packages/NonlinearSolveBase/2E600/src/solve.jl:352
...
Stacktrace:
[1] solve(prob::EnsembleProblem{NonlinearProblem{Vector{Float64}, true, @NamedTuple{F::Float64, Δ::Float64, K::Float64, κ::Float64, n::Int64, m_r::Int64, m_i::Int64}, NonlinearFunction{true, SciMLBase.FullSpecialize, typeof(mean_field), UniformScaling{Bool}, Nothing, Nothing, typeof(jacobian), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem}, typeof(prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, args::HomotopyContinuationJL{true, AutoForwardDiff{nothing, Nothing}, @Kwargs{}}; kwargs::@Kwargs{})
@ SciMLBase ~/.julia/packages/SciMLBase/LFeTa/src/ensemble/basic_ensemble_solve.jl:361
[2] solve(prob::EnsembleProblem{NonlinearProblem{Vector{Float64}, true, @NamedTuple{F::Float64, Δ::Float64, K::Float64, κ::Float64, n::Int64, m_r::Int64, m_i::Int64}, NonlinearFunction{true, SciMLBase.FullSpecialize, typeof(mean_field), UniformScaling{Bool}, Nothing, Nothing, typeof(jacobian), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardNonlinearProblem}, typeof(prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, args::HomotopyContinuationJL{true, AutoForwardDiff{nothing, Nothing}, @Kwargs{}})
@ SciMLBase ~/.julia/packages/SciMLBase/LFeTa/src/ensemble/basic_ensemble_solve.jl:356
[3] top-level scope
Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
[961ee093] ModelingToolkit v10.26.0
[8913a72c] NonlinearSolve v4.12.0
[2ac3b008] NonlinearSolveHomotopyContinuation v0.1.7
[1dea7af3] OrdinaryDiffEq v6.102.1
⌅ [d1185830] SymbolicUtils v3.32.0
[0c5d862f] Symbolics v6.56.0
[8ea1fca8] TermInterface v2.0.0
[37e2e46d] LinearAlgebra v1.11.0
- Output of
versioninfo()
Julia Version 1.11.7
Commit f2b3dbda30a (2025-09-08 12:10 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × AMD Ryzen 5 5600X 6-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 10 default, 0 interactive, 5 GC (on 12 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_VSCODE_REPL = 1
JULIA_NUM_THREADS = 10
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working