Skip to content

Commit 3ca004e

Browse files
docs: update assertions documentation
1 parent b968b92 commit 3ca004e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

docs/src/basics/Debugging.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,31 @@ Suppose we also want to validate that `u1 + u2 >= 2.0`. We can do this via the a
4242
```
4343

4444
The assertions must be an iterable of pairs, where the first element is the symbolic condition and
45-
the second is the message to be logged when the condition fails.
45+
the second is a message to be logged when the condition fails. All assertions are added to the
46+
generated code and will cause the solver to reject steps that fail the assertions. For systems such
47+
as the above where the assertion is guaranteed to eventually fail, the solver will likely exit
48+
with a `dtmin` failure..
49+
50+
```@example debug
51+
prob = ODEProblem(sys, [], (0.0, 10.0))
52+
sol = solve(prob, Tsit5())
53+
```
54+
55+
We can use `debug_system` to log the failing assertions in each call to the RHS function.
4656

4757
```@repl debug
4858
dsys = debug_system(sys; functions = []);
4959
dprob = ODEProblem(dsys, [], (0.0, 10.0));
5060
dsol = solve(dprob, Tsit5());
5161
```
5262

53-
Note the messages containing the failed assertion and corresponding message.
63+
Note the logs containing the failed assertion and corresponding message. To temporarily disable
64+
logging in a system returned from `debug_system`, use `ModelingToolkit.ASSERTION_LOG_VARIABLE`.
65+
66+
```@repl debug
67+
dprob[ModelingToolkit.ASSERTION_LOG_VARIABLE] = false;
68+
solve(drob, Tsit5());
69+
```
5470

5571
```@docs
5672
debug_system

0 commit comments

Comments
 (0)