Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. from scipy.integrate import odeint
  5.  
  6. # Set random seed (for reproducibility)
  7. np.random.seed(1000)
  8.  
  9. # Start and end time (in milliseconds)
  10. tmin = 0.0
  11. tmax = 50.0
  12.  
  13. # Average potassium channel conductance per unit area (mS/cm^2)
  14. gK = 36.0
  15.  
  16. # Average sodoum channel conductance per unit area (mS/cm^2)
  17. gNa = 120.0
  18.  
  19. # Average leak channel conductance per unit area (mS/cm^2)
  20. gL = 0.3
  21.  
  22. # Membrane capacitance per unit area (uF/cm^2)
  23. Cm = 1.0
  24.  
  25. # Potassium potential (mV)
  26. VK = -12.0
  27.  
  28. # Sodium potential (mV)
  29. VNa = 115.0
  30.  
  31. # Leak potential (mV)
  32. Vl = 10.613
  33.  
  34. # Time values
  35. T = np.linspace(tmin, tmax, 10000)
  36.  
  37. # Potassium ion-channel rate functions
  38.  
  39. def alpha_n(Vm):
  40. return (0.01 * (10.0 - Vm)) / (np.exp(1.0 - (0.1 * Vm)) - 1.0)
  41.  
  42. def beta_n(Vm):
  43. return 0.125 * np.exp(-Vm / 80.0)
  44.  
  45. # Sodium ion-channel rate functions
  46.  
  47. def alpha_m(Vm):
  48. return (0.1 * (25.0 - Vm)) / (np.exp(2.5 - (0.1 * Vm)) - 1.0)
  49.  
  50. def beta_m(Vm):
  51. return 4.0 * np.exp(-Vm / 18.0)
  52.  
  53. def alpha_h(Vm):
  54. return 0.07 * np.exp(-Vm / 20.0)
  55.  
  56. def beta_h(Vm):
  57. return 1.0 / (np.exp(3.0 - (0.1 * Vm)) + 1.0)
  58.  
  59. # n, m, and h steady-state values
  60.  
  61. def n_inf(Vm=0.0):
  62. return alpha_n(Vm) / (alpha_n(Vm) + beta_n(Vm))
  63.  
  64. def m_inf(Vm=0.0):
  65. return alpha_m(Vm) / (alpha_m(Vm) + beta_m(Vm))
  66.  
  67. def h_inf(Vm=0.0):
  68. return alpha_h(Vm) / (alpha_h(Vm) + beta_h(Vm))
  69.  
  70. # Input stimulus
  71. def Id(t):
  72. if 0.0 < t < 1.0:
  73. return 150.0
  74. elif 10.0 < t < 11.0:
  75. return 50.0
  76. return 0.0
  77.  
  78. # Compute derivatives
  79. def compute_derivatives(y, t0):
  80. dy = np.zeros((4,))
  81.  
  82. Vm = y[0]
  83. n = y[1]
  84. m = y[2]
  85. h = y[3]
  86.  
  87. # dVm/dt
  88. GK = (gK / Cm) * np.power(n, 4.0)
  89. GNa = (gNa / Cm) * np.power(m, 3.0) * h
  90. GL = gL / Cm
  91.  
  92. dy[0] = (Id(t0) / Cm) - (GK * (Vm - VK)) - (GNa * (Vm - VNa)) - (GL * (Vm - Vl))
  93.  
  94. # dn/dt
  95. dy[1] = (alpha_n(Vm) * (1.0 - n)) - (beta_n(Vm) * n)
  96.  
  97. # dm/dt
  98. dy[2] = (alpha_m(Vm) * (1.0 - m)) - (beta_m(Vm) * m)
  99.  
  100. # dh/dt
  101. dy[3] = (alpha_h(Vm) * (1.0 - h)) - (beta_h(Vm) * h)
  102.  
  103. return dy
  104.  
  105. # State (Vm, n, m, h)
  106. Y = np.array([0.0, n_inf(), m_inf(), h_inf()])
  107.  
  108. # Solve ODE system
  109. # Vy = (Vm[t0:tmax], n[t0:tmax], m[t0:tmax], h[t0:tmax])
  110. Vy = odeint(compute_derivatives, Y, T)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement