利用python 写出dS/dt=-β1SI-β2SE-φS, dV/dt=φS- 1-( )σ ( ) β1I+β2E V, dE/dt=β1SI+β2SE+ 1-( )σ ( ) β1I+β2E V-αE, dI/dt=αE-γI, dR/dt=γI ■ ■
时间: 2023-05-29 08:06:43 浏览: 108
import numpy as np
from scipy.integrate import odeint
# set parameters
beta1 = 0.2
beta2 = 0.3
phi = 0.1
sigma = 0.1
alpha = 0.05
gamma = 0.02
# define the system of ODEs
def model(y, t):
S, V, E, I, R = y
dSdt = -beta1*S*I - beta2*S*E - phi*S
dVdt = phi*S - (1-sigma*V)*(beta1*I + beta2*E)*V
dEdt = beta1*S*I + beta2*S*E + (1-sigma*V)*(beta1*I + beta2*E)*V - alpha*E
dIdt = alpha*E - gamma*I
dRdt = gamma*I
return [dSdt, dVdt, dEdt, dIdt, dRdt]
# set initial conditions
y0 = [0.9, 0.1, 0.01, 0.001, 0]
# set time points
t = np.linspace(0, 100, 1000)
# solve the ODEs
y = odeint(model, y0, t)
# plot the results
import matplotlib.pyplot as plt
plt.plot(t, y[:,0], label='S')
plt.plot(t, y[:,1], label='V')
plt.plot(t, y[:,2], label='E')
plt.plot(t, y[:,3], label='I')
plt.plot(t, y[:,4], label='R')
plt.xlabel('Time')
plt.ylabel('Population')
plt.title('SEIR Model')
plt.legend()
plt.show()
阅读全文