I have a problem with solving a Differential Equation system properly. The code is working, but the solution is wrong (which I know for certain because I am reproducing results of someone else).
The system (in easy terms) is given by:
(d/dt)A(t) = -B(t)*g(A(t), t)
(d/dt)B(t) = B(t)^2 * f(A(t),t, (d/dt)A(t) )
where f and g are complicated functions, which also include integrals, but this integrals are not over t or A/B.
So I read the Tutorial for the DifferentialEquations package and also implemented some other easy systems correctly. Now I try to implement the System above as follows:
using DifferentialEquations function Eqs(du,u,p,t) du=u*g(u,t) du=u^2 * f(u,du,t) end u0=[10^-5,1,0,0] tspan(10^4, 10^-4) #solving "backwards" prob=ODEProblem(Eqs,u0,tspan,p) sol=solve(prob,AutoTsit5(Rosenbrock23()))]
After plotting the solution I can see that this is not correct. Moreover I tried the following:
sol_array = convert(Array,sol) t_array = convert(Array,sol.t)
And look at the values for the derivatives:
Which (in my understanding) gives me the results for (d/dt)A and (d/dt)B for the timesteps. But this array is completely filled with 0 which I find very strange, because my values for A and B are growing, so how can the derivative be 0?
So I have 2 different possibilities for this:
A) I do not understand the Differentialequations Package correctly and the implementation of my system is wrong.
B) The Equation is very Stiff and the solver fails.
According to this stackoverflow post:
the different solver of the package are sophisticated enough to solve all not-too-exotic problems. I already used a variety of different solvers described in the documentation, but my problem still remains, such that I think that A) is my problem.
edit: initial conditions are u0=[10^-5,1] not u0=[10^-5,0] and small mistake in DEQ
edit2: p added in definition