Skip to content

Instantly share code, notes, and snippets.

@mstimberg
Created February 14, 2023 10:09
Show Gist options
  • Save mstimberg/01cadfbac3bec4a7b28d1a25fe75ae31 to your computer and use it in GitHub Desktop.
Save mstimberg/01cadfbac3bec4a7b28d1a25fe75ae31 to your computer and use it in GitHub Desktop.
from brian2 import *
# import brian2cuda
set_device('cpp_standalone', directory='layers_openmp')
prefs.devices.cpp_standalone.openmp_threads = 4
group1 = NeuronGroup(100, 'dv/dt = 100*Hz : 1', threshold='v>1', reset='v=0')
group1.v = 'rand()'
group2 = NeuronGroup(100, '''dv/dt = -v/tau : 1
tau : second ''', threshold='v>1', reset='v=0')
group2.tau = 10*ms
synapses = Synapses(group1, group2, 'w: 1', on_pre='v_post += w')
synapses.connect(p=0.2)
synapses.w = 'rand()*.1'
synapses.delay = 'rand()*2*ms'
mon1 = SpikeMonitor(group1)
mon2 = SpikeMonitor(group2)
run(100*ms)
fig, ax = plt.subplots(2, 1, sharex=True)
ax[0].plot(mon1.t/ms, mon1.i, '.')
ax[1].plot(mon2.t/ms, mon2.i, '.', color='C1')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment