Zoom:

Copy THIS LINK to save model.

Description and instructions

This page is intended to allow development of simple compartmental analysis models. In this approach to modeling, we imagine the "population" (or whatever word is appropriate) as being divided into compartments—a barrel of monkeys, a bag of cats, a box of squirrels. For each compartment, we specify a starting size, and the "flow rates" by which things can move from one compartment to another. The system can be closed (where the total population among all compartments is constant) or open (where new members of the population can enter from a "source" compartment and leave into a "sink.") For more complicated models, you can try free programs like VenSim or Populus, or commercial software like STELLA.

Each compartment is assigned a variable name—any capital letter other than E and T (e is reserved for the base of the natural exponential and logarithmic functions, and t is used for time). The starting value for a compartment is given in parentheses below the variable name. Clicking on a compartment's variable name or initial value allows you to change the name or the value, or to delete it. You can also select which variables will be plotted when you run the model.

To create a connection between two compartments, click-and-drag from the black square in the starting compartment to (anywhere in) the ending compartment. The default flow-rate formula is '1', but each time you create a new connection, you are given the chance to edit the formula—or delete the connection. (You can also edit the formula later by clicking the connection.) Formulas can refer to any variable (compartment) name, or to t (for time). Expressions like "2a+1" are automatically changed to "2*A+1".

When the model is ready, click "Run model." If all formulas are valid, you will see a plot of the compartment values over time (computed using the classical Runge-Kutta method, RK4), or (if you prefer, and have at least two compartments) a phase plane solution curve. To see more, click "Continue."

To "save" a model (or send it to someone else), copy THIS LINK (or the one above on the left), both of which are updated whenever a substantive change is made in the model.

Technical notes

(April 2012) First release.

(October 6, 2014) Major revisions made in the interface, along with some "behind-the-scenes" changes. Switched plotting packages (from jqPlot to flot). Solution curves are now plotted using an (ad hoc) adaptive method to vary the step size, producing smoother graphs.

(October 2019) Interface updates (including ability to "zoom" font size, helpful for presentations); removed dependence on MooTools; presets stored externally in an XML file; revamped link parameters (for Facebook compatibility)

(March 2020) Interactivity for slider parameters: graphs automatically updated when a parameter changes.


TODO: Implement a true (standard) adaptive method. Add more presets.


The contents of this page are © 2019 Darryl Nester. It is available to anyone who wishes to use it (like most things on the Internet). Please send me an email if you have found it to be useful, if you have suggestions for improvement, or to suggest additional presets.