Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
127 views
#Simulation as well as Frequency Model for Iext. By using interaction can test the change in parameters of the FitzHugh-Nagumo model of a neuron in order to see how the model interacts. This simulates the model using desolve_odeint rather than Eulers. @interact def Iext(I=(0.01,0.05,0.1,0.2,0.201,0.208,0.209,0.21,0.25,0.3,0.5,0.7,0.9,1,1.5,2.0),m=(0.001,0.01,0.1,0.5,1,5),b=(0.001,0.01,0.1,0.5,1,5)): var("V","w") t=srange(0,1000,0.1) sol=desolve_odeint([(V*(1-V)*(V-0.2))-w+I,0.01*(V-(0.5*w))], ics=[m,b], dvars=[V,w], times=t) p=list_plot(zip(t,sol[:,0]), plotjoined=True)+list_plot(zip(t,sol[:,1]), plotjoined=True, color="purple") show(p)
Interact: please open in CoCalc
#Model Simulation Iext=[0.25,0.3,0.5,0.7,0.9] Frequency=[0.008,0.01,0.013,0.015,0.02] list_plot(zip(Frequency,Iext),axes_lables=["Frequency (Hz), Iext"])
verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'axes_lables'=['Frequency (Hz), Iext'] verbose 0 (163: primitive.py, options) The allowed options for Point set defined by 5 point(s) are: alpha How transparent the point is. faceted If True color the edge of the point. (only for 2D plots) hue The color given as a hue. legend_color The color of the legend text legend_label The label for this item in the legend. marker the marker symbol for 2D plots only (see documentation of plot() for details) markeredgecolorthe color of the marker edge (only for 2D plots) rgbcolor The color as an RGB tuple. size How big the point is (i.e., area in points^2=(1/72 inch)^2). zorder The layer level in which to draw verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'axes_lables'=['Frequency (Hz), Iext'] verbose 0 (163: primitive.py, options) The allowed options for Point set defined by 5 point(s) are: alpha How transparent the point is. faceted If True color the edge of the point. (only for 2D plots) hue The color given as a hue. legend_color The color of the legend text legend_label The label for this item in the legend. marker the marker symbol for 2D plots only (see documentation of plot() for details) markeredgecolorthe color of the marker edge (only for 2D plots) rgbcolor The color as an RGB tuple. size How big the point is (i.e., area in points^2=(1/72 inch)^2). zorder The layer level in which to draw verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'axes_lables'=['Frequency (Hz), Iext'] verbose 0 (163: primitive.py, options) The allowed options for Point set defined by 5 point(s) are: alpha How transparent the point is. faceted If True color the edge of the point. (only for 2D plots) hue The color given as a hue. legend_color The color of the legend text legend_label The label for this item in the legend. marker the marker symbol for 2D plots only (see documentation of plot() for details) markeredgecolorthe color of the marker edge (only for 2D plots) rgbcolor The color as an RGB tuple. size How big the point is (i.e., area in points^2=(1/72 inch)^2). zorder The layer level in which to draw
var("V") var("w")
V w
f(V)=V*(1-V)*(V-0.2)
Vprime(V)=f(V)-w+0.1
Wprime(w)=0.01*(V-(0.5*w))
plot_vector_field((Vprime(V), Wprime(w)), (V,-2,2), (w,-2,2))
testpoints=[(1,1), (2,2), (1,-1), (2,-2), (-1,-1), (-2,-2),(-1,1),(-2,2)]
#Vector Field with Trajecotries and Equilibirum point(0,0). Subthreshold t=srange(0, 1000, 0.1) vf=plot_vector_field((Vprime(V),Wprime(w)),(V,-2,2),(w,-2,2))+ point([0,0], color="blue", size=40) for i in srange (0,len(testpoints),1): sol=desolve_odeint([f(V)-w+0.1,0.01*(V-(0.5*w)) ], ics=testpoints[i], dvars=[V,w], times=t) p=list_plot(zip(sol[:,0], sol[:,1]), color="red", plotjoined=True)+vf show(p, ymin= -2, ymax=2, xmin=-2, xmax=2)
#redefining V prime for new test with changed Iext value Vprime2(V)=f(V)-w+0.208
#Vector Field with Trajecotries and Equilibirum point(0,0). Threshold t=srange(0, 1000, 0.1) vf=plot_vector_field((Vprime2(V),Wprime(w)),(V,-2,2),(w,-2,2))+ point([0,0], color="blue", size=40) for i in srange (0,len(testpoints),1): sol=desolve_odeint([f(V)-w+0.208,0.01*(V-(0.5*w)) ], ics=testpoints[i], dvars=[V,w], times=t) p=list_plot(zip(sol[:,0], sol[:,1]), color="red", plotjoined=True)+vf show(p, ymin= -2, ymax=2, xmin=-2, xmax=2)
#redefining V prime for new test with changed Iext value Vprime3(V)=f(V)-w+0.5
#Vector Field with Trajecotries and Equilibirum point(0,0). Supra-threshold t=srange(0, 1000, 0.1) vf=plot_vector_field((Vprime3(V),Wprime(w)),(V,-2,2),(w,-2,2))+ point([0,0], color="blue", size=40) for i in srange (0,len(testpoints),1): sol=desolve_odeint([f(V)-w+0.5,0.01*(V-(0.5*w)) ], ics=testpoints[i], dvars=[V,w], times=t) p=list_plot(zip(sol[:,0], sol[:,1]), color="red", plotjoined=True)+vf show(p, ymin= -2, ymax=2, xmin=-2, xmax=2)
#Sub-Threshold State Space Code t=srange(0,100,0.1) sol4=desolve_odeint((f(V)-w+0.1, 0.01*(V-(0.5*w))), ics=[0.1,0.1], dvars=[V,w], times=t) list_plot(sol4, axes_labels=["V", "w"]) plotjoined=True
#Threshold State Space Code t=srange(0,100,0.1) sol5=desolve_odeint((f(V)-w+0.208, 0.01*(V-(0.5*w))), ics=[0.1,0.1], dvars=[V,w], times=t) list_plot(sol5, axes_labels=["V", "w"]) plotjoined=True
#SupraThreshold State Space Code t=srange(0,100,0.1) sol6=desolve_odeint((f(V)-w+0.5, 0.01*(V-(0.5*w))), ics=[0.1,0.1], dvars=[V,w], times=t) list_plot(sol6, axes_labels=["V", "w"]) plotjoined=True
#sub-Threshold State Space Code with nullclines t=srange(0,100,0.1) sol4=desolve_odeint((f(V)-w+0.1, 0.01*(V-(0.5*w))), ics=[0.1,0.1], dvars=[V,w], times=t) list_plot(sol4, axes_labels=["V", "w"])+plot(2*V,color="red")+plot((1+V)+0.1,color="red")+plot(V-0.2+0.1,color="red") plotjoined=True
#Threshold State Space Code with nullclines t=srange(0,100,0.1) sol5=desolve_odeint((f(V)-w+0.208, 0.01*(V-(0.5*w))), ics=[0.1,0.1], dvars=[V,w], times=t) list_plot(sol5, axes_labels=["V", "w"])+plot(2*V,color="red")+plot((1+V)+0.1,color="red")+plot(V-0.2+0.1,color="red") plotjoined=True
#SupraThreshold State Space Code with nullclines t=srange(0,100,0.1) sol6=desolve_odeint((f(V)-w+0.5, 0.01*(V-(0.5*w))), ics=[0.1,0.1], dvars=[V,w], times=t) list_plot(sol6, axes_labels=["V", "w"])+ plot(2*V,color="red")+plot((1+V)+0.1,color="red")+plot(V-0.2+0.1,color="red") plotjoined=True