-
-
Notifications
You must be signed in to change notification settings - Fork 80
Closed
Description
Mostly a repeat of this one: #88. However, that one mostly discussed for SDEs, and I got some ODE cases where this became quite relevant. When doing parameter fitting on a model containing a hill function
using Catalyst
rn = @reaction_network begin
hill(X, 1.0, K, n), ∅ --> X
d, X --> ∅
end
one sometimes encounters parameter sets
u0 = [:X => 0.2]
ps = [:K => 9.087101071878903, :n => 2.5163255503214117, :d => 4.638316464318106]
which will, when simulated, cause the ODE (due to numeric inaccuracy) to go slightly negative
oprob = ODEProblem(rn, u0, 20.0, ps)
solve(oprob)
This causes a
ERROR: DomainError with -1.6572261631222257e-6:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
in the solve
. command. Because the PositiveDomain
callback do not prevent evaluations outside of the domain, this is not a solution
using DiffEqCallbacks
solve(oprob; callback = PositiveDomain([1.0])) # Still errors.
This definitely feels like something that can come up without the user trying to do something outrageous. Not sure if there is a recommended solution, but if there is, it feels like something to create a tutorial on.
Metadata
Metadata
Assignees
Labels
No labels