# Method of Line with DifferentialEquations.jl

**URL:** <https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000>\
**Category:** General Usage\
**Created:** [May 18, 2018, 5:31pm UTC](https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000 "2018-05-18T17:31:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthieu](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Post date:** [May 18, 2018, 5:31pm UTC](https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000/1 "2018-05-18T17:31:21Z")

</div>

What algorithm/option in DifferentialEquations should I choose to solve efficiently a large and stiff system of ODE (a system of 100 to 10\_000 say) when I am _only_ interested in the value of the stationary solution (i.e I know that system of ODE converges to a constant vector and I just want to find this constant).

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 18, 2018, 5:56pm UTC](https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000/2 "2018-05-18T17:56:07Z")

</div>

`CVODE_BDF(linear_solver = :GMRES)` with the solver options `save_everystep=false,save_start=false` is likely what you’re looking for.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 18, 2018, 5:59pm UTC](https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000/3 "2018-05-18T17:59:28Z")

</div>

This blog post explains a workflow for doing exactly this: [http://www.stochasticlifestyle.com/solving-systems-stochastic-pdes-using-gpus-julia/](http://www.stochasticlifestyle.com/solving-systems-stochastic-pdes-using-gpus-julia/)

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [May 18, 2018, 6:02pm UTC](https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000/4 "2018-05-18T18:02:16Z")

</div>

If you know that there is a unique stationary solution and you are only interested in it, maybe you try a Newton method to find the equilibrium directly.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 18, 2018, 6:17pm UTC](https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000/5 "2018-05-18T18:17:51Z")

</div>

> [@rveltz](#):
>
> If you know that there is a unique stationary solution and you are only interested in it, maybe you try a Newton method to find the equilibrium directly.

True. But that doesn’t capture initial condition dependence if that’s a thing in this model. FWIW if you use the steady state stuff then this is simplified, and then switching between rootfinding and a dynamical form is trivialized:

[http://docs.juliadiffeq.org/latest/solvers/steady\_state\_solve.html#SteadyStateDiffEq.jl-1](http://docs.juliadiffeq.org/latest/solvers/steady_state_solve.html#SteadyStateDiffEq.jl-1)

```julia
# Newton method via nlsolve choice, defaults to NLsolve.jl
sol = solve(prob,SSRootfind()) 
# Dynamical solve to steady-state, automatically exits when `norm(du)< ...`
sol = solve(prob,DynamicSS(CVODE_BDF()),dt=1.0)

```

---

<div class="post-metadata">

**Author:** ![matthieu](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Post date:** [May 18, 2018, 7:52pm UTC](https://discourse.julialang.org/t/method-of-line-with-differentialequations-jl/11000/6 "2018-05-18T19:52:17Z")

</div>

DynamicSS is exactly what I was looking for. Thanks a lot!
