============= KMC algorithm ============= * Form and maintain a list of all possible rates :math:`r_j` in system .. math:: r_j\;\mbox{for all}\;\; j=1,2,\ldots,M :math:`M` -- number of possible events * Calculate the cummulative function .. math:: R_m=\sum_{j=1}^{m}r_j, \;\;\mbox{for all}\;\; m=1,2,\ldots,M * Generate random number :math:`\rho_1\in[0,1)` * Select event :math:`i` .. math:: R_{i-1}\leq \rho_1 R_M < R_i .. image:: images/kmc_cdf_invert.png :scale: 25% :align: center * Carry out event :math:`i` * Generate random number :math:`\rho_2\in(0,1)` * Compute time increment :math:`\Delta t` .. math:: \Delta t=-\frac{ln(\rho_2)}{R_M} * Update time: :math:`t=t+\Delta t` * Update list of events and goto next step