stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
752 stars 188 forks source link

DAE solver with forward sensitivity analysis. #767

Closed yizhang-yiz closed 6 years ago

yizhang-yiz commented 6 years ago

Summary:

DAE solver with forward sensitivity analysis.

Description:

Differential Algebraic Equations(DAE) are more general than ODE, but also more challenging to solve. In application It usually involves an ODE system and an algebraic system. A classical example is the pendulum in Cartesian coordinates. In PK/PD applications, an example is one/two-compartment PK model linked to an Emax model, so that Emax depends on the concentration.

With IDAS from SUNDIALS library, we are able to solve DAE system. The type of initial condition of the primary, of the time derivative of the primary, and parameters can be either var or double. In the former case, forward sensitivity will be calculated with respect to var variables.

Current Version:

v2.18.0

wds15 commented 6 years ago

Can you point me to an example of a 2-cmt model linked with an Emax response which needs a DAE?

I don't see the need for a DAE here so I guess I don't get what you mean here.

(I am not objecting at all against this; I am just trying to understand use cases which are relevant to me as well).

yizhang-yiz commented 6 years ago

We can always think the simultaneous approach of PK/PD modeling as a DAE model, though it's naturally decoupled. A slightly more complex model would be a pk model with nonlinear equilibrium binding (@billgillespie showed this to me). dx1(t)/dt = -(CL + CL12) cu(t) + k21 x2(t) dx2(t)/dt = CL12 cu(t) - k21 x2(t) x1(t) = Vu cu(t) + Vb cb(t) cb(t) = Bmax * cu(t) / (Kd + cu(t))

observed value: c(t) = cu(t) + cb(t) cu(t) and cb(t) are the unbound and bound drug concentration, respectively. pk is modeled as 2-cmt with nonlinear binding.

In general as long as there is some non-dynamic constraint to a dynamical system it tend to become a DAE system. The constraint in population dynamics often is a result of intervention from outside.