.. 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 Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_twoneurons.py: Two neuron example ------------------ 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:: default import nest import nest.voltage_trace import matplotlib.pyplot as plt 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:: default 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:: default 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:: default 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:: default 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:: default nest.voltage_trace.from_device(voltmeter) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_twoneurons.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: twoneurons.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: twoneurons.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_