This is an old version, view current version.
16.5 Solving DAEs
Stan provides a dae
function for solving DAEs, so that the above chemical reaction
equation can be solved in the following code.
data {
int N;
vector[3] yy0;
vector[3] yp0;
real t0;
real alpha;
real beta;
array[N] real ts;
array[N] vector[3] y;
}parameters {
real gamma;
}transformed parameters {
vector[3] y_hat[N] = dae(chem, yy0, yp0, t0, ts, alpha, beta, gamma);
}
Since gamma
is a parameter, the DAE solver is called in the transformed parameters block.