import numpy as np
import matplotlib.pyplot as plt
import sim_ballena as ballena

neu = [ ballena.Lif().v_reset(-70).v_thres(-40).t_refractory(1).tau(5),
        ballena.Lif().v_reset(-75).v_thres(-45).t_refractory(3).tau(5),
        ballena.Lif().v_reset(-80).v_thres(-50).t_refractory(5).tau(5)]
net = ( ballena.Network(neu)
       .synapses_in( [(0,0),(0,1),(0,2)] )
       .synapses_net([])
    	.weights([3]*3)
       .outputs([0,1,2])
       .mode(['VOLTAGES']) )

times = np.linspace(0,10,25)
instance = ballena.Instance( [(t,0) for t in times] )
res      = net.simulate( instance, 10 )

t = res.time()
v = res.v_trace()

for idx in range(3):
    plt.plot( t, v[idx], label=f'neu {idx}' )
plt.show()