def test_basic_analytics(self): S, I, R, eta, rho, omega, t = symbols("S I R eta rho omega, t") SIRS = SymbolicEpiModel([S, I, R]) SIRS.set_processes([ #### transmission process #### # S + I (eta)-> I + I (S, I, eta, I, I), #### transition processes #### # I (rho)-> R # R (omega)-> S (I, rho, R), (R, omega, S), ]) odes = SIRS.ODEs() expected = [ Eq(Derivative(S, t), -I * S * eta + R * omega), Eq(Derivative(I, t), I * (S * eta - rho)), Eq(Derivative(R, t), I * rho - R * omega) ] assert (all([got == exp for got, exp in zip(odes, expected)])) fixed_points = SIRS.find_fixed_points() expected = FiniteSet((S, 0, 0), (rho / eta, R * omega / rho, R)) assert (all([got == exp for got, exp in zip(fixed_points, expected)])) J = SIRS.jacobian() expected = Matrix([[-I * eta, -S * eta, omega], [I * eta, S * eta - rho, 0], [0, rho, -omega]]) N = SIRS.N_comp assert (all( [J[i, j] == expected[i, j] for i in range(N) for j in range(N)])) eig = SIRS.get_eigenvalues_at_disease_free_state() expected = {-omega: 1, eta - rho: 1, 0: 1} assert (all([v == expected[k] for k, v in eig.items()]))
]) SIS.add_transition_processes([ (I, rho, S), ]) print(SIS.find_fixed_points()) print(SIS.get_eigenvalues_at_fixed_point({S: 1})) print("==========") SIS = SymbolicEpiModel([S, I]) SIS.set_processes([ (I, S, eta / (1 - I), I, I), (I, rho, S), ]) print(SIS.jacobian()) print(SIS.get_eigenvalues_at_disease_free_state()) N = sympy.symbols("N") epi = SymbolicSIRSModel(eta, rho, omega, initial_population_size=N) print() print(epi.ODEs()) print(epi.find_fixed_points()) print("==========") x = sympy.symbols("x") SIS = SymbolicEpiModel([x, I]) SIS.set_processes([ (I, x, eta / (1 - I), I, I), (I, rho, x), ])