NEST main@f146f75
Loading...
Searching...
No Matches
aeif_cond_exp.h
Go to the documentation of this file.
1/*
2 * aeif_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 AEIF_COND_EXP_H
24#define AEIF_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 aeif_cond_exp_dynamics( double, const double*, double*, void* );
58
69extern "C" int aeif_cond_exp_dynamics_DT0( double, const double*, double*, void* );
70
71/* BeginUserDocs: neuron, adaptation, integrate-and-fire, conductance-based, soft threshold
72
73Short description
74+++++++++++++++++
75
76Conductance based exponential integrate-and-fire neuron model
77
78Description
79+++++++++++
80
81``aeif_cond_exp`` is the adaptive exponential integrate and fire neuron
82according to Brette and Gerstner (2005), with postsynaptic
83conductances in the form of truncated exponentials.
84
85This implementation uses the embedded 4th order Runge-Kutta-Fehlberg
86solver with adaptive stepsize to integrate the differential equation.
87
88The membrane potential is given by the following differential equation:
89
90.. math::
91
92 C dV/dt= -g_L(V-E_L)+g_L \cdot \Delta_T \cdot \exp((V-V_T)/\Delta_T)-g_e(t)(V-E_e) \\
93 -g_i(t)(V-E_i)-w +I_e
94
95and
96
97.. math::
98
99 \tau_w \cdot dw/dt= a(V-E_L) -W
100
101Note that the spike detection threshold V_peak is automatically set to
102:math:`V_th+10 mV` to avoid numerical instabilities that may result from
103setting V_peak too high.
104
105For implementation details see the
106`aeif_models_implementation <../model_details/aeif_models_implementation.ipynb>`_ notebook.
107
108
109.. note::
110
111 The default refractory period for ``aeif`` models is zero, consistent with the model definition in
112 Brette & Gerstner :footcite:p:`Brette2005`. Thus, an ``aeif`` neuron with default parameters can fire multiple
113 spikes in a single time step, which can lead to exploding spike numbers and extreme slow-down of simulations.
114
115 To avoid such unphysiological behavior, you should set a refractory time ``t_ref > 0``.
116
117
118.. note::
119
120 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
121 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
122 the inhibitory one. Only the absolute value of the weight sets the conductance
123 amplitude. Spike connections must use the default ``receptor_type`` of 0.
124
125 See :ref:`synapse_selection` for the conventions used by other models.
126
127Parameters
128++++++++++
129The following parameters can be set in the status Dictionary.
130
131======== ======= =======================================
132**Dynamic state variables:**
133--------------------------------------------------------
134 V_m mV Membrane potential
135 g_ex nS Excitatory synaptic conductance
136 g_in nS Inhibitory synaptic conductance
137 w pA Spike-adaptation current
138======== ======= =======================================
139
140======== ======= =======================================
141**Membrane Parameters**
142--------------------------------------------------------
143 C_m pF Capacity of the membrane
144 t_ref ms Duration of refractory period
145 V_reset mV Reset value for V_m after a spike
146 E_L mV Leak reversal potential
147 g_L nS Leak conductance
148 I_e pA Constant external input current
149======== ======= =======================================
150
151======== ======= ==================================
152**Spike adaptation parameters**
153---------------------------------------------------
154 a nS Subthreshold adaptation
155 b pA Spike-triggered adaptation
156 Delta_T mV Slope factor
157 tau_w ms Adaptation time constant
158 V_th mV Spike initiation threshold
159 V_peak mV Spike detection threshold
160======== ======= ==================================
161
162=========== ======= ===========================================================
163**Synaptic parameters**
164-------------------------------------------------------------------------------
165 E_ex mV Excitatory reversal potential
166 tau_syn_ex ms Exponential decay time constant of excitatory synaptic
167 conductance kernel
168 E_in mV Inhibitory reversal potential
169 tau_syn_in ms Exponential decay time constant of inhibitory synaptic
170 conductance kernel
171=========== ======= ===========================================================
172
173============= ======= =========================================================
174**Integration parameters**
175-------------------------------------------------------------------------------
176gsl_error_tol real This parameter controls the admissible error of the
177 GSL integrator. Reduce it if NEST complains about
178 numerical instabilities.
179============= ======= =========================================================
180
181Sends
182+++++
183
184SpikeEvent
185
186Receives
187++++++++
188
189SpikeEvent, CurrentEvent, DataLoggingRequest
190
191References
192++++++++++
193
194.. footbibliography::
195
196See also
197++++++++
198
199iaf_cond_exp, aeif_cond_alpha
200
201Examples using this model
202+++++++++++++++++++++++++
203
204.. listexamples:: aeif_cond_exp
205
206EndUserDocs */
207
208void register_aeif_cond_exp( const std::string& name );
209
210class aeif_cond_exp : public ArchivingNode
211{
212
213public:
214 aeif_cond_exp();
215 aeif_cond_exp( const aeif_cond_exp& );
216 ~aeif_cond_exp() override;
217
223 using Node::handle;
224 using Node::handles_test_event;
225
226 size_t send_test_event( Node&, size_t, synindex, bool ) override;
227
228 void handle( SpikeEvent& ) override;
229 void handle( CurrentEvent& ) override;
230 void handle( DataLoggingRequest& ) override;
231
232 size_t handles_test_event( SpikeEvent&, size_t ) override;
233 size_t handles_test_event( CurrentEvent&, size_t ) override;
234 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
235
236 void get_status( Dictionary& ) const override;
237 void set_status( const Dictionary& ) override;
238
239private:
240 void init_buffers_() override;
241 void pre_run_hook() override;
242 void update( const Time&, const long, const long ) override;
243
244 // END Boilerplate function declarations ----------------------------
245
246 // Friends --------------------------------------------------------
247
248 // make dynamics function quasi-member
249 friend int aeif_cond_exp_dynamics( double, const double*, double*, void* );
250
251 // The next two classes need to be friends to access the State_ class/member
252 friend class RecordablesMap< aeif_cond_exp >;
253 friend class UniversalDataLogger< aeif_cond_exp >;
254
255private:
256 // ----------------------------------------------------------------
257
259 struct Parameters_
260 {
261 double V_peak_;
262 double V_reset_;
263 double t_ref_;
264
265 double g_L;
266 double C_m;
267 double E_ex;
268 double E_in;
269 double E_L;
270 double Delta_T;
271 double tau_w;
272 double a;
273 double b;
274 double V_th;
275 double tau_syn_ex;
276 double tau_syn_in;
277 double I_e;
278
279 double gsl_error_tol;
280
281 Parameters_();
282
283 void get( Dictionary& ) const;
284 void set( const Dictionary&, Node* node );
285 };
286
287public:
288 // ----------------------------------------------------------------
289
294 struct State_
295 {
302 enum StateVecElems
303 {
304 V_M = 0,
305 G_EXC, // 1
306 G_INH, // 2
307 W, // 3
308 STATE_VEC_SIZE
309 };
310
312 double y_[ STATE_VEC_SIZE ];
313 unsigned int r_;
314
315 State_( const Parameters_& );
316 State_( const State_& );
317
318 State_& operator=( const State_& );
319
320 void get( Dictionary& ) const;
321 void set( const Dictionary&, const Parameters_&, Node* );
322 };
323
324 // ----------------------------------------------------------------
325
329 struct Buffers_
330 {
331 Buffers_( aeif_cond_exp& );
332 Buffers_( const Buffers_&, aeif_cond_exp& );
333
335 UniversalDataLogger< aeif_cond_exp > logger_;
336
338 RingBuffer spike_exc_;
339 RingBuffer spike_inh_;
340 RingBuffer currents_;
341
343 gsl_odeiv_step* s_;
344 gsl_odeiv_control* c_;
345 gsl_odeiv_evolve* e_;
346 gsl_odeiv_system sys_;
347
348 // Since IntegrationStep_ is initialized with step_, and the resolution
349 // cannot change after nodes have been created, it is safe to place both
350 // here.
351 double step_;
352 double IntegrationStep_;
353
361 double I_stim_;
362 };
363
364 // ----------------------------------------------------------------
365
369 struct Variables_
370 {
375 double V_peak;
376
377 unsigned int refractory_counts_;
378 };
379
380 // Access functions for UniversalDataLogger -------------------------------
381
383 template < State_::StateVecElems elem >
384 double
385 get_y_elem_() const
386 {
387 return S_.y_[ elem ];
388 }
389
390 // ----------------------------------------------------------------
391
392 Parameters_ P_;
393 State_ S_;
394 Variables_ V_;
395 Buffers_ B_;
396
398 static RecordablesMap< aeif_cond_exp > recordablesMap_;
399};
400
401inline size_t
402aeif_cond_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
403{
405 e.set_sender( *this );
406
407 return target.handles_test_event( e, receptor_type );
408}
409
410inline size_t
411aeif_cond_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
412{
413 if ( receptor_type != 0 )
414 {
415 throw UnknownReceptorType( receptor_type, get_name() );
416 }
417 return 0;
418}
419
420inline size_t
421aeif_cond_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
422{
423 if ( receptor_type != 0 )
424 {
425 throw UnknownReceptorType( receptor_type, get_name() );
426 }
427 return 0;
428}
429
430inline size_t
431aeif_cond_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
432{
433 if ( receptor_type != 0 )
434 {
435 throw UnknownReceptorType( receptor_type, get_name() );
436 }
437 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
438}
439
440inline void
441aeif_cond_exp::get_status( Dictionary& d ) const
442{
443 P_.get( d );
444 S_.get( d );
446
447 d[ names::recordables ] = recordablesMap_.get_list();
448}
449
450inline void
451aeif_cond_exp::set_status( const Dictionary& d )
452{
453 Parameters_ ptmp = P_; // temporary copy in case of errors
454 ptmp.set( d, this ); // throws if BadProperty
455 State_ stmp = S_; // temporary copy in case of errors
456 stmp.set( d, ptmp, this ); // throws if BadProperty
457
458 // We now know that (ptmp, stmp) are consistent. We do not
459 // write them back to (P_, S_) before we are also sure that
460 // the properties to be set in the parent class are internally
461 // consistent.
463
464 // if we get here, temporaries contain consistent set of properties
465 P_ = ptmp;
466 S_ = stmp;
467}
468
469} // namespace
470
471#endif // HAVE_GSL
472#endif // AEIF_COND_EXP_H
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP).
Definition archiving_node.h:49
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:249
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:265
Event for electrical currents.
Definition event.h:608
Request data to be logged/logged data to be sent.
Definition event.h:675
Base class for all NEST network objects.
Definition node.h:99
Event for spike information.
Definition event.h:420
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
const std::string tau_syn_in("tau_syn_in")
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 gsl_error_tol("gsl_error_tol")
const std::string V_th("V_th")
const std::string a("a")
const std::string V_peak("V_peak")
const std::string E_in("E_in")
const std::string target("target")
const std::string tau_syn_ex("tau_syn_ex")
const std::string b("b")
const std::string tau_w("tau_w")
const std::string Delta_T("Delta_T")
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
RecordablesMap< binary_neuron< TGainfunction > > binary_neuron< TGainfunction >::recordablesMap_
Definition binary_neuron.h:319
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121
const double e
Definition numerics.cpp:32