Berkeley Madonna™ Programs

The following "programs" are written for Berkeley Madonna™, a mathematical modelling and differential equation solving software package developed by George Oster and Robert Macey at the University of California Berkeley and programmed by Tim Zahnley. You can use it with either a Windows or Mac operating system.

You can download Berkeley Madonna™ and try it out for no charge. This software is fully functional with the following exceptions:

  • Models cannot be saved
  • Graphs and tables cannot be saved or copied
  • A "watermark" appears in all printouts (people will know you didn't buy it)
  • The Register dialog appears each time the program is started

To run the programs below in Berkeley Madonna™,

  1. Download and install Berkeley Madonna™ on your computer
  2. Run Berkeley Madonna™
  3. Copy and paste the programs below into Madonna (one at a time)
  4. Run the program
  5. Click on the Graph menu in the header and select "Choose Variables...". Remove those that you don't want and add those you do.
  6. Click on the Graph menu in the header and select "Axis Settings...". In the "Scales" window, remove the "Automatic" scaling and click on Log for the Left and Right Y axes. You can then set the scale to that you desire, for example, a minimum of 1, a maximum of 1E10, with 10 divisions.
  7. The Help menu is indeed helpful if you have problems (with the program, that is).
  8. The names of the parameters and variables noted in the programs. You can change their values as you like. Some values may be off a realistic scale and give you weird behavior. I don't offer any guarantees.

Although I have no financial interest in Berkeley Madonna™, it is not clear how ethical it would be for me to endorse this commercial product or encourage its purchase. Were it ethical, I would say something like, "It's super: a great way to program even relatively complex differential and difference equation models for theoretical studies, or to use as a tool for teaching students mathematical modeling or quantitative subjects that use differential and difference equations."

If you don't already know, running computer simulations is fun and a lot easier than doing real experiments. If you are of the right mindset, you can even feel like you are working. 

Feel free to contact me if you have problems running any of these programs



Toxin-mediated cycling in chemostat culture

Model of antibiotic treatment with density dependent MIC

Simulation of a fluctuation test experiment

Episodic Selection for Competence

Model of Persistence and Mutation to Resistance

Model of the population dynamics of phage with CRISPR-mediated immunity

Model of the population dynamics of conjugative plasmids with CRISPR-mediated immunity

Model of the population dynamics of antibiotic treatment in continuous culture

Model of the population dynamics of antibiotic treatment with refugia




As convenient and useful as Berkeley Madonna™ is for many population dynamic and evolutionary simulations, for complex Monte Carlo simulations that require a great deal of time to run lower (?) level computer languages are more flexible and faster.   While there are a number of programming languages that can be used for these endeavors, like C++, the one I am most familiar with and fluent in is FORTRAN, ancient FORTRAN 77 to be more specific.   Although not necessary, in my experience programming in FORTRAN is a particularly enjoyable enterprise if you write and debug the code whilst listening to The Rolling Stones or The Grateful Dead (who are they?).   Once FORTRAN programs are compiled, they run very quickly, probably as fast or faster than more modern languages.   FORTRAN is also very portable; FORTRAN programs can be used without modification on many different computers, “platforms”.    The compiler I currently use is gfortran, which is associated with Xcode for Mac. 

The semi-stochastic simulations use in Levin, B. R and O.E. Cornejo (2009) The population and evolutionary dynamics of homologous gene recombination in bacteria (PLoS Genetics, In Press) was written in FORTRAN 77.   Although the same core program is used for all the simulations in this report, somewhat different versions were used for specific purposes, primarily for different forms of output.   The version of this program on this site is for competition between two populations that can differ in their rates of recombination.  This program can be used for single population simulations as well.  In this version of the program, multiple runs are generated and runs terminate when one or the competing populations dominates or a specified amount to time passes.    The output of this incarnation of the program is the time for termination, the densities of the competing populations and the mean fitness at the time of termination.

The code is somewhat annotated, the parameters and variable are defined and more, but some knowledge of FORTRAN will be needed to modify the program for your specific use.   Let me know if I can help.


Source Code

Example Input File

Example Output File