.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/twoneurons.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_twoneurons.py: Two neuron example ------------------ .. only:: html ---- Run this example as a Jupyter notebook: .. card:: :width: 25% :margin: 2 :text-align: center :link: https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fnest%2Fnest-simulator-examples&urlpath=lab%2Ftree%2Fnest-simulator-examples%2Fnotebooks%2Fnotebooks%2Ftwoneurons.ipynb&branch=main :link-alt: JupyterHub service .. image:: https://nest-simulator.org/TryItOnEBRAINS.png .. grid:: 1 1 1 1 :padding: 0 0 2 0 .. grid-item:: :class: sd-text-muted :margin: 0 0 3 0 :padding: 0 0 3 0 :columns: 4 See :ref:`our guide ` for more information and troubleshooting. ---- This script simulates two connected pre- and postsynaptic neurons. The presynaptic neuron receives a constant external current, and the membrane potential of both neurons are recorded. See Also ~~~~~~~~ :doc:`one_neuron` .. GENERATED FROM PYTHON SOURCE LINES 38-41 First, we import all necessary modules for simulation, analysis and plotting. Additionally, we set the verbosity to suppress info messages and reset the kernel. .. GENERATED FROM PYTHON SOURCE LINES 41-49 .. code-block:: Python import matplotlib.pyplot as plt import nest import nest.voltage_trace nest.set_verbosity("M_WARNING") nest.ResetKernel() .. GENERATED FROM PYTHON SOURCE LINES 50-51 Second, we create the two neurons and the recording device. .. GENERATED FROM PYTHON SOURCE LINES 51-56 .. code-block:: Python neuron_1 = nest.Create("iaf_psc_alpha") neuron_2 = nest.Create("iaf_psc_alpha") voltmeter = nest.Create("voltmeter") .. GENERATED FROM PYTHON SOURCE LINES 57-58 Third, we set the external current of neuron 1. .. GENERATED FROM PYTHON SOURCE LINES 58-61 .. code-block:: Python neuron_1.I_e = 376.0 .. GENERATED FROM PYTHON SOURCE LINES 62-66 Fourth, we connect neuron 1 to neuron 2. Then, we connect a voltmeter to the two neurons. To learn more about the previous steps, please check out the :doc:`one neuron example `. .. GENERATED FROM PYTHON SOURCE LINES 66-74 .. code-block:: Python weight = 20.0 delay = 1.0 nest.Connect(neuron_1, neuron_2, syn_spec={"weight": weight, "delay": delay}) nest.Connect(voltmeter, neuron_1) nest.Connect(voltmeter, neuron_2) .. GENERATED FROM PYTHON SOURCE LINES 75-77 Now we simulate the network using ``Simulate``, which takes the desired simulation time in milliseconds. .. GENERATED FROM PYTHON SOURCE LINES 77-80 .. code-block:: Python nest.Simulate(1000.0) .. GENERATED FROM PYTHON SOURCE LINES 81-83 Finally, we plot the neurons' membrane potential as a function of time. .. GENERATED FROM PYTHON SOURCE LINES 83-86 .. code-block:: Python nest.voltage_trace.from_device(voltmeter) plt.show() .. _sphx_glr_download_auto_examples_twoneurons.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: twoneurons.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: twoneurons.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_