I have a system of three ODEs. This system oscillates. I need to determine the frequency of each of the three solutions.
My file. You can download and modify this.
I'm new to Mathematica and I know this question has been asked multiple times, but I can't get it working.
{xSol, ySol, zSol} = NDSolveValue[{ode1, ode2, ode3, ic2}, {x, y, z}, {t, 0, 200}]
Plotting xSol, ySol and zSol (three interpolating functions) gives:
Can anyone show me how to determine the frequency of this thing using Reap and Sow or FFT. I've been instructed already how to do this using EcoEvo package, but I'm also wondering how to do it without such a package.
Both the Reap/Sow solution and the FFT come pretty close to what I have and need. But I fail in modifying the mentioned solutions so that it works with my code.
How do I individually determine the frequency of xSol, ySol and zSol?
My implementation of WhenEvent
For example, when I try to use WhenEvent, I used it like this:
{xSol, ySol, zSol} = NDSolveValue[{ode1, ode2, ode3, ic2, WhenEvent[x'[t] == 0, Sow[t]]}, {x, y, z}, {t, 0, 200}]
This gives me an error (which I presume to be about the WhenEvent) and my regular solutions. Because the solutions are correct, I think that the problem here is in the WhenEvent.
Error: Event location failed to converge to the requested accuracy or precision within 100 iterations between t = ... and t = ....
LATER UPDATE
{{xSol, ySol, zSol}, reapresult} = Reap[NDSolveValue[{ode1, ode2, ode3, ic2, WhenEvent[x[t] > .4 && x'[t] == 0,Sow[t]]}, {x, y, z}, {t, 0, 200} ]]
This outputs and empty list {}
I first forgot to add the Reap[]
All suggestions and solutions are highly appreciated! Many thanks


xis (almost) zero for a long time. You can use (for instance) the conditionx[t] == .8 && x'[t] > 0instead, although this of course has to be modified for similar problems. I suggest you have a look at the documentation ofWhenEvent. – Natas Oct 20 '20 at 12:16