# Theta neuron network with 50e and 20i cells with all-to-all
# connectivity and tonic input to both the e- and i-cells
#
# Parameters
par I_e=1, I_i=0
par gei=.4,gii=0.15,gee=0.1, gie=2
par tauz=50,gz=.2
par sige=0.5, sigi=.02
par taue=1, taui=3
#
#ODEs for e-cells, i-cells and adaptation
x[0..49]'=1-cos(x[j])+(1+cos(x[j]))*(I_e-gz*z[j]-gie*si+gee*se+sige*we[j])
z[0..49]'=sd(x[j])-z[j]/tauz
y[0..19]'=1-cos(y[j])+(1+cos(y[j]))*(I_i-gii*si+gei*se+sigi*wi[j])
# Synapses
se'=sum(0,49)of(sd(shift(x0,i')))/50-se/taue
si'=sum(0,19)of(sd(shift(y0,i')))/20-si/taui
global 1 x[0..49]-pi {x[j]=-pi}
global 1 y[0..19]-pi {y[j]=-pi}
#
# Initial Conditions
x[0..49](0)=ran(1)*2*pi-pi
y[0..19](0)=ran(1)*2*pi-pi
wiener we[0..49]
wiener wi[0..19]
sd(x)=exp(-b*(1-cos(x-2.5)))*b
par b=100
aux swgt=.8*se+.2*si
@ meth=euler,
@ total=1400,trans=400,maxstor=1000000
@ dt=0.02,nOut=10
@ xp=t,yp=se,xlo=600,xhi=1200,ylo=0,yhi=.5
done