NEST main@caf0ae8
 
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
118Parameters
119++++++++++
120The following parameters can be set in the status Dictionary.
121
122======== ======= =======================================
123**Dynamic state variables:**
124--------------------------------------------------------
125 V_m mV Membrane potential
126 g_ex nS Excitatory synaptic conductance
127 g_in nS Inhibitory synaptic conductance
128 w pA Spike-adaptation current
129======== ======= =======================================
130
131======== ======= =======================================
132**Membrane Parameters**
133--------------------------------------------------------
134 C_m pF Capacity of the membrane
135 t_ref ms Duration of refractory period
136 V_reset mV Reset value for V_m after a spike
137 E_L mV Leak reversal potential
138 g_L nS Leak conductance
139 I_e pA Constant external input current
140======== ======= =======================================
141
142======== ======= ==================================
143**Spike adaptation parameters**
144---------------------------------------------------
145 a nS Subthreshold adaptation
146 b pA Spike-triggered adaptation
147 Delta_T mV Slope factor
148 tau_w ms Adaptation time constant
149 V_th mV Spike initiation threshold
150 V_peak mV Spike detection threshold
151======== ======= ==================================
152
153=========== ======= ===========================================================
154**Synaptic parameters**
155-------------------------------------------------------------------------------
156 E_ex mV Excitatory reversal potential
157 tau_syn_ex ms Exponential decay time constant of excitatory synaptic
158 conductance kernel
159 E_in mV Inhibitory reversal potential
160 tau_syn_in ms Exponential decay time constant of inhibitory synaptic
161 conductance kernel
162=========== ======= ===========================================================
163
164============= ======= =========================================================
165**Integration parameters**
166-------------------------------------------------------------------------------
167gsl_error_tol real This parameter controls the admissible error of the
168 GSL integrator. Reduce it if NEST complains about
169 numerical instabilities.
170============= ======= =========================================================
171
172Sends
173+++++
174
175SpikeEvent
176
177Receives
178++++++++
179
180SpikeEvent, CurrentEvent, DataLoggingRequest
181
182References
183++++++++++
184
185.. footbibliography::
186
187See also
188++++++++
189
190iaf_cond_exp, aeif_cond_alpha
191
192Examples using this model
193+++++++++++++++++++++++++
194
195.. listexamples:: aeif_cond_exp
196
197EndUserDocs */
198
199void register_aeif_cond_exp( const std::string& name );
200
201class aeif_cond_exp : public ArchivingNode
202{
203
204public:
205 aeif_cond_exp();
206 aeif_cond_exp( const aeif_cond_exp& );
207 ~aeif_cond_exp() override;
208
214 using Node::handle;
215 using Node::handles_test_event;
216
217 size_t send_test_event( Node&, size_t, synindex, bool ) override;
218
219 void handle( SpikeEvent& ) override;
220 void handle( CurrentEvent& ) override;
221 void handle( DataLoggingRequest& ) override;
222
223 size_t handles_test_event( SpikeEvent&, size_t ) override;
224 size_t handles_test_event( CurrentEvent&, size_t ) override;
225 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
226
227 void get_status( Dictionary& ) const override;
228 void set_status( const Dictionary& ) override;
229
230private:
231 void init_buffers_() override;
232 void pre_run_hook() override;
233 void update( const Time&, const long, const long ) override;
234
235 // END Boilerplate function declarations ----------------------------
236
237 // Friends --------------------------------------------------------
238
239 // make dynamics function quasi-member
240 friend int aeif_cond_exp_dynamics( double, const double*, double*, void* );
241
242 // The next two classes need to be friends to access the State_ class/member
243 friend class RecordablesMap< aeif_cond_exp >;
244 friend class UniversalDataLogger< aeif_cond_exp >;
245
246private:
247 // ----------------------------------------------------------------
248
250 struct Parameters_
251 {
252 double V_peak_;
253 double V_reset_;
254 double t_ref_;
255
256 double g_L;
257 double C_m;
258 double E_ex;
259 double E_in;
260 double E_L;
261 double Delta_T;
262 double tau_w;
263 double a;
264 double b;
265 double V_th;
266 double tau_syn_ex;
267 double tau_syn_in;
268 double I_e;
269
270 double gsl_error_tol;
271
272 Parameters_();
273
274 void get( Dictionary& ) const;
275 void set( const Dictionary&, Node* node );
276 };
277
278public:
279 // ----------------------------------------------------------------
280
285 struct State_
286 {
293 enum StateVecElems
294 {
295 V_M = 0,
296 G_EXC, // 1
297 G_INH, // 2
298 W, // 3
299 STATE_VEC_SIZE
300 };
301
303 double y_[ STATE_VEC_SIZE ];
304 unsigned int r_;
305
306 State_( const Parameters_& );
307 State_( const State_& );
308
309 State_& operator=( const State_& );
310
311 void get( Dictionary& ) const;
312 void set( const Dictionary&, const Parameters_&, Node* );
313 };
314
315 // ----------------------------------------------------------------
316
320 struct Buffers_
321 {
322 Buffers_( aeif_cond_exp& );
323 Buffers_( const Buffers_&, aeif_cond_exp& );
324
326 UniversalDataLogger< aeif_cond_exp > logger_;
327
329 RingBuffer spike_exc_;
330 RingBuffer spike_inh_;
331 RingBuffer currents_;
332
334 gsl_odeiv_step* s_;
335 gsl_odeiv_control* c_;
336 gsl_odeiv_evolve* e_;
337 gsl_odeiv_system sys_;
338
339 // Since IntegrationStep_ is initialized with step_, and the resolution
340 // cannot change after nodes have been created, it is safe to place both
341 // here.
342 double step_;
343 double IntegrationStep_;
344
352 double I_stim_;
353 };
354
355 // ----------------------------------------------------------------
356
360 struct Variables_
361 {
366 double V_peak;
367
368 unsigned int refractory_counts_;
369 };
370
371 // Access functions for UniversalDataLogger -------------------------------
372
374 template < State_::StateVecElems elem >
375 double
376 get_y_elem_() const
377 {
378 return S_.y_[ elem ];
379 }
380
381 // ----------------------------------------------------------------
382
383 Parameters_ P_;
384 State_ S_;
385 Variables_ V_;
386 Buffers_ B_;
387
389 static RecordablesMap< aeif_cond_exp > recordablesMap_;
390};
391
392inline size_t
393aeif_cond_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
394{
395 SpikeEvent e;
396 e.set_sender( *this );
397
398 return target.handles_test_event( e, receptor_type );
399}
400
401inline size_t
402aeif_cond_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
403{
404 if ( receptor_type != 0 )
405 {
406 throw UnknownReceptorType( receptor_type, get_name() );
407 }
408 return 0;
409}
410
411inline size_t
412aeif_cond_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
413{
414 if ( receptor_type != 0 )
415 {
416 throw UnknownReceptorType( receptor_type, get_name() );
417 }
418 return 0;
419}
420
421inline size_t
422aeif_cond_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
423{
424 if ( receptor_type != 0 )
425 {
426 throw UnknownReceptorType( receptor_type, get_name() );
427 }
428 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
429}
430
431inline void
432aeif_cond_exp::get_status( Dictionary& d ) const
433{
434 P_.get( d );
435 S_.get( d );
437
438 d[ names::recordables ] = recordablesMap_.get_list();
439}
440
441inline void
442aeif_cond_exp::set_status( const Dictionary& d )
443{
444 Parameters_ ptmp = P_; // temporary copy in case of errors
445 ptmp.set( d, this ); // throws if BadProperty
446 State_ stmp = S_; // temporary copy in case of errors
447 stmp.set( d, ptmp, this ); // throws if BadProperty
448
449 // We now know that (ptmp, stmp) are consistent. We do not
450 // write them back to (P_, S_) before we are also sure that
451 // the properties to be set in the parent class are internally
452 // consistent.
454
455 // if we get here, temporaries contain consistent set of properties
456 P_ = ptmp;
457 S_ = stmp;
458}
459
460} // namespace
461
462#endif // HAVE_GSL
463#endif // AEIF_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 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
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
const double e
Definition numerics.cpp:32