NEST main@caf0ae8
 
Loading...
Searching...
No Matches
aeif_psc_alpha.h
Go to the documentation of this file.
1/*
2 * aeif_psc_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_PSC_ALPHA_H
24#define AEIF_PSC_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
45
46namespace nest
47{
58extern "C" int aeif_psc_alpha_dynamics( double, const double*, double*, void* );
59
60/* BeginUserDocs: neuron, adaptation, integrate-and-fire, current-based, soft threshold
61
62Short description
63+++++++++++++++++
64
65Current-based exponential integrate-and-fire neuron model
66
67Description
68+++++++++++
69
70``aeif_psc_alpha`` is the adaptive exponential integrate and fire neuron according
71to Brette and Gerstner (2005).
72Synaptic currents are modelled as alpha-functions.
73
74This implementation uses the embedded 4th order Runge-Kutta-Fehlberg solver with
75adaptive step size to integrate the differential equation.
76
77The membrane potential is given by the following differential equation:
78
79.. math::
80
81 C dV/dt= -g_L(V-E_L)+g_L\cdot\Delta_T\cdot\exp((V-V_T)/\Delta_T) - w(t) + I_syn(t) + I_e
82
83and
84
85.. math::
86
87 \tau_w \cdot dw/dt= a(V-E_L) - w
88
89.. math::
90
91 I_{syn}(t) ~ \sum_k (t-t^k) \exp((t-t^k)/\tau_{syn})H(t - t^k) .
92
93Here :math:`H(t)` is the Heaviside step function and `k` indexes incoming spikes.
94
95For implementation details see the
96`aeif_models_implementation <../model_details/aeif_models_implementation.ipynb>`_ notebook.
97
98.. note::
99
100 The default refractory period for ``aeif`` models is zero, consistent with the model definition in
101 Brette & Gerstner :footcite:p:`Brette2005`. Thus, an ``aeif`` neuron with default parameters can fire multiple
102 spikes in a single time step, which can lead to exploding spike numbers and extreme slow-down of simulations.
103
104 To avoid such unphysiological behavior, you should set a refractory time ``t_ref > 0``.
105
106Parameters
107++++++++++
108
109The following parameters can be set in the status Dictionary.
110
111======== ======= =======================================
112**Dynamic state variables:**
113--------------------------------------------------------
114 V_m mV Membrane potential
115 I_ex pA Excitatory synaptic current
116 dI_ex pA/ms First derivative of I_ex
117 I_in pA Inhibitory synaptic current
118 dI_in pA/ms First derivative of I_in
119 w pA Spike-adaptation current
120 g pA Spike-adaptation current
121======== ======= =======================================
122
123======== ======= =======================================
124**Membrane Parameters**
125--------------------------------------------------------
126 C_m pF Capacity of the membrane
127 t_ref ms Duration of refractory period
128 V_reset mV Reset value for V_m after a spike
129 E_L mV Leak reversal potential
130 g_L nS Leak conductance
131 I_e pA Constant external input current
132======== ======= =======================================
133
134======== ======= ==================================
135**Spike adaptation parameters**
136---------------------------------------------------
137 a nS Subthreshold adaptation
138 b pA Spike-triggered adaptation
139 Delta_T mV Slope factor
140 tau_w ms Adaptation time constant
141 V_th mV Spike initiation threshold
142 V_peak mV Spike detection threshold
143======== ======= ==================================
144
145=========== ======= ===========================================================
146**Synaptic parameters**
147-------------------------------------------------------------------------------
148 tau_syn_ex ms Rise time of excitatory synaptic conductance (alpha
149 function)
150 tau_syn_in ms Rise time of the inhibitory synaptic conductance
151 (alpha function)
152=========== ======= ===========================================================
153
154============= ======= =========================================================
155**Integration parameters**
156-------------------------------------------------------------------------------
157gsl_error_tol real This parameter controls the admissible error of the
158 GSL integrator. Reduce it if NEST complains about
159 numerical instabilities
160============= ======= =========================================================
161
162Sends
163+++++
164
165SpikeEvent
166
167Receives
168++++++++
169
170SpikeEvent, CurrentEvent, DataLoggingRequest
171
172References
173++++++++++
174
175.. footbibliography::
176
177See also
178++++++++
179
180iaf_psc_alpha, aeif_cond_exp
181
182Examples using this model
183+++++++++++++++++++++++++
184
185.. listexamples:: aeif_psc_alpha
186
187EndUserDocs */
188
189void register_aeif_psc_alpha( const std::string& name );
190
191class aeif_psc_alpha : public ArchivingNode
192{
193
194public:
195 aeif_psc_alpha();
196 aeif_psc_alpha( const aeif_psc_alpha& );
197 ~aeif_psc_alpha() override;
198
204 using Node::handle;
205 using Node::handles_test_event;
206
207 size_t send_test_event( Node&, size_t, synindex, bool ) override;
208
209 void handle( SpikeEvent& ) override;
210 void handle( CurrentEvent& ) override;
211 void handle( DataLoggingRequest& ) override;
212
213 size_t handles_test_event( SpikeEvent&, size_t ) override;
214 size_t handles_test_event( CurrentEvent&, size_t ) override;
215 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
216
217 void get_status( Dictionary& ) const override;
218 void set_status( const Dictionary& ) override;
219
220private:
221 void init_buffers_() override;
222 void pre_run_hook() override;
223 void update( Time const&, const long, const long ) override;
224
225 // END Boilerplate function declarations ----------------------------
226
227 // Friends --------------------------------------------------------
228
229 // make dynamics function quasi-member
230 friend int aeif_psc_alpha_dynamics( double, const double*, double*, void* );
231
232 // The next two classes need to be friends to access the State_ class/member
233 friend class RecordablesMap< aeif_psc_alpha >;
234 friend class UniversalDataLogger< aeif_psc_alpha >;
235
236private:
237 // ----------------------------------------------------------------
238
240 struct Parameters_
241 {
242 double V_peak_;
243 double V_reset_;
244 double t_ref_;
245
246 double g_L;
247 double C_m;
248 double E_L;
249 double Delta_T;
250 double tau_w;
251 double a;
252 double b;
253 double V_th;
254 double tau_syn_ex;
255 double tau_syn_in;
256 double I_e;
257
258 double gsl_error_tol;
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 {
281 enum StateVecElems
282 {
283 V_M = 0,
284 DI_EXC, // 1
285 I_EXC, // 2
286 DI_INH, // 3
287 I_INH, // 4
288 W, // 5
289 STATE_VEC_SIZE
290 };
291
292 double y_[ STATE_VEC_SIZE ];
294 unsigned int r_;
295
296 State_( const Parameters_& );
297 State_( const State_& );
298
299 State_& operator=( const State_& );
300
301 void get( Dictionary& ) const;
302 void set( const Dictionary&, const Parameters_&, Node* );
303 };
304
305 // ----------------------------------------------------------------
306
310 struct Buffers_
311 {
312 Buffers_( aeif_psc_alpha& );
313 Buffers_( const Buffers_&, aeif_psc_alpha& );
314
316 UniversalDataLogger< aeif_psc_alpha > logger_;
317
319 RingBuffer spike_exc_;
320 RingBuffer spike_inh_;
321 RingBuffer currents_;
322
324 gsl_odeiv_step* s_;
325 gsl_odeiv_control* c_;
326 gsl_odeiv_evolve* e_;
327 gsl_odeiv_system sys_;
328
329 // Since IntegrationStep_ is initialized with step_, and the resolution
330 // cannot change after nodes have been created, it is safe to place both
331 // here.
332 double step_;
333 double IntegrationStep_;
334
342 double I_stim_;
343 };
344
345 // ----------------------------------------------------------------
346
350 struct Variables_
351 {
353 double i0_ex_;
354
356 double i0_in_;
357
362 double V_peak;
363
364 unsigned int refractory_counts_;
365 };
366
367 // Access functions for UniversalDataLogger -------------------------------
368
370 template < State_::StateVecElems elem >
371 double
372 get_y_elem_() const
373 {
374 return S_.y_[ elem ];
375 }
376
377 // ----------------------------------------------------------------
378
379 Parameters_ P_;
380 State_ S_;
381 Variables_ V_;
382 Buffers_ B_;
383
385 static RecordablesMap< aeif_psc_alpha > recordablesMap_;
386};
387
388inline size_t
389aeif_psc_alpha::send_test_event( Node& target, size_t receptor_type, synindex, bool )
390{
391 SpikeEvent e;
392 e.set_sender( *this );
393
394 return target.handles_test_event( e, receptor_type );
395}
396
397inline size_t
398aeif_psc_alpha::handles_test_event( SpikeEvent&, size_t receptor_type )
399{
400 if ( receptor_type != 0 )
401 {
402 throw UnknownReceptorType( receptor_type, get_name() );
403 }
404 return 0;
405}
406
407inline size_t
408aeif_psc_alpha::handles_test_event( CurrentEvent&, size_t receptor_type )
409{
410 if ( receptor_type != 0 )
411 {
412 throw UnknownReceptorType( receptor_type, get_name() );
413 }
414 return 0;
415}
416
417inline size_t
418aeif_psc_alpha::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
419{
420 if ( receptor_type != 0 )
421 {
422 throw UnknownReceptorType( receptor_type, get_name() );
423 }
424 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
425}
426
427inline void
428aeif_psc_alpha::get_status( Dictionary& d ) const
429{
430 P_.get( d );
431 S_.get( d );
433
434 d[ names::recordables ] = recordablesMap_.get_list();
435}
436
437inline void
438aeif_psc_alpha::set_status( const Dictionary& d )
439{
440 Parameters_ ptmp = P_; // temporary copy in case of errors
441 ptmp.set( d, this ); // throws if BadProperty
442 State_ stmp = S_; // temporary copy in case of errors
443 stmp.set( d, ptmp, this ); // throws if BadProperty
444
445 // We now know that (ptmp, stmp) are consistent. We do not
446 // write them back to (P_, S_) before we are also sure that
447 // the properties to be set in the parent class are internally
448 // consistent.
450
451 // if we get here, temporaries contain consistent set of properties
452 P_ = ptmp;
453 S_ = stmp;
454}
455
456} // namespace
457
458#endif // HAVE_GSL
459#endif // AEIF_PSC_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 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 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