.. currentmodule:: brian2 .. cuba_openmp: Example: cuba_openmp ==================== .. only:: html .. |launchbinder| image:: http://mybinder.org/badge.svg .. _launchbinder: https://mybinder.org/v2/gh/brian-team/brian2-binder/master?filepath=examples/standalone/cuba_openmp.ipynb .. note:: You can launch an interactive, editable version of this example without installing any local files using the Binder service (although note that at some times this may be slow or fail to open): |launchbinder|_ Run the ``cuba.py`` example with OpenMP threads. :: from brian2 import * set_device('cpp_standalone', directory='CUBA') prefs.devices.cpp_standalone.openmp_threads = 4 taum = 20*ms taue = 5*ms taui = 10*ms Vt = -50*mV Vr = -60*mV El = -49*mV eqs = ''' dv/dt = (ge+gi-(v-El))/taum : volt (unless refractory) dge/dt = -ge/taue : volt (unless refractory) dgi/dt = -gi/taui : volt (unless refractory) ''' P = NeuronGroup(4000, eqs, threshold='v>Vt', reset='v = Vr', refractory=5*ms, method='exact') P.v = 'Vr + rand() * (Vt - Vr)' P.ge = 0*mV P.gi = 0*mV we = (60*0.27/10)*mV # excitatory synaptic weight (voltage) wi = (-20*4.5/10)*mV # inhibitory synaptic weight Ce = Synapses(P, P, on_pre='ge += we') Ci = Synapses(P, P, on_pre='gi += wi') Ce.connect('i<3200', p=0.02) Ci.connect('i>=3200', p=0.02) s_mon = SpikeMonitor(P) run(1 * second) plot(s_mon.t/ms, s_mon.i, ',k') xlabel('Time (ms)') ylabel('Neuron index') show() .. image:: ../resources/examples_images/standalone.cuba_openmp.1.png