|
| 1 | +# Verbosity Control |
| 2 | + |
| 3 | +## Verbosity Specification with SciMLLogging.jl |
| 4 | + |
| 5 | +BoundaryValueDiffEq.jl uses SciMLLogging.jl to provide users with fine-grained control over logging and diagnostic output during BVP solving. The `BVPVerbosity` struct allows you to customize which messages are displayed, from deprecation warnings to detailed debugging information about solver convergence, linear algebra issues, and internal NonlinearSolve.jl/Optimization.jl solver diagnostics. |
| 6 | + |
| 7 | +## Basic Usage |
| 8 | + |
| 9 | +Pass a `BVPVerbosity` object to `solve` or `init` using the `verbose` keyword argument: |
| 10 | + |
| 11 | +```julia |
| 12 | +using BoundaryValueDiffEq |
| 13 | + |
| 14 | +# Define a boundary value problem |
| 15 | +function f!(du, u, p, t) |
| 16 | + du[1] = u[2] |
| 17 | + du[2] = -u[1] |
| 18 | +end |
| 19 | + |
| 20 | +function bc!(res, u, p, t) |
| 21 | + res[1] = u[1][1] |
| 22 | + res[2] = u[end][1] - 1 |
| 23 | +end |
| 24 | + |
| 25 | +u0 = [0.0, 1.0] |
| 26 | +tspan = (0.0, 1.0) |
| 27 | +prob = BVProblem(f!, bc!, u0, tspan) |
| 28 | + |
| 29 | +# Solve with detailed verbosity to see convergence info |
| 30 | +verbose = BVPVerbosity(Detailed()) |
| 31 | +sol = solve(prob, MIRK4(), dt = 0.1, verbose = verbose) |
| 32 | + |
| 33 | +# Solve with completely silent output (no warnings or deprecations) |
| 34 | +sol = solve(prob, MIRK4(), dt = 0.1, verbose = BVPVerbosity(None())) |
| 35 | + |
| 36 | +# Solve with default verbosity (standard preset) |
| 37 | +sol = solve(prob, MIRK4(), dt = 0.1) # equivalent to verbose = BVPVerbosity() |
| 38 | +``` |
| 39 | + |
| 40 | +## Controlling Internal Solver Verbosity |
| 41 | + |
| 42 | +BoundaryValueDiffEq.jl solvers internally use NonlinearSolve.jl (for nonlinear systems) or Optimization.jl (when using optimization-based methods). You can control the verbosity of these internal solvers independently: |
| 43 | + |
| 44 | +```julia |
| 45 | +# Silence BVP messages but show all NonlinearSolve convergence info |
| 46 | +verbose = BVPVerbosity( |
| 47 | + None(), |
| 48 | + nonlinear_verbosity = All() |
| 49 | +) |
| 50 | +sol = solve(prob, MIRK4(), dt = 0.1, verbose = verbose) |
| 51 | + |
| 52 | +# Show standard BVP messages but silence NonlinearSolve output |
| 53 | +verbose = BVPVerbosity( |
| 54 | + Standard(), |
| 55 | + nonlinear_verbosity = None() |
| 56 | +) |
| 57 | +sol = solve(prob, MIRK4(), dt = 0.1, verbose = verbose) |
| 58 | + |
| 59 | +# Control Optimization.jl verbosity when using optimization-based methods |
| 60 | +using Optimization, OptimizationOptimJL |
| 61 | + |
| 62 | +verbose = BVPVerbosity( |
| 63 | + Standard(), |
| 64 | + optimization_verbosity = Detailed() |
| 65 | +) |
| 66 | +sol = solve(prob, MIRK4(optimize = OptimizationOptimJL.BFGS()), dt = 0.1, verbose = verbose) |
| 67 | +``` |
| 68 | + |
| 69 | +## API Reference |
| 70 | + |
| 71 | +```@docs |
| 72 | +BVPVerbosity |
| 73 | +``` |
0 commit comments