-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support tracing for all and add an example
- Loading branch information
Showing
16 changed files
with
397 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# [Logging the Solve Process](@ logging_api) | ||
|
||
All NonlinearSolve.jl native solvers allow storing and displaying the trace of the nonlinear | ||
solve process. This is controlled by 3 keyword arguments to `solve`: | ||
|
||
1. `show_trace`: Must be `Val(true)` or `Val(false)`. This controls whether the trace is | ||
displayed to the console. (Defaults to `Val(false)`) | ||
2. `trace_level`: Needs to be one of Trace Objects: [`TraceMinimal`](@ref), | ||
[`TraceWithJacobianConditionNumber`](@ref), or [`TraceAll`](@ref). This controls the | ||
level of detail of the trace. (Defaults to `TraceMinimal()`) | ||
3. `store_trace`: Must be `Val(true)` or `Val(false)`. This controls whether the trace is | ||
stored in the solution object. (Defaults to `Val(false)`) | ||
|
||
## Example Usage | ||
|
||
```@example tracing | ||
using ModelingToolkit, NonlinearSolve | ||
@variables x y z | ||
@parameters σ ρ β | ||
# Define a nonlinear system | ||
eqs = [0 ~ σ * (y - x), | ||
0 ~ x * (ρ - z) - y, | ||
0 ~ x * y - β * z] | ||
@named ns = NonlinearSystem(eqs, [x, y, z], [σ, ρ, β]) | ||
u0 = [x => 1.0, y => 0.0, z => 0.0] | ||
ps = [σ => 10.0 ρ => 26.0 β => 8 / 3] | ||
prob = NonlinearProblem(ns, u0, ps) | ||
solve(prob) | ||
``` | ||
|
||
This produced the output, but it is hard to diagnose what is going on. We can turn on | ||
the trace to see what is happening: | ||
|
||
```@example tracing | ||
solve(prob; show_trace = Val(true), trace_level = TraceAll(10)) | ||
``` | ||
|
||
You can also store the trace in the solution object: | ||
|
||
```@example tracing | ||
sol = solve(prob; trace_level = TraceAll(), store_trace = Val(true)); | ||
sol.trace | ||
``` | ||
|
||
## API | ||
|
||
```@docs | ||
TraceMinimal | ||
TraceWithJacobianConditionNumber | ||
TraceAll | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.