1
1
# Modeling Nonlinear Systems
2
2
3
- In this example, we will go one step deeper and showcase the direct function
4
- generation capabilities in ModelingToolkit.jl to build nonlinear systems.
5
- Let's say we wanted to solve for the steady state of an ODE. This steady state
6
- is reached when the nonlinear system of differential equations equals zero.
7
- We use (unknown) variables for our nonlinear system.
3
+ ModelingToolkit.jl is not only useful for generating initial value problems (` ODEProblem ` ).
4
+ The package can also build nonlinear systems.
5
+ This is, for example, useful for finding the steady state of an ODE.
6
+ This steady state is reached when the nonlinear system of differential equations equals zero.
7
+
8
+ !!! note
9
+
10
+ The high level ` @mtkmodel ` macro used in the
11
+ [ getting started tutorial] (@ref getting_started)
12
+ is not yet compatible with ` NonlinearSystem ` .
13
+ We thus have to use a lower level interface to define nonlinear systems.
14
+ For an introduction to this interface, read the
15
+ [ programmatically generating ODESystems tutorial] (@ref programmatically).
8
16
9
17
``` @example nonlinear
10
18
using ModelingToolkit, NonlinearSolve
@@ -15,8 +23,6 @@ using ModelingToolkit, NonlinearSolve
15
23
eqs = [0 ~ σ * (y - x)
16
24
0 ~ x * (ρ - z) - y
17
25
0 ~ x * y - β * z]
18
- guesses = [x => 1.0, y => 0.0, z => 0.0]
19
- ps = [σ => 10.0, ρ => 26.0, β => 8 / 3]
20
26
@mtkbuild ns = NonlinearSystem(eqs)
21
27
22
28
guesses = [x => 1.0, y => 0.0, z => 0.0]
@@ -26,7 +32,9 @@ prob = NonlinearProblem(ns, guesses, ps)
26
32
sol = solve(prob, NewtonRaphson())
27
33
```
28
34
29
- We can similarly ask to generate the ` NonlinearProblem ` with the analytical
35
+ We found the ` x ` , ` y ` and ` z ` for which the right hand sides of ` eqs ` are all equal to zero.
36
+
37
+ Just like with ` ODEProblem ` s we can generate the ` NonlinearProblem ` with its analytical
30
38
Jacobian function:
31
39
32
40
``` @example nonlinear
0 commit comments