NEST main@caf0ae8
 
Loading...
Searching...
No Matches
aeif_psc_exp.h
Go to the documentation of this file.
1/*
2 * aeif_psc_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_PSC_EXP_H
24#define AEIF_PSC_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
45
46namespace nest
47{
58extern "C" int aeif_psc_exp_dynamics( double, const double*, double*, void* );
59
60/* BeginUserDocs: neuron, integrate-and-fire, adaptation, current-based, soft threshold
61
62Short description
63+++++++++++++++++
64
65Current-based exponential integrate-and-fire neuron model
66
67Description
68+++++++++++
69
70``aeif_psc_exp`` is the adaptive exponential integrate and fire neuron
71according to Brette and Gerstner (2005), with postsynaptic currents
72in the form of truncated exponentials.
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) ~ \sum_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 I_in pA Inhibitory synaptic current
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 Delta_T mV Slope factor
137 tau_w ms Adaptation time constant
138 V_th mV Spike initiation threshold
139 V_peak mV Spike detection threshold
140======== ======= ==================================
141
142=========== ======= ===========================================================
143**Synaptic parameters**
144-------------------------------------------------------------------------------
145 tau_syn_ex ms Exponential decay time constant of excitatory synaptic
146 conductance kernel
147 tau_syn_in ms Exponential decay time constant of inhibitory synaptic
148 conductance kernel
149=========== ======= ===========================================================
150
151============= ======= =========================================================
152**Integration parameters**
153-------------------------------------------------------------------------------
154gsl_error_tol real This parameter controls the admissible error of the
155 GSL integrator. Reduce it if NEST complains about
156 numerical instabilities
157============= ======= =========================================================
158
159Sends
160+++++
161
162SpikeEvent
163
164Receives
165++++++++
166
167SpikeEvent, CurrentEvent, DataLoggingRequest
168
169References
170++++++++++
171
172.. footbibliography::
173
174See also
175++++++++
176
177iaf_psc_exp, aeif_cond_exp
178
179Examples using this model
180+++++++++++++++++++++++++
181
182.. listexamples:: aeif_psc_exp
183
184EndUserDocs */
185
186void register_aeif_psc_exp( const std::string& name );
187
188class aeif_psc_exp : public ArchivingNode
189{
190
191public:
192 aeif_psc_exp();
193 aeif_psc_exp( const aeif_psc_exp& );
194 ~aeif_psc_exp() override;
195
201 using Node::handle;
202 using Node::handles_test_event;
203
204 size_t send_test_event( Node&, size_t, synindex, bool ) override;
205
206 void handle( SpikeEvent& ) override;
207 void handle( CurrentEvent& ) override;
208 void handle( DataLoggingRequest& ) override;
209
210 size_t handles_test_event( SpikeEvent&, size_t ) override;
211 size_t handles_test_event( CurrentEvent&, size_t ) override;
212 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
213
214 void get_status( Dictionary& ) const override;
215 void set_status( const Dictionary& ) override;
216
217private:
218 void init_buffers_() override;
219 void pre_run_hook() override;
220 void update( const Time&, const long, const long ) override;
221
222 // END Boilerplate function declarations ----------------------------
223
224 // Friends --------------------------------------------------------
225
226 // make dynamics function quasi-member
227 friend int aeif_psc_exp_dynamics( double, const double*, double*, void* );
228
229 // The next two classes need to be friends to access the State_ class/member
230 friend class RecordablesMap< aeif_psc_exp >;
231 friend class UniversalDataLogger< aeif_psc_exp >;
232
233private:
234 // ----------------------------------------------------------------
235
237 struct Parameters_
238 {
239 double V_peak_;
240 double V_reset_;
241 double t_ref_;
242
243 double g_L;
244 double C_m;
245 double E_L;
246 double Delta_T;
247 double tau_w;
248 double a;
249 double b;
250 double V_th;
251 double tau_syn_ex;
252 double tau_syn_in;
253 double I_e;
254
255 double gsl_error_tol;
256
257 Parameters_();
258
259 void get( Dictionary& ) const;
260 void set( const Dictionary&, Node* node );
261 };
262
263public:
264 // ----------------------------------------------------------------
265
270 struct State_
271 {
278 enum StateVecElems
279 {
280 V_M = 0,
281 I_EXC, // 1
282 I_INH, // 2
283 W, // 3
284 STATE_VEC_SIZE
285 };
286
288 double y_[ STATE_VEC_SIZE ];
289 unsigned int r_;
290
291 State_( const Parameters_& );
292 State_( const State_& );
293
294 State_& operator=( const State_& );
295
296 void get( Dictionary& ) const;
297 void set( const Dictionary&, const Parameters_&, Node* );
298 };
299
300 // ----------------------------------------------------------------
301
305 struct Buffers_
306 {
307 Buffers_( aeif_psc_exp& );
308 Buffers_( const Buffers_&, aeif_psc_exp& );
309
311 UniversalDataLogger< aeif_psc_exp > logger_;
312
314 RingBuffer spike_exc_;
315 RingBuffer spike_inh_;
316 RingBuffer currents_;
317
319 gsl_odeiv_step* s_;
320 gsl_odeiv_control* c_;
321 gsl_odeiv_evolve* e_;
322 gsl_odeiv_system sys_;
323
324 // Since IntegrationStep_ is initialized with step_, and the resolution
325 // cannot change after nodes have been created, it is safe to place both
326 // here.
327 double step_;
328 double IntegrationStep_;
329
337 double I_stim_;
338 };
339
340 // ----------------------------------------------------------------
341
345 struct Variables_
346 {
351 double V_peak;
352
353 unsigned int refractory_counts_;
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_exp > recordablesMap_;
375};
376
377inline size_t
378aeif_psc_exp::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_exp::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_exp::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_exp::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_exp::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_exp::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_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 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