NEST main@caf0ae8
 
Loading...
Searching...
No Matches
iaf_cond_exp.h
Go to the documentation of this file.
1/*
2 * iaf_cond_exp.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef IAF_COND_EXP_H
24#define IAF_COND_EXP_H
25
26// Generated includes:
27#include "config.h"
28
29#ifdef HAVE_GSL
30
31// External includes:
32#include <gsl/gsl_errno.h>
33#include <gsl/gsl_matrix.h>
34#include <gsl/gsl_odeiv.h>
35
36// Includes from nestkernel:
37#include "archiving_node.h"
38#include "connection.h"
39#include "event.h"
40#include "nest_types.h"
41#include "recordables_map.h"
42#include "ring_buffer.h"
44
45namespace nest
46{
57extern "C" int iaf_cond_exp_dynamics( double, const double*, double*, void* );
58
59// clang-format off
60/* BeginUserDocs: neuron, integrate-and-fire, conductance-based, hard threshold
61
62Short description
63+++++++++++++++++
64
65Leaky integrate-and-fire neuron model with exponentially-shaped synaptic conductances
66
67
68Description
69+++++++++++
70
71``iaf_cond_exp`` is a leaky integrate-and-fire neuron model with
72
73* a hard threshold,
74* a fixed refractory period,
75* no adaptation mechanisms,
76* exponentially-shaped synaptic conductances according to :footcite:p:`Meffin2004`, normalized such that an event of weight 1.0 results in a peak conductance of 1 nS.
77
78Membrane potential evolution, spike emission, and refractoriness
79................................................................
80
81The membrane potential evolves according to
82
83.. math::
84
85 \frac{dV_\text{m}}{dt} = \frac{ -g_{\text{L}} (V_{\text{m}} - E_{\text{L}}) - I_{\text{syn}} + I_\text{e} } {C_{\text{m}}}
86
87where the synaptic input current :math:`I_{\text{syn}}(t)` is discussed below and :math:`I_\text{e}` is
88a constant input current set as a model parameter.
89
90A spike is emitted at time step :math:`t^*=t_{k+1}` if
91
92.. math::
93
94 V_\text{m}(t_k) < V_{th} \quad\text{and}\quad V_\text{m}(t_{k+1})\geq V_\text{th} \;.
95
96Subsequently,
97
98.. math::
99
100 V_\text{m}(t) = V_{\text{reset}} \quad\text{for}\quad t^* \leq t < t^* + t_{\text{ref}} \;,
101
102that is, the membrane potential is clamped to :math:`V_{\text{reset}}` during the refractory period.
103
104Synaptic input
105..............
106
107The synaptic input current has an excitatory and an inhibitory component
108
109.. math::
110
111 I_{\text{syn}}(t) = I_{\text{syn, ex}}(t) + I_{\text{syn, in}}(t)
112
113where
114
115.. math::
116
117 I_{\text{syn, X}}(t) = (V_{\text{m}}(t) - E_{\text{syn, X}}) \sum_{j} \sum_k g_{\text{j, X}}(t-t_j^k-d_j) \;,
118
119where :math:`j` indexes either excitatory (:math:`\text{X} = \text{ex}`)
120or inhibitory (:math:`\text{X} = \text{in}`) presynaptic neurons,
121:math:`k` indexes the spike times of neuron :math:`j`, and :math:`d_j`
122is the delay from neuron :math:`j`.
123
124The individual synaptic conductances are given by
125
126.. math::
127
128 g_{\text{j, X}}(t) = w_{\text{j}} \cdot e^{-\frac{t}{\tau_{\text{syn, X}}}} \Theta(t)
129
130where :math:`\Theta(x)` is the Heaviside step function. The conductances are normalized to unit maximum, that is,
131
132.. math::
133
134 g_{\text{j, X}}(t= 0) = w_{\text{j}} \;,
135
136where :math:`w` is a weight (excitatory if :math:`w > 0` or inhibitory if :math:`w < 0`).
137
138Parameters
139++++++++++
140
141=============== ================== =============================== ========================================================================
142**Parameter** **Default** **Math equivalent** **Description**
143=============== ================== =============================== ========================================================================
144``E_L`` -70 mV :math:`E_\text{L}` Leak reversal potential
145``C_m`` 250 pF :math:`C_{\text{m}}` Capacity of the membrane
146``t_ref`` 2 ms :math:`t_{\text{ref}}` Duration of refractory period
147``V_th`` -55 mV :math:`V_{\text{th}}` Spike threshold
148``V_reset`` -70 mV :math:`V_{\text{reset}}` Reset potential of the membrane
149``E_ex`` 0 mV :math:`E_\text{ex}` Excitatory reversal potential
150``E_in`` -85 mV :math:`E_\text{in}` Inhibitory reversal potential
151``g_L`` -16.6667 nS :math:`g_\text{L}` Leak conductance
152``tau_syn_ex`` 0.2 ms :math:`\tau_{\text{syn, ex}}` Exponential decay time constant of excitatory synaptic conductance kernel
153``tau_syn_in`` 2.0 ms :math:`\tau_{\text{syn, in}}` Exponential decay time constant of inhibitory synaptic conductance kernel
154``I_e`` 0 pA :math:`I_\text{e}` Constant input current
155=============== ================== =============================== ========================================================================
156
157The following state variables evolve during simulation and are available either as neuron properties or as recordables.
158
159================== ================= ========================== =================================
160**State variable** **Initial value** **Math equivalent** **Description**
161================== ================= ========================== =================================
162``V_m`` -70 mV :math:`V_{\text{m}}` Membrane potential
163``g_ex`` 0 nS :math:`g_{\text{ex}}` Excitatory synaptic conductance
164``g_in`` 0 nS :math:`g_{\text{in}}` Inhibitory synaptic conductance
165================== ================= ========================== =================================
166
167Sends
168+++++
169
170SpikeEvent
171
172Receives
173++++++++
174
175SpikeEvent, CurrentEvent, DataLoggingRequest
176
177References
178++++++++++
179
180.. footbibliography::
181
182See also
183++++++++
184
185iaf_psc_delta, iaf_psc_alpha, iaf_psc_exp, iaf_cond_alpha, iaf_cond_beta
186
187Examples using this model
188+++++++++++++++++++++++++
189
190.. listexamples:: iaf_cond_exp
191
192EndUserDocs*/
193// clang-format on
194
195void register_iaf_cond_exp( const std::string& name );
196
197class iaf_cond_exp : public ArchivingNode
198{
199
200public:
201 iaf_cond_exp();
202 iaf_cond_exp( const iaf_cond_exp& );
203 ~iaf_cond_exp() override;
204
210 using Node::handle;
211 using Node::handles_test_event;
212
213 size_t send_test_event( Node&, size_t, synindex, bool ) override;
214
215 void handle( SpikeEvent& ) override;
216 void handle( CurrentEvent& ) override;
217 void handle( DataLoggingRequest& ) override;
218
219 size_t handles_test_event( SpikeEvent&, size_t ) override;
220 size_t handles_test_event( CurrentEvent&, size_t ) override;
221 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
222
223 void get_status( Dictionary& ) const override;
224 void set_status( const Dictionary& ) override;
225
226private:
227 void init_buffers_() override;
228 void pre_run_hook() override;
229 void update( Time const&, const long, const long ) override;
230
231 // END Boilerplate function declarations ----------------------------
232
233 // Friends --------------------------------------------------------
234
235 // make dynamics function quasi-member
236 friend int iaf_cond_exp_dynamics( double, const double*, double*, void* );
237
238 // The next two classes need to be friends to access the State_ class/member
239 friend class RecordablesMap< iaf_cond_exp >;
240 friend class UniversalDataLogger< iaf_cond_exp >;
241
242private:
243 // ----------------------------------------------------------------
244
246 struct Parameters_
247 {
248 double V_th_;
249 double V_reset_;
250 double t_ref_;
251 double g_L;
252 double C_m;
253 double E_ex;
254 double E_in;
255 double E_L;
256 double tau_synE;
257 double tau_synI;
258 double I_e;
259
260 Parameters_();
261
262 void get( Dictionary& ) const;
263 void set( const Dictionary&, Node* node );
264 };
265
266public:
267 // ----------------------------------------------------------------
268
273 struct State_
274 {
276 enum StateVecElems
277 {
278 V_M = 0,
279 G_EXC,
280 G_INH,
281 STATE_VEC_SIZE
282 };
283
285 double y_[ STATE_VEC_SIZE ];
286 int r_;
287
288 State_( const Parameters_& );
289 State_( const State_& );
290
291 State_& operator=( const State_& );
292
293 void get( Dictionary& ) const;
294 void set( const Dictionary&, const Parameters_&, Node* );
295 };
296
297 // ----------------------------------------------------------------
298
299private:
303 struct Buffers_
304 {
305 Buffers_( iaf_cond_exp& );
306 Buffers_( const Buffers_&, iaf_cond_exp& );
307
309 UniversalDataLogger< iaf_cond_exp > logger_;
310
312 RingBuffer spike_exc_;
313 RingBuffer spike_inh_;
314 RingBuffer currents_;
315
317 gsl_odeiv_step* s_;
318 gsl_odeiv_control* c_;
319 gsl_odeiv_evolve* e_;
320 gsl_odeiv_system sys_;
321
322 // Since IntegrationStep_ is initialized with step_, and the resolution
323 // cannot change after nodes have been created, it is safe to place both
324 // here.
325 double step_;
326 double IntegrationStep_;
327
335 double I_stim_;
336 };
337
338 // ----------------------------------------------------------------
339
343 struct Variables_
344 {
345 int RefractoryCounts_;
346 };
347
348 // Access functions for UniversalDataLogger -------------------------------
349
351 template < State_::StateVecElems elem >
352 double
353 get_y_elem_() const
354 {
355 return S_.y_[ elem ];
356 }
357
358 // ----------------------------------------------------------------
359
360 Parameters_ P_;
361 State_ S_;
362 Variables_ V_;
363 Buffers_ B_;
364
366 static RecordablesMap< iaf_cond_exp > recordablesMap_;
367};
368
369
370inline size_t
371iaf_cond_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
372{
373 SpikeEvent e;
374 e.set_sender( *this );
375 return target.handles_test_event( e, receptor_type );
376}
377
378inline size_t
379iaf_cond_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
380{
381 if ( receptor_type != 0 )
382 {
383 throw UnknownReceptorType( receptor_type, get_name() );
384 }
385 return 0;
386}
387
388inline size_t
389iaf_cond_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
390{
391 if ( receptor_type != 0 )
392 {
393 throw UnknownReceptorType( receptor_type, get_name() );
394 }
395 return 0;
396}
397
398inline size_t
399iaf_cond_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
400{
401 if ( receptor_type != 0 )
402 {
403 throw UnknownReceptorType( receptor_type, get_name() );
404 }
405 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
406}
407
408
409inline void
410iaf_cond_exp::get_status( Dictionary& d ) const
411{
412 P_.get( d );
413 S_.get( d );
415
416 d[ names::recordables ] = recordablesMap_.get_list();
417}
418
419inline void
420iaf_cond_exp::set_status( const Dictionary& d )
421{
422 Parameters_ ptmp = P_; // temporary copy in case of errors
423 ptmp.set( d, this ); // throws if BadProperty
424 State_ stmp = S_; // temporary copy in case of errors
425 stmp.set( d, ptmp, this ); // throws if BadProperty
426
427 // We now know that (ptmp, stmp) are consistent. We do not
428 // write them back to (P_, S_) before we are also sure that
429 // the properties to be set in the parent class are internally
430 // consistent.
432
433 // if we get here, temporaries contain consistent set of properties
434 P_ = ptmp;
435 S_ = stmp;
436}
437
438} // namespace
439
440#endif // HAVE_GSL
441#endif // IAF_COND_EXP_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:220
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:236
const std::string E_L("E_L")
const std::string I_e("I_e")
const std::string recordables("recordables")
const std::string C_m("C_m")
const std::string d("d")
const std::string E_in("E_in")
const std::string target("target")
const std::string E_ex("E_ex")
const std::string g_L("g_L")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
const double e
Definition numerics.cpp:32