Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/ModelingToolkitBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Moshi = "2e0e35c7-a2e4-4343-998d-7ef72827ed2d"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
Expand All @@ -48,6 +49,7 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
SCCNonlinearSolve = "9dfe8606-65a1-4bb3-9748-cb89d1561431"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
SciMLPublic = "431bcebd-1456-4ced-9d72-93c2757fff0b"
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand Down Expand Up @@ -140,6 +142,7 @@ Mooncake = "0.5"
Moshi = "0.3.6"
NaNMath = "0.3, 1"
NonlinearSolve = "4.3"
NonlinearSolveBase = "2.25.0"
OffsetArrays = "1"
OrderedCollections = "1"
OrdinaryDiffEq = "6.82.0, 7"
Expand All @@ -160,6 +163,7 @@ Reexport = "0.2, 1"
RuntimeGeneratedFunctions = "0.5.12"
SCCNonlinearSolve = "1.8.1"
SciMLBase = "2.149.0, 3"
SciMLLogging = "1.10.1, 2"
SciMLPublic = "1.0.0"
SciMLStructures = "1.7"
Serialization = "1"
Expand Down
2 changes: 2 additions & 0 deletions lib/ModelingToolkitBase/src/ModelingToolkitBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ import Random: AbstractRNG
import DomainSets
# For `LinearInitializationProblem`
import SCCNonlinearSolve
using NonlinearSolveBase: NonlinearVerbosity
using SciMLLogging: None

export @derivatives

Expand Down
3 changes: 2 additions & 1 deletion lib/ModelingToolkitBase/src/systems/problem_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,8 @@ function maybe_build_initialization_problem(

orig_op = copy(op)
initializeprob = ModelingToolkitBase.InitializationProblem{iip}(
sys, t, op; guesses, time_dependent_init, initialization_eqs, fast_path = true,
sys, t, op; verbose = NonlinearVerbosity(linear_verbosity = None()),
guesses, time_dependent_init, initialization_eqs, fast_path = true,
use_scc, u0_constructor, p_constructor, eval_expression, eval_module,
missing_guess_value, is_steadystateprob, kwargs...
)
Expand Down
21 changes: 21 additions & 0 deletions lib/ModelingToolkitBase/test/initializationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ using DiffEqBase: BrownFullBasicInit
import DiffEqNoiseProcess
using Setfield: @set!
import SymbolicUtils as SU
using NonlinearSolveBase: NonlinearVerbosity
using SciMLLogging: None

const ERRMOD = @isdefined(ModelingToolkit) ? ModelingToolkit.StateSelection : ModelingToolkitBase
missing_guess_value = if @isdefined(ModelingToolkit)
Expand Down Expand Up @@ -2040,6 +2042,25 @@ if @isdefined(ModelingToolkit)
end
end

@testset "Default `verbose` kwarg silences linear solve chatter on initializeprob" begin
@variables a(t) b(t)
@parameters k
eqs = [D(a) ~ k * a + b,
0 ~ a + b - 1]
@mtkbuild verbsys = ODESystem(eqs, t)

prob = ODEProblem(verbsys, [a => 0.5, k => 1.0], (0.0, 1.0))

@test haskey(prob.f.initializeprob.kwargs, :verbose)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a @test_nowarn?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, for a meaningful test we would need a test case that always causes some kind of blas error, or causes blas to have invalid arguments, since those are the only two toggles we're turning off.
This already tests that the correct verbosity settings get in to the nonlinear solver, adding a @test_logs would basically just be testing that the verbosity system works in NonlinearSolve, but that's already tested in NonlinearSolve.

v = prob.f.initializeprob.kwargs[:verbose]
@test v isa NonlinearVerbosity
@test v.linear_verbosity isa None

custom = NonlinearVerbosity()
prob2 = ODEProblem(verbsys, [a => 0.5, k => 1.0], (0.0, 1.0); verbose = custom)
@test prob2.f.initializeprob.kwargs[:verbose] === custom
end

@testset "Output arrays from constant RHS under ForwardDiff" begin
# Issue #4457
@parameters m=1.5 d=9.0
Expand Down
Loading