# Compartmental Systems¶

CompartmentalSystems is a Python package to deal with compartmental models of the form

\[\frac{d}{dt}\,x(t) = B(x(t),t)\,x(t) + u(t).\]

Since most computations are based on the state transition operator \(\Phi\) that solves

\[\frac{d}{dt}\,\Phi(t,s) = B(t)\,\Phi(t,s),\quad \Phi(s,s) = \bf{I},\]

nonlinear models need to be linearized in the first step. Then the package provides numerical computation of

age

- compartmental age densities
- system age densities
- compartmental age mean and higher order moments
- system age mean and higher order moments
- compartmental age quantiles
- system age quantiles

transit time

- forward and backward transit time densities
- backward transit time mean and higher order moments
- forward and backward transit time quantiles

## Table of Contents¶

`smooth_reservoir_model` |
Module for symbolical treatment of smooth reservoir models. |

`smooth_model_run` |
Module for numerical treatment of smooth reservoir models. |

`start_distributions` |
Module for computing age distributions or moments thereof to be used as start distributions in subsequent simulations. |

## Jupyter notebook examples¶

## Important Note¶

\(B(t)=(b_{ij}(t))\) is supposed to be a *compartmental matrix* for all times \(t\):

- \(b_{ii}(t)\leq0\) for all \(i\)
- \(b_{ij}(t)\geq0\) for \(i\neq j\)
- \(\sum\limits_{i=1}^d b_{ij}(t)\leq 0\) for all \(j\)