.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/run_microcircuit.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_run_microcircuit.py: Microcircuit example (Potjans & Diesmann 2014) ---------------------------------------------- Example illustrating usage of the `microcircuit` python package. .. GENERATED FROM PYTHON SOURCE LINES 32-44 .. code-block:: Python import time import nest import numpy as np ## import model implementation from microcircuit import network ## import (default) parameters (network, simulation, stimulus) from microcircuit.network_params import default_net_dict as net_dict from microcircuit.sim_params import default_sim_dict as sim_dict from microcircuit.stimulus_params import default_stim_dict as stim_dict .. GENERATED FROM PYTHON SOURCE LINES 45-118 .. code-block:: Python ## set network scale scaling_factor = 0.2 net_dict["N_scaling"] = scaling_factor net_dict["K_scaling"] = scaling_factor ## set path for storing spike data and figures sim_dict['data_path'] = 'data_scale_%.2f/' % scaling_factor def main(): ## start timer time_start = time.time() ## create instance of the network net = network.Network(sim_dict, net_dict, stim_dict) time_network = time.time() ## create all nodes (neurons, devices) net.create() time_create = time.time() ## connect nework net.connect() time_connect = time.time() ## pre-simulation (warm-up phase) net.simulate(sim_dict["t_presim"]) time_presimulate = time.time() ## simulation net.simulate(sim_dict["t_sim"]) time_simulate = time.time() ## store metadata net.store_metadata() ## current memory consumption of the python process (in MB) import psutil mem = psutil.Process().memory_info().rss / (1024 * 1024) ##################### ## plot spikes and firing rate distribution print() print('##########################################') print() observation_interval = np.array([sim_dict["t_presim"], sim_dict["t_presim"] + sim_dict["t_sim"]]) net.evaluate(observation_interval , observation_interval ) print() print('Raster plot : see %s ' % (sim_dict['data_path'] + 'raster_plot.png') ) print('Distributions of firing rates: see %s ' % (sim_dict['data_path'] + 'box_plot.png' ) ) time_evaluate = time.time() ##################### ## print timers and memory consumption print() print('##########################################') print() print('Times of Rank %d:' % nest.Rank()) print(' Total time:') print(' Time to initialize : %.3fs' % (time_network - time_start)) print(' Time to create : %.3fs' % (time_create - time_network)) print(' Time to connect : %.3fs' % (time_connect - time_create)) print(' Time to presimulate : %.3fs' % (time_presimulate - time_connect)) print(' Time to simulate : %.3fs' % (time_simulate - time_presimulate)) print(' Time to evaluate : %.3fs' % (time_evaluate - time_simulate)) print() print("Memory consumption: %dMB" % mem) print() print('##########################################') print() .. GENERATED FROM PYTHON SOURCE LINES 119-122 .. code-block:: Python if __name__== '__main__': main() .. _sphx_glr_download_auto_examples_run_microcircuit.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_microcircuit.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_microcircuit.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: run_microcircuit.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_