Issues while runing model

Description of problem

While i was executing the below code
start_scope()

tau = 10ms
eqs = ‘’’
dv/dt = (sin(2
pi100Hz*t)-v)/tau : 1
‘’’

Change to Euler method because exact integrator doesn’t work here

G = NeuronGroup(1, eqs, method=‘euler’)
M = StateMonitor(G, ‘v’, record=0)

G.v = 5 # initial value

run(60*ms)

plot(M.t/ms, M.v[0])
xlabel(‘Time (ms)’)
ylabel(‘v’);

BELOW IS THE ERROR

NotImplementedError Traceback (most recent call last)
Cell In[8], line 14
10 M = StateMonitor(G, ‘v’, record=0)
12 G.v = 5 # initial value
—> 14 run(60*ms)
16 plot(M.t/ms, M.v[0])
17 xlabel(‘Time (ms)’)

File ~.conda\envs\gsoc\Lib\site-packages\brian2\units\fundamentalunits.py:2780, in check_units..do_check_units..new_f(*args, **kwds)
2770 error_message = (
2771 f"Function ‘{f.name}’ "
2772 “expected a quantitity with unit "
2773 f”{unit} for argument ‘{k}’ but got "
2774 f"‘{value}’"
2775 )
2776 raise DimensionMismatchError(
2777 error_message, get_dimensions(newkeyset[k])
2778 )
→ 2780 result = f(*args, **kwds)
2781 if “result” in au:
2782 if isinstance(au[“result”], Callable) and au[“result”] != bool:

File ~.conda\envs\gsoc\Lib\site-packages\brian2\core\magic.py:407, in run(duration, report, report_period, namespace, profile, level)
334 @check_units(duration=second, report_period=second)
335 def run(
336 duration,
(…)
341 level=0,
342 ):
343 “”"
344 run(duration, report=None, report_period=10*second, namespace=None, level=0)
345
(…)
405 intended use. See MagicNetwork for more details.
406 “”"
→ 407 return magic_network.run(
408 duration,
409 report=report,
410 report_period=report_period,
411 namespace=namespace,
412 profile=profile,
413 level=2 + level,
414 )

File ~.conda\envs\gsoc\Lib\site-packages\brian2\core\magic.py:248, in MagicNetwork.run(self, duration, report, report_period, namespace, profile, level)
238 def run(
239 self,
240 duration,
(…)
245 level=0,
246 ):
247 self._update_magic_objects(level=level + 1)
→ 248 Network.run(
249 self,
250 duration,
251 report=report,
252 report_period=report_period,
253 namespace=namespace,
254 profile=profile,
255 level=level + 1,
256 )

File ~.conda\envs\gsoc\Lib\site-packages\brian2\core\base.py:333, in device_override..device_override_decorator..device_override_decorated_function(*args, **kwds)
331 curdev = get_device()
332 if hasattr(curdev, name):
→ 333 return getattr(curdev, name)(*args, **kwds)
334 else:
335 return func(*args, **kwds)

File ~.conda\envs\gsoc\Lib\site-packages\brian2tools\baseexport\device.py:221, in BaseExporter.network_run(self, network, duration, namespace, level, **kwds)
215 raise RuntimeError('The network has already been built ’
216 'and run before. Use set_device with ’
217 'build_on_run=False and an explicit ’
218 'device.build call to use multiple run ’
219 ‘statements with this device.’)
220 # call build
→ 221 self.build(direct_call=False, **self.build_options)

File ~.conda\envs\gsoc\Lib\site-packages\brian2tools\nmlexport\lemsexport.py:739, in LEMSDevice.build(self, filename, direct_call, lems_const_save)
737 # TODO: should be extended to multiple runs
738 if len(self.runs) > 1:
→ 739 raise NotImplementedError(“Currently only single run is supported.”)
740 # get filename without extension
741 if len(filename.split(“.”)) != 1:

NotImplementedError: Currently only single run is supported.

Minimal code to reproduce problem

What you have aready tried

Expected output (if relevant)

Actual output (if relevant)

Full traceback of error (if relevant)

Hi @sparsh-989. From the error message on the bottom, it seems that you ran set_device('neuroml2') earlier in the session (or notebook). This is implemented as a “standalone mode”, and this mode is mostly meant to run a single script (i.e. in its own session), not several simulations in a row. If you want to start a new simulation with the neuroml2 device, you’d have to call:

device.reinit()
device.activate()

first (see Computational methods and efficiency — Brian 2 2.5.4 documentation).

If you don’t want to generate NeuroML code in the first place (which seems to be indicated by the fact that you are plotting afterwards :blush: ), then you should instead switch back to the standard, “runtime”, device with:

set_device('runtime')

Hope that makes things clearer – please let me know if you still have questions!

Hi @mstimberg ,
thanks for the clear guidance

1 Like