Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



52 Commits

Repository files navigation


Latest PyPI version


MiTepid_sim: A Repository to Simulate the Spread of COVID-19 in any Population with a Known Age-Structure.

What this library has to offer can be summarized as follows:

  • The MiTepid_sim library simulates the dynamics of a stratified compartmental epidemiological model. A set of Ordinary Differential Equations (ODEs) is used as the mathematical basis for the model. Hence, the computational cost to run the simulations is that of a set of ODEs. Currently, SIS, SIR, and SEIR compartmental models are defined in the code, but the user can easily add any other model in the models module of the library.
  • In order to make the code relevant to the spread of SARS-CoV-2 in a population and not simply a generic model, MiTepid_sim comes with a set of contact rates that are obtained based on the available data on the spread of SARS-CoV-2 in a population. The mathematical basis of how these contact rates are calculated is explained in this manuscript, which I later on published it as an open-access paper in PLOS ONE. The contact rates are calculated assuming the population is stratified into nine age-groups, every 10 years and then 80+. The contact rates accompanying the code should be adapted based on the population density of each population in each age-group. Population distribution of some sample countries is already added to the policies module of the library. The user can easily add any other population of interest to the module.
  • The MiTepid_sim library allows us to study the effects of applying various containment policies to a given population. Such policies can affect each age-group differently and can vary in time.
  • The library can also be used to study the effects of vaccination in a population and how wide-spread vaccination should be to achieve herd-immunity. The vaccinated population can be considered simply as initial values for the Recovered (R) compartment. And the code allows us to change the initial conditions in any arbitrary time-step of choice to emulate the gradual introduction of the vaccine in a population.
  • The library comes with a set of visualizations tools that allows us to generate various plots necessary to study the effects of each policy in the evolution of the trajectories of different compartments. We can plot the trajectories per age group or as an aggregate for the whole population.
  • The contact rates used in the examples are the output of an optimisation scheme as implemented in MiTepid_opt package.


There are a few scripts in the examples folder in the repository which can be used as examples of what the code can do. To see samples of the plots generated by the code, you can look at this manuscript or this one . All the plots in these two manuscripts are generated using MiTepid_sim.


The MiTepid_sim library can be installed using the following command:

pip install mitepid




This code is tested under Python 3.8, and should work well for earlier versions of Python 3.


GNU General Public License (Version 3).


MiTepid is maintained by Vahid Samadi Bokharaie.


Simulating stratified model for the spread of COVID19 in a population.







No releases published


No packages published