Skip to content

Commit 3a4c8d7

Browse files
committed
up
1 parent 6738b03 commit 3a4c8d7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

docs/src/catalyst_applications/nonlinear_solve.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# [Finding Steady States using NonlinearSolve.jl](@id nonlinear_solve)
22

3-
We have previously described how `ReactionSystem` steady states can be found through [homotopy continuation](@ref homotopy_continuation). Catalyst also supports the creation of `NonlinearProblems` corresponding to `ODEProblems` with all left-hand side derivatives set to 0. These can be solved using the variety of nonlinear equation-solving algorithms implemented by [NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl), with the solutions corresponding to system steady states. Generally, this approach is preferred when one only wishes to find *a single solution* (with homotopy continuation being preferred when one wishes to find *all solutions*).
3+
We have previously described how `ReactionSystem` steady states can be found through [homotopy continuation](@ref homotopy_continuation). Catalyst also supports the creation of `NonlinearProblems` corresponding to `ODEProblems` with all left-hand side derivatives set to 0. These can be solved using the variety of nonlinear equation-solving algorithms implemented by [NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl), with the solutions corresponding to system steady states. Generally, using this approach is advantageous when:
4+
- Only a single steady state solution is sought.
5+
- The nonlinear system produced by the model does not correspond to a multivariate, rational, polynomial (homotopy continuation cannot be applied to these systems). Examples include models with non-integer hill coefficients or stoichiometric constants.
6+
7+
However, if all (or multiple) steady states are sought, using homotopy continuation is better.
48

59
This tutorial describes how to create `NonlinearProblem`s from Catalyst's `ReactionSystemn`s, and how to solve them using NonlinearSolve. More extensive descriptions of available solvers and options can be found in [NonlinearSolve's documentation](https://docs.sciml.ai/NonlinearSolve/stable/). If you use this in your research, please [cite the NonlinearSolve.jl](@ref nonlinear_solve_citation) and [Catalyst.jl](@ref catalyst_citation) publications.
610

@@ -41,13 +45,13 @@ nl_prob = NonlinearProblem(dimer_production, u_guess, p)
4145
Finally, we can solve it using the `solve` command, returning the steady state solution:
4246
```@example nonlinear_solve1
4347
using NonlinearSolve
44-
solve(nl_prob)
48+
sol = solve(nl_prob)
4549
```
4650

47-
NonlinearSolve provides [a wide range of potential solvers](https://docs.sciml.ai/NonlinearSolve/stable/solvers/NonlinearSystemSolvers/). If we wish to designate one, it can be supplied as a second argument to `solve`. Here, we use the Newton Trust Region method:
51+
NonlinearSolve provides [a wide range of potential solvers](https://docs.sciml.ai/NonlinearSolve/stable/solvers/NonlinearSystemSolvers/). If we wish to designate one, it can be supplied as a second argument to `solve`. Here, we use the Newton Trust Region method, and then check that the solution is equal to the previous one.
4852
```@example nonlinear_solve1
49-
solve(nl_prob, TrustRegion())
50-
nothing # hide
53+
sol_ntr = solve(nl_prob, TrustRegion())
54+
sol ≈ sol_ntr
5155
```
5256

5357
## [Finding steady states through ODE simulations](@id nonlinear_solve_ode_simulation_based)
@@ -69,7 +73,7 @@ two_state_model = @reaction_network begin
6973
(k1,k2), X1 <--> X2
7074
end
7175
```
72-
It has an infinite number of steady states. To make steady state finding possible, information of the system's conserved quantities (here $C=X1+X2$) must be provided. Since these can be computed from system initial conditions (`u0`, i.e. those provided when performing ODE simulations), designating an `u0` is often the best way. This can either be done by performing [ODE simulation-based steady state finding](@ref), using the initial condition as the initial `u` guess. Alternatively, any conservation quantities can be eliminated when the `NonlinearProblem` is created. This feature is supported by Catalyst's [conservation law finding and elimination feature](@ref network_analysis_deficiency).
76+
It has an infinite number of steady states. To make steady state finding possible, information of the system's conserved quantities (here $C=X1+X2$) must be provided. Since these can be computed from system initial conditions (`u0`, i.e. those provided when performing ODE simulations), designating an `u0` is often the best way. There are two ways to do this. First, one can perform [ODE simulation-based steady state finding](@ref), using the initial condition as the initial `u` guess. Alternatively, any conserved quantities can be eliminated when the `NonlinearProblem` is created. This feature is supported by Catalyst's [conservation law finding and elimination feature](@ref network_analysis_deficiency).
7377

7478
To eliminate conservation laws we simply provide the `remove_conserved = true` argument to `NonlinearProblem`:
7579
```@example nonlinear_solve2
@@ -82,7 +86,7 @@ here it is important that the quantities used in `u_guess` correspond to the con
8286
```@example nonlinear_solve2
8387
sol = solve(nl_prob)
8488
```
85-
We note that the output only provides a single value. The reason is that the actual system solved only contains a single equation (the other being eliminated with the conserved quantity). To find the values of $X1$ and $X2$ we can [inference the solution object using these as input](@ref simulation_structure_interfacing_solutions):
89+
We note that the output only provides a single value. The reason is that the actual system solved only contains a single equation (the other being eliminated with the conserved quantity). To find the values of $X1$ and $X2$ we can [directly query the solution object for these species' values, using the species themselves as inputs](@ref simulation_structure_interfacing_solutions):
8690
```@example nonlinear_solve2
8791
@unpack X1, X2 = two_state_model
8892
sol[X1]

0 commit comments

Comments
 (0)