NEST main@caf0ae8
 
Loading...
Searching...
No Matches
aeif_cond_alpha.h
Go to the documentation of this file.
1/*
2 * aeif_cond_alpha.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_ALPHA_H
24#define AEIF_COND_ALPHA_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_alpha_dynamics( double, const double*, double*, void* );
58
69extern "C" int aeif_cond_alpha_dynamics_DT0( double, const double*, double*, void* );
70
71/* BeginUserDocs: neuron, integrate-and-fire, adaptation, conductance-based, soft threshold
72
73Short description
74+++++++++++++++++
75
76Conductance based exponential integrate-and-fire neuron model
77
78Description
79+++++++++++
80
81``aeif_cond_alpha`` is the adaptive exponential integrate and fire neuron according
82to Brette and Gerstner (2005).
83Synaptic conductances are modelled as alpha-functions.
84
85This implementation uses the embedded 4th order Runge-Kutta-Fehlberg solver with
86adaptive step size to integrate the differential equation.
87
88The membrane potential is given by the following differential equation:
89
90.. math::
91
92 C_m \frac{dV}{dt} =
93 -g_L(V-E_L)+g_L\Delta_T\exp\left(\frac{V-V_{th}}{\Delta_T}\right) -
94 g_e(t)(V-E_e) \\
95 -g_i(t)(V-E_i)-w +I_e
96
97and
98
99.. math::
100
101 \tau_w \frac{dw}{dt} = a(V-E_L) - w
102
103For the reference implementation of this model, see
104`aeif_models_implementation <../model_details/aeif_models_implementation.ipynb>`_ notebook.
105
106
107.. note::
108
109 The default refractory period for ``aeif`` models is zero, consistent with the model definition in
110 Brette & Gerstner :footcite:p:`Brette2005`. Thus, an ``aeif`` neuron with default parameters can fire multiple
111 spikes in a single time step, which can lead to exploding spike numbers and extreme slow-down of simulations.
112
113 To avoid such unphysiological behavior, you should set a refractory time ``t_ref > 0``.
114
115Parameters
116++++++++++
117
118The following parameters can be set in the status Dictionary.
119
120======== ======= =======================================
121**Dynamic state variables:**
122--------------------------------------------------------
123 V_m mV Membrane potential
124 g_ex nS Excitatory synaptic conductance
125 dg_ex nS/ms First derivative of g_ex
126 g_in nS Inhibitory synaptic conductance
127 dg_in nS/ms First derivative of g_in
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 Rise time of excitatory synaptic conductance (alpha
158 function)
159 E_in mV Inhibitory reversal potential
160 tau_syn_in ms Rise time of the inhibitory synaptic conductance
161 (alpha function)
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_alpha, aeif_cond_exp
191
192Examples using this model
193+++++++++++++++++++++++++
194
195.. listexamples:: aeif_cond_alpha
196
197EndUserDocs */
198
199void register_aeif_cond_alpha( const std::string& name );
200
201class aeif_cond_alpha : public ArchivingNode
202{
203
204public:
205 aeif_cond_alpha();
206 aeif_cond_alpha( const aeif_cond_alpha& );
207 ~aeif_cond_alpha() 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( Time const&, 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_alpha_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_alpha >;
244 friend class UniversalDataLogger< aeif_cond_alpha >;
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 DG_EXC, // 1
297 G_EXC, // 2
298 DG_INH, // 3
299 G_INH, // 4
300 W, // 5
301 STATE_VEC_SIZE
302 };
303
304 double y_[ STATE_VEC_SIZE ];
306 unsigned int r_;
307
308 State_( const Parameters_& );
309 State_( const State_& );
310
311 State_& operator=( const State_& );
312
313 void get( Dictionary& ) const;
314 void set( const Dictionary&, const Parameters_&, Node* );
315 };
316
317 // ----------------------------------------------------------------
318
322 struct Buffers_
323 {
324 Buffers_( aeif_cond_alpha& );
325 Buffers_( const Buffers_&, aeif_cond_alpha& );
326
328 UniversalDataLogger< aeif_cond_alpha > logger_;
329
331 RingBuffer spike_exc_;
332 RingBuffer spike_inh_;
333 RingBuffer currents_;
334
336 gsl_odeiv_step* s_;
337 gsl_odeiv_control* c_;
338 gsl_odeiv_evolve* e_;
339 gsl_odeiv_system sys_;
340
341 // Since IntegrationStep_ is initialized with step_, and the resolution
342 // cannot change after nodes have been created, it is safe to place both
343 // here.
344 double step_;
345 double IntegrationStep_;
346
354 double I_stim_;
355 };
356
357 // ----------------------------------------------------------------
358
362 struct Variables_
363 {
365 double g0_ex_;
366
368 double g0_in_;
369
374 double V_peak;
375
376 unsigned int refractory_counts_;
377 };
378
379 // Access functions for UniversalDataLogger -------------------------------
380
382 template < State_::StateVecElems elem >
383 double
384 get_y_elem_() const
385 {
386 return S_.y_[ elem ];
387 }
388
389 // ----------------------------------------------------------------
390
391 Parameters_ P_;
392 State_ S_;
393 Variables_ V_;
394 Buffers_ B_;
395
397 static RecordablesMap< aeif_cond_alpha > recordablesMap_;
398};
399
400inline size_t
401aeif_cond_alpha::send_test_event( Node& target, size_t receptor_type, synindex, bool )
402{
403 SpikeEvent e;
404 e.set_sender( *this );
405
406 return target.handles_test_event( e, receptor_type );
407}
408
409inline size_t
410aeif_cond_alpha::handles_test_event( SpikeEvent&, size_t receptor_type )
411{
412 if ( receptor_type != 0 )
413 {
414 throw UnknownReceptorType( receptor_type, get_name() );
415 }
416 return 0;
417}
418
419inline size_t
420aeif_cond_alpha::handles_test_event( CurrentEvent&, size_t receptor_type )
421{
422 if ( receptor_type != 0 )
423 {
424 throw UnknownReceptorType( receptor_type, get_name() );
425 }
426 return 0;
427}
428
429inline size_t
430aeif_cond_alpha::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
431{
432 if ( receptor_type != 0 )
433 {
434 throw UnknownReceptorType( receptor_type, get_name() );
435 }
436 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
437}
438
439inline void
440aeif_cond_alpha::get_status( Dictionary& d ) const
441{
442 P_.get( d );
443 S_.get( d );
445
446 d[ names::recordables ] = recordablesMap_.get_list();
447}
448
449inline void
450aeif_cond_alpha::set_status( const Dictionary& d )
451{
452 Parameters_ ptmp = P_; // temporary copy in case of errors
453 ptmp.set( d, this ); // throws if BadProperty
454 State_ stmp = S_; // temporary copy in case of errors
455 stmp.set( d, ptmp, this ); // throws if BadProperty
456
457 // We now know that (ptmp, stmp) are consistent. We do not
458 // write them back to (P_, S_) before we are also sure that
459 // the properties to be set in the parent class are internally
460 // consistent.
462
463 // if we get here, temporaries contain consistent set of properties
464 P_ = ptmp;
465 S_ = stmp;
466}
467
468} // namespace
469
470#endif // HAVE_GSL
471#endif // AEIF_COND_ALPHA_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