Simulation module

Functions for simulation control

nest.lib.hl_api_simulation.Cleanup()

Cleans up resources after a Run calls.

Cleanup is automatically called by Simulate and RunManager.

Closes state for a series of runs, such as flushing and closing files. A Prepare is needed after a Cleanup before any more calls to Run.

nest.lib.hl_api_simulation.DisableStructuralPlasticity()

Disable structural plasticity for the network simulation

nest.lib.hl_api_simulation.EnableStructuralPlasticity()

Enable structural plasticity for the network simulation

nest.lib.hl_api_simulation.GetKernelStatus(keys=None)

Obtain parameters of the simulation kernel.

Parameters:

keys (str or list, optional) – Single parameter name or list of parameter names

Returns:

  • dict – Parameter dictionary, if called without argument

  • type – Single parameter value, if called with single parameter name

  • list – List of parameter values, if called with list of parameter names

Raises:

TypeError – If keys are of the wrong type.

Notes

See SetKernelStatus for documentation on each parameter key.

See also

SetKernelStatus

nest.lib.hl_api_simulation.Install(module_name)

Load a dynamically linked NEST module.

Parameters:

module_name (str) – Name of the dynamically linked module

Returns:

NEST module identifier, required for unloading

Return type:

handle

Notes

Dynamically linked modules are searched in the NEST library directory (<prefix>/lib/nest) and in LD_LIBRARY_PATH (on Linux) or DYLD_LIBRARY_PATH (on OSX).

Example

nest.Install("mymodule")
nest.lib.hl_api_simulation.Prepare()

Calibrate the system before a Run call.

Prepare is automatically called by Simulate and RunManager.

Call before the first Run call, or before calling Run after changing the system, calling SetStatus or Cleanup.

nest.lib.hl_api_simulation.ResetKernel()

Reset the simulation kernel.

This will destroy the network as well as all custom models created with CopyModel(). Calling this function is equivalent to restarting NEST.

In particular,

  • all network nodes

  • all connections

  • all user-defined neuron and synapse models

are deleted, and

  • time

  • random generators

are reset. All dynamically loaded modules (via Install()) are unloaded.

nest.lib.hl_api_simulation.Run(t)

Simulate the network for t milliseconds.

Parameters:

t (float) – Time to simulate in ms

Notes

Call between Prepare and Cleanup calls, or within a with RunManager clause. Run(t) is called once by each call to Simulate(t).

Prepare must be called before Run to calibrate the system, and Cleanup must be called after Run to close files, cleanup handles, and so on. After Cleanup, Prepare can and must be called before more Run calls.

Be careful about modifying the network or neurons between Prepare and Cleanup calls. In particular, do not call Create, Connect, or SetKernelStatus. Calling SetStatus to change membrane potential V_m of neurons or synaptic weights (but not delays!) will in most cases work as expected, while changing membrane or synaptic times constants will not work correctly. If in doubt, assume that changes may cause undefined behavior and check these thoroughly.

Also note that local_spike_counter is reset each time you call Run.

nest.lib.hl_api_simulation.RunManager()

ContextManager for Run

Calls Prepare before a series of Run calls, and calls Cleanup at end.

For example:

with RunManager():
    for _ in range(10):
        Run(100)
        # extract results

Notes

Be careful about modifying the network or neurons inside the RunManager context. In particular, do not call Create, Connect, or SetKernelStatus. Calling SetStatus to change membrane potential V_m of neurons or synaptic weights (but not delays!) will in most cases work as expected, while changing membrane or synaptic times constants will not work correctly. If in doubt, assume that changes may cause undefined behavior and check these thoroughly.

See also

Prepare, Run, Cleanup, Simulate

nest.lib.hl_api_simulation.SetKernelStatus(params)

Set parameters for the simulation kernel.

See the documentation of Kernel attributes (nest.NestModule) for a valid list of params.

Parameters:

params (dict) – Dictionary of parameters to set.

See also

GetKernelStatus

nest.lib.hl_api_simulation.Simulate(t)

Simulate the network for t milliseconds.

Simulate(t) runs Prepare(), Run(t), and Cleanup() in this order.

Parameters:

t (float) – Time to simulate in ms