CellMLToolkit.jl icon indicating copy to clipboard operation
CellMLToolkit.jl copied to clipboard

Instability when claculating local sensitivites

Open H-Sax opened this issue 2 years ago • 2 comments

Hi,

I am trying to calculate the local sensitivities for a large circulation model [(Shi 2006)]

I am Importing the model using CellML.jl when I define an ODEproblem and simulate the solution appears fine and also when performing GSA the results are also sound.

Using the code

using ForwardDiff

savetime = LinRange(18, 19, 100)

p = prob.p 

function circ_local(x)
    newprob = remake(prob; p=x[1:end])
    sol = solve(newprob, Tsit5(); reltol=1e-6, abstol=1e-12,saveat = savetime)
    [mean(sol[@nonamespace sys.LV₊V]), mean(sol[@nonamespace sys.Pat₊Pi])]
end
S = ForwardDiff.jacobian(circ_local,p)

Note: all the solver opts I use are the same for both simulation and performing GSA.

The above returns the following warnings with the NAN’s

Warning: First function call produced NaNs. Exiting.
└ @ OrdinaryDiffEq ~/.julia/packages/OrdinaryDiffEq/ZBye7/src/initdt.jl:121
┌ Warning: dt <= dtmin. Aborting. There is either an error in your model specification or the true solution is unstable.
└ @ SciMLBase ~/.julia/packages/SciMLBase/Vg9hW/src/integrator_interface.jl:345
2×154 Matrix{Float64}:
 NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  …  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN
 NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN     NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN

I have tried with a range of stiff solvers and low tolerance however nothing is working. I am cautious to claim model error due to the GSA and simulation running fine. This issue is also present in models Heldt 2002 and the Systemic loop as checked by me. I guess this would also be the same for the model I opened an issue about recently Smith 2004.

This issue has been opened as a result of discussion on the discourse please see here

Cheers

H-Sax avatar May 23 '22 09:05 H-Sax