SciML / CellMLToolkit.jl

CellMLToolkit.jl is a Julia library that connects CellML models to the Scientific Julia ecosystem.
https://docs.sciml.ai/CellMLToolkit/stable/
Other
62 stars 15 forks source link

Instability when claculating local sensitivites #90

Open H-Sax opened 2 years ago

H-Sax commented 2 years ago

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

anandijain commented 2 years ago

Hey Harry, thanks for these issues. The first link doesn't seem to resolve (Shi 2006)

H-Sax commented 2 years ago

Hey Harry, thanks for these issues. The first link doesn't seem to resolve (Shi 2006)

Sorry about this I must have copied a dodgy link

https://models.cellml.org/exposure/c49d416ae3a5132882e6ea7479ba50f5/ModelMain.cellml/view

The above should now take you to the Shi 2006 model quoted in my initial issue :)