NEST main@caf0ae8
 
Loading...
Searching...
No Matches
aeif_psc_delta.h
Go to the documentation of this file.
1/*
2 * aeif_psc_delta.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_DELTA_H
24#define AEIF_PSC_DELTA_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_delta_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 adaptive exponential integrate-and-fire neuron model with delta synapse
66
67Description
68+++++++++++
69
70``aeif_psc_delta`` is the adaptive exponential integrate and fire neuron
71according to Brette and Gerstner (2005), with postsynaptic currents
72in the form of delta spikes.
73
74This implementation uses the embedded 4th order Runge-Kutta-Fehlberg
75solver with adaptive stepsize 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) = J \sum_k \delta(t - t^k).
92
93Here delta is the Dirac delta function and `k` indexes incoming
94spikes. This is implemented such that ``V_m`` will be incremented/decremented by
95the value of `J` after a spike.
96
97For implementation details see the
98`aeif_models_implementation <../model_details/aeif_models_implementation.ipynb>`_ notebook.
99
100.. note::
101
102 The default refractory period for ``aeif`` models is zero, consistent with the model definition in
103 Brette & Gerstner :footcite:p:`Brette2005`. Thus, an ``aeif`` neuron with default parameters can fire multiple
104 spikes in a single time step, which can lead to exploding spike numbers and extreme slow-down of simulations.
105
106 To avoid such unphysiological behavior, you should set a refractory time ``t_ref > 0``.
107
108Parameters
109++++++++++
110
111The following parameters can be set in the status Dictionary.
112
113======== ======= =======================================
114**Dynamic state variables**
115--------------------------------------------------------
116 V_m mV Membrane potential
117 w pA Spike-adaptation current
118======== ======= =======================================
119
120======== ======= =======================================
121**Membrane Parameters**
122--------------------------------------------------------
123 C_m pF Capacity of the membrane
124 t_ref ms Duration of refractory period
125 V_reset mV Reset value for V_m after a spike
126 E_L mV Leak reversal potential
127 g_L nS Leak conductance
128 I_e pA Constant external input current
129======== ======= =======================================
130
131======== ======= ==================================
132**Spike adaptation parameters**
133---------------------------------------------------
134 a ns Subthreshold adaptation
135 b pA Spike-triggered adaptation
136 tau_w ms Adaptation time constant
137 Delta_T mV Slope factor
138 tau_w ms Adaptation time constant
139 V_th mV Spike initiation threshold
140 V_peak mV Spike detection threshold
141======== ======= ==================================
142
143============= ======= =========================================================
144**Integration parameters**
145-------------------------------------------------------------------------------
146gsl_error_tol real This parameter controls the admissible error of the
147 GSL integrator. Reduce it if NEST complains about
148 numerical instabilities.
149============= ======= =========================================================
150
151Sends
152+++++
153
154SpikeEvent
155
156Receives
157++++++++
158
159SpikeEvent, CurrentEvent, DataLoggingRequest
160
161References
162++++++++++
163
164.. footbibliography::
165
166See also
167++++++++
168
169iaf_psc_delta, aeif_cond_exp, aeif_psc_exp
170
171Examples using this model
172+++++++++++++++++++++++++
173
174.. listexamples:: aeif_psc_delta
175
176EndUserDocs */
177
178void register_aeif_psc_delta( const std::string& name );
179
180class aeif_psc_delta : public ArchivingNode
181{
182
183public:
184 aeif_psc_delta();
185 aeif_psc_delta( const aeif_psc_delta& );
186 ~aeif_psc_delta() override;
187
193 using Node::handle;
194 using Node::handles_test_event;
195
196 size_t send_test_event( Node&, size_t, synindex, bool ) override;
197
198 void handle( SpikeEvent& ) override;
199 void handle( CurrentEvent& ) override;
200 void handle( DataLoggingRequest& ) override;
201
202 size_t handles_test_event( SpikeEvent&, size_t ) override;
203 size_t handles_test_event( CurrentEvent&, size_t ) override;
204 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
205
206 void get_status( Dictionary& ) const override;
207 void set_status( const Dictionary& ) override;
208
209private:
210 void init_buffers_() override;
211 void pre_run_hook() override;
212 void update( const Time&, const long, const long ) override;
213
214 // END Boilerplate function declarations ----------------------------
215
216 // Friends --------------------------------------------------------
217
218 // make dynamics function quasi-member
219 friend int aeif_psc_delta_dynamics( double, const double*, double*, void* );
220
221 // The next two classes need to be friends to access the State_ class/member
222 friend class RecordablesMap< aeif_psc_delta >;
223 friend class UniversalDataLogger< aeif_psc_delta >;
224
225private:
226 // ----------------------------------------------------------------
227
229 struct Parameters_
230 {
231 double V_peak_;
232 double V_reset_;
233
234 double t_ref_;
235
236 double g_L;
237 double C_m;
238 double E_L;
239 double Delta_T;
240 double tau_w;
241 double a;
242 double b;
243 double V_th;
244 double I_e;
245
246 double gsl_error_tol;
247 bool with_refr_input_;
248
249 Parameters_();
250
251 void get( Dictionary& ) const;
252 void set( const Dictionary&, Node* node );
253 };
254
255public:
256 // ----------------------------------------------------------------
257
262 struct State_
263 {
267 double refr_spikes_buffer_;
268
275 enum StateVecElems
276 {
277 V_M = 0,
278 W,
279 STATE_VEC_SIZE
280 };
281
283 double y_[ STATE_VEC_SIZE ];
284 unsigned int r_;
285
286 State_( const Parameters_& );
287 State_( const State_& );
288
289 State_& operator=( const State_& );
290
291 void get( Dictionary& ) const;
292 void set( const Dictionary&, const Parameters_&, Node* );
293 };
294
295 // ----------------------------------------------------------------
296
300 struct Buffers_
301 {
302 Buffers_( aeif_psc_delta& );
303 Buffers_( const Buffers_&, aeif_psc_delta& );
304
306 UniversalDataLogger< aeif_psc_delta > logger_;
307
309 RingBuffer spikes_;
310 RingBuffer currents_;
311
313 gsl_odeiv_step* s_;
314 gsl_odeiv_control* c_;
315 gsl_odeiv_evolve* e_;
316 gsl_odeiv_system sys_;
317
318 // Since IntegrationStep_ is initialized with step_, and the resolution
319 // cannot change after nodes have been created, it is safe to place both
320 // here.
321 double step_;
322 double IntegrationStep_;
323
331 double I_stim_;
332 };
333
334 // ----------------------------------------------------------------
335
339 struct Variables_
340 {
345 double V_peak_;
346
347 unsigned int refractory_counts_;
348
349 double Delta_T_inv_;
350
351 double C_m_inv_;
352
353 double tau_w_inv_;
354 };
355
356 // Access functions for UniversalDataLogger -------------------------------
357
359 template < State_::StateVecElems elem >
360 double
361 get_y_elem_() const
362 {
363 return S_.y_[ elem ];
364 }
365
366 // ----------------------------------------------------------------
367
368 Parameters_ P_;
369 State_ S_;
370 Variables_ V_;
371 Buffers_ B_;
372
374 static RecordablesMap< aeif_psc_delta > recordablesMap_;
375};
376
377inline size_t
378aeif_psc_delta::send_test_event( Node& target, size_t receptor_type, synindex, bool )
379{
380 SpikeEvent e;
381 e.set_sender( *this );
382
383 return target.handles_test_event( e, receptor_type );
384}
385
386inline size_t
387aeif_psc_delta::handles_test_event( SpikeEvent&, size_t receptor_type )
388{
389 if ( receptor_type != 0 )
390 {
391 throw UnknownReceptorType( receptor_type, get_name() );
392 }
393 return 0;
394}
395
396inline size_t
397aeif_psc_delta::handles_test_event( CurrentEvent&, size_t receptor_type )
398{
399 if ( receptor_type != 0 )
400 {
401 throw UnknownReceptorType( receptor_type, get_name() );
402 }
403 return 0;
404}
405
406inline size_t
407aeif_psc_delta::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
408{
409 if ( receptor_type != 0 )
410 {
411 throw UnknownReceptorType( receptor_type, get_name() );
412 }
413 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
414}
415
416inline void
417aeif_psc_delta::get_status( Dictionary& d ) const
418{
419 P_.get( d );
420 S_.get( d );
422
423 d[ names::recordables ] = recordablesMap_.get_list();
424}
425
426inline void
427aeif_psc_delta::set_status( const Dictionary& d )
428{
429 Parameters_ ptmp = P_; // temporary copy in case of errors
430 ptmp.set( d, this ); // throws if BadProperty
431 State_ stmp = S_; // temporary copy in case of errors
432 stmp.set( d, ptmp, this ); // throws if BadProperty
433
434 // We now know that (ptmp, stmp) are consistent. We do not
435 // write them back to (P_, S_) before we are also sure that
436 // the properties to be set in the parent class are internally
437 // consistent.
439
440 // if we get here, temporaries contain consistent set of properties
441 P_ = ptmp;
442 S_ = stmp;
443}
444
445} // namespace
446
447#endif // HAVE_GSL
448#endif // AEIF_PSC_DELTA_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 gsl_error_tol("gsl_error_tol")
const std::string V_th("V_th")
const std::string a("a")
const std::string target("target")
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