with(plots):
plotsetup(gif);

#Flow rate model
V0:=0;Qin:=1; Vb:=V0+Qin*t;
gstretch:=gsyn*sig(Vb);
sig:=t->1/(1+exp(0.01*(-t+500)));

a := .3; b := .08; c := -0.3; d:=-1/5.5;
gsyn := -0.6; vsyn := 1/2;

solve({-ve+Heaviside(ve-a)-we, b*(ve+d-c*we)}): assign(%);
IC1 := v(0) =ve, w(0) =we;


A1 :=plot(1/c*(v+d), v = -2 .. 2, color = blue,thickness=1): A:=display(A1):
#BB1 :=plot(-v+Heaviside(v-a), v = -2 .. 2.1, color = red):
#BB1  :=plot(-v+Heaviside(v-a)-gsyn*(v-vsyn), v = -2 .. 2.1, color = red):

animate(
        plot, [-v+Heaviside(v-a)-gstretch*(v-vsyn),v=-2..2,
		view=[-2..2,-0.7..0.7],axes=BOXED,thickness=1],
        t=0..1000,frames=100,background=A);
