# How to identify oscillatory conditions in Julia ODEs?

**URL:** <https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824>\
**Category:** Modelling & Simulations\
**Tags:** question\
**Created:** [May 28, 2022, 6:29am UTC](https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824 "2022-05-28T06:29:07Z")\
**Posts on this page:** 5\
**Page:** 2

<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:** [June 30, 2022, 6:56am UTC](https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824/21 "2022-06-30T06:56:13Z")

</div>

This is still a bit mysterious to me… I am not sure I see the point.

You dont need to know the period for the conventional methods to work, actually the period is an unknown. It yields a BVP problem with a phase condition. The combination of Newton and continuation is a “basic” component of numerical bifurcation (see [periodic orbits](https://bifurcationkit.github.io/BifurcationKitDocs.jl/dev/periodicOrbit/)) and is implemented in BifurcationKit.jl

Plus, in orthogonal collocation, you can use mesh adaptation. Close to homoclinic orbits, the Fourier expansion will not yield good results.

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [July 2, 2022, 7:47pm UTC](https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824/22 "2022-07-02T19:47:09Z")

</div>

Perhaps I should restate my original need. I would like to know whether the ODE ends up giving an oscillatory equilibrium. The implementation `callback = TerminateSteadyState()` helps me by telling whether equilibrium has been reached. If `eq` has fewer cycles than `soln`, then an equilibrium had been reached and the maximum time point of eq tells me when. However, this implementation works for equilibria that do not change, like:  
 ![f7e33612790aa68d2f698091ef2f7775093ed1cb_2_666x500](https://global.discourse-cdn.com/julialang/original/3X/7/b/7b7276d460c4ef6a626daf996f95ad188c03d714.png)  
Can something similar be done with oscillatory equilibria?  
Thanks

---

<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:** [July 4, 2022, 6:22am UTC](https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824/23 "2022-07-04T06:22:47Z")

</div>

> [@Luigi\_Marongiu](#):
>
> `eq = solve(prob, Rosenbrock23(), callback = TerminateSteadyState())`

The oscillations appear at `kappa = 2.004616330703016e7` (Hopf bifurcation) with `state = [1.2295081967213114e6, 389184.48612039164, 9.496101461337554e7, 206056.3353121641, 59463.21329809305, 2.308619658134151e8]`.

```julia
julia> hopf
SuperCritical - Hopf bifurcation point at κ ≈ 2.004616330703016e7.
Frequency ω ≈ 0.06391634078691726
Period of the periodic orbit ≈ 98.30327002176668
Normal form z⋅(iω + a⋅δp + b⋅|z|²): 
(a = 5.967587852411348e-11 + 1.655914621958718e-11im, b = -3.504679044424272e-19 + 2.9623334806795282e-18im)

```

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [September 12, 2022, 11:02am UTC](https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824/24 "2022-09-12T11:02:05Z")

</div>

Sorry for the late reply. May I ask you how did you implement `hopf`? Is there a gentle introduction to bifurcation apart from the link you gave? Thank you

---

<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:** [September 12, 2022, 11:59am UTC](https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824/25 "2022-09-12T11:59:46Z")

</div>

For the code, I used BifurcationKit.jl. I will try to post the code when I find some time

For books, maybe

Hirsch, Morris W., Stephen Smale, Robert L. Devaney, and Morris W. Hirsch. _Differential Equations, Dynamical Systems, and an Introduction to Chaos_. 2nd ed. Pure and Applied Mathematics; a Series of Monographs and Textbooks, v. 60. San Diego, CA: Academic Press, 2004.

Kuznetsov, Yuri A. _Elements of Applied Bifurcation Theory, Second Edition_, n.d.

[Previous page](https://discourse.julialang.org/t/how-to-identify-oscillatory-conditions-in-julia-odes/81824.md?page=1)
