"""Prep the Simulation"""
# Set simulation parameters
dt = 0.01
t_max = 50
# Initialize a vector of timesteps
t = np.arange(0, t_max, dt)
# Initialize vectors which store the input to our network, and for data to be written to during simulation from outputs
inputs = np.zeros([len(t),4])+20.0 # Input vector must be 2d, even if second dimension is 1
data = np.zeros([len(t),net.get_num_outputs_actual()])
# Compile the network to use the Numpy CPU backend (if you want to see what's happening, set debug to true)
model = net.compile(backend='numpy', dt=dt, debug=False)
"""Simulate the network"""
# At every step, apply the current input to a forward pass of the network and store the results in 'data'
for i in range(len(t)):
data[i,:] = model.forward(inputs[i,:])
data = data.transpose()
"""Plot the data"""
plt.figure()
plt.subplot(2,2,1)
plt.plot(t,data[:][0],label='0',color='C0')
plt.plot(t,data[:][1],label='1',color='C1')
plt.xlabel('t (ms)')
plt.ylabel('U (mV)')
plt.title('Non-spiking Chemical Synapse')
plt.legend()
plt.subplot(2,2,2)
plt.plot(t,data[:][2],label='2',color='C2')
plt.plot(t,data[:][3],label='3',color='C3')
plt.xlabel('t (ms)')
plt.ylabel('U (mV)')
plt.title('Electrical Synapse')
plt.legend()
plt.subplot(2,2,3)
plt.plot(t,data[:][4],label='4',color='C4')
plt.plot(t,data[:][5],label='5',color='C5')
plt.xlabel('t (ms)')
plt.ylabel('U (mV)')
plt.title('Rectified Electrical Synapse (Forward)')
plt.legend()
plt.subplot(2,2,4)
plt.plot(t,data[:][6],label='6',color='C6')
plt.plot(t,data[:][7],label='7',color='C7')
plt.xlabel('t (ms)')
plt.ylabel('U (mV)')
plt.title('Rectified Electrical Synapse (Backward)')
plt.legend()