The synaptic group attribute seems not being able to be modified when using run_args in standalone mode., although I don’t see the same behavior for neuron group. The following code demonstrate this issue. Is this a feature or can be bypassed?
from brian2 import *
set_device('cpp_standalone', build_on_run=False)
eqs = '''
dv/dt = (I-v)/tau : 1
I : 1
tau : second
'''
G = NeuronGroup(3, eqs, threshold='v>1', reset='v = 0', method='exact')
G.I = [2, 0, 0]
G.tau = [10, 100, 100]*ms
S = Synapses(G, G, 'w : 1', on_pre='v_post += w')
S.connect(i=0, j=[1, 2])
S.w = 'j*0.2'
S.delay = 'j*2*ms'
S.pre.delay = '3*ms'
M = StateMonitor(G, 'v', record=True)
run(10*ms) # will not call device.build/device.run
device.build(run=False) # Compile the code
# Do 10 runs without recompiling, each time initializing v differently
for idx in range(10):
device.run(run_args={G.v: np.arange(3)*0.01 + 0.1*idx})
print('1----: ', S.w[:])
S.w[:] = 0
print('2----: ', S.w[:])
I manually set S.w[:] = 0 but the value of the array remain unchanged.
1----: [0.2 0.4]
2----: [0.2 0.4]