beta /( * * gamma /( * dt min simulate for days n_t int( * /dtcorresponding no of hours dt*n_t end time u_ [ ut ode_fe(fu_ dtts [:, [:, [:, fig plt figure( plt plot(tstitrfig legend(( )(' '' '' ')'lower right'plt xlabel('hours'plt show(consistency checkn [ [ [ eps - tolerance for comparing real numbers for in range(len( ))sir_sum [ni[nr[nif abs(sir_sum nepsprint '**consistency check faileds+ + =% !% %(sir_sumnif __name__ ='__main__'demo_sir(recall that the returned from ode_fe contains all components (si rin the solution vector at all time points we therefore need to extract the si and values in separate arrays for further analysis and easy plotting another key feature of this higher-quality code is the consistency check by adding the three differential equations in the sir modelwe realize that which means that ci cr const we can check that this relation holds by comparing rn to the sum of the initial conditions the check is not full-fledged verificationbut it is much better than doing nothing and hoping that the computation is correct exercise suggests another method for controlling the quality of the numerical solution time-restricted immunity let us now assume that immunity after the disease only lasts for some certain time period this means that there is transport from the state to the state