DIY caffeine pharmacokinetics

A night of insomnia last weekend prompted me to build a mathematical model of my caffeine throughput. System dynamics provides the framework:

Model description

The stock and flow diagram shown above describes the basic system:  “Pipes” represent caffeine flow into and out of “reservoirs” (the boxes) that store caffeine. The text labels denote system variables, with the blue arrows indicating relationships between the variables. These variables parameterize the model by specifying each flow rate. The “clouds” on each end form the system boundaries.

First-order dynamics simulates the transfer of caffeine from stomach to body tissues, as well as the drug’s removal from the tissues. Therefore the half-life values for these processes fully define the model; we calculate instantaneous flow rates using the half-life values and the instantaneous amount of caffeine stored in the reservoirs.

Input signal

Two daily cups of coffee, one at 10:00 and the other at 14:00, each consumed in five minutes, forms the input signal:


The following time-series shows the simulated system response to the input signal, starting at midnight on the first day, over four days of caffeine ingestion:

Despite starting with no caffeine in the body, we see that the system reaches steady-state operation very quickly. Such constancy likely facilitates chemical dependency. We also see that caffeine remains in the system overnight for this input signal, which pretty much explains caffeine-induced insomnia.


I used Vensim PLE to model this system. Here is the model file:  caffeine.mdl.


Leave a Reply

Your email address will not be published.