Advertisement
Sephinroth

1535

Apr 9th, 2021
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. Q = 200
  5. P = np.zeros(Q)
  6. P[0] = 1
  7. PP = np.zeros(Q)
  8. t_max = 100
  9. dt = 0.001
  10. lmbd = 4
  11. mu = 5
  12. t = 0
  13. p0 = [1]
  14. p1 = []
  15.  
  16. while t < t_max:
  17.     PP[0] = dt * (-lmbd * P[0] + mu * P[1])
  18.     for j in range(1, Q-1):
  19.         PP[j] = dt * (-(lmbd + mu) * P[j] + lmbd * P[j-1] + mu * P[j + 1])
  20.     for j in range(Q):
  21.         P[j] += PP[j]
  22.         if j == 0: p0.append()
  23.         t += dt
  24. print(P)
  25. t_to_plot = np.linspace(0, 100, 200)
  26. plt.plot(t_to_plot, P)
  27. plt.plot()
  28. plt.show()
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement