NEST main@f146f75
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
106.. note::
107
108 Incoming spikes are routed to the excitatory or inhibitory synapse type by the **sign of the
109 connection weight**. A positive weight targets the excitatory synapse type, a negative weight
110 the inhibitory one, and also sets the direction of the post-synaptic current.
111 Spike connections must use the default ``receptor_type`` of 0.
112
113 See :ref:`synapse_selection` for the conventions used by other models.
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 I_ex pA Excitatory synaptic current
125 I_in pA Inhibitory synaptic current
126 w pA Spike-adaptation current
127======== ======= =======================================
128
129======== ======= =======================================
130**Membrane Parameters**
131--------------------------------------------------------
132 C_m pF Capacity of the membrane
133 t_ref ms Duration of refractory period
134 V_reset mV Reset value for V_m after a spike
135 E_L mV Leak reversal potential
136 g_L nS Leak conductance
137 I_e pA Constant external input current
138======== ======= =======================================
139
140======== ======= ==================================
141**Spike adaptation parameters**
142---------------------------------------------------
143 a ns Subthreshold adaptation
144 b pA Spike-triggered adaptation
145 Delta_T mV Slope factor
146 tau_w ms Adaptation time constant
147 V_th mV Spike initiation threshold
148 V_peak mV Spike detection threshold
149======== ======= ==================================
150
151=========== ======= ===========================================================
152**Synaptic parameters**
153-------------------------------------------------------------------------------
154 tau_syn_ex ms Exponential decay time constant of excitatory synaptic
155 conductance kernel
156 tau_syn_in ms Exponential decay time constant of inhibitory synaptic
157 conductance kernel
158=========== ======= ===========================================================
159
160============= ======= =========================================================
161**Integration parameters**
162-------------------------------------------------------------------------------
163gsl_error_tol real This parameter controls the admissible error of the
164 GSL integrator. Reduce it if NEST complains about
165 numerical instabilities
166============= ======= =========================================================
167
168Sends
169+++++
170
171SpikeEvent
172
173Receives
174++++++++
175
176SpikeEvent, CurrentEvent, DataLoggingRequest
177
178References
179++++++++++
180
181.. footbibliography::
182
183See also
184++++++++
185
186iaf_psc_exp, aeif_cond_exp
187
188Examples using this model
189+++++++++++++++++++++++++
190
191.. listexamples:: aeif_psc_exp
192
193EndUserDocs */
194
195void register_aeif_psc_exp( const std::string& name );
196
197class aeif_psc_exp : public ArchivingNode
198{
199
200public:
201 aeif_psc_exp();
202 aeif_psc_exp( const aeif_psc_exp& );
203 ~aeif_psc_exp() override;
204
210 using Node::handle;
211 using Node::handles_test_event;
212
213 size_t send_test_event( Node&, size_t, synindex, bool ) override;
214
215 void handle( SpikeEvent& ) override;
216 void handle( CurrentEvent& ) override;
217 void handle( DataLoggingRequest& ) override;
218
219 size_t handles_test_event( SpikeEvent&, size_t ) override;
220 size_t handles_test_event( CurrentEvent&, size_t ) override;
221 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
222
223 void get_status( Dictionary& ) const override;
224 void set_status( const Dictionary& ) override;
225
226private:
227 void init_buffers_() override;
228 void pre_run_hook() override;
229 void update( const Time&, const long, const long ) override;
230
231 // END Boilerplate function declarations ----------------------------
232
233 // Friends --------------------------------------------------------
234
235 // make dynamics function quasi-member
236 friend int aeif_psc_exp_dynamics( double, const double*, double*, void* );
237
238 // The next two classes need to be friends to access the State_ class/member
239 friend class RecordablesMap< aeif_psc_exp >;
240 friend class UniversalDataLogger< aeif_psc_exp >;
241
242private:
243 // ----------------------------------------------------------------
244
246 struct Parameters_
247 {
248 double V_peak_;
249 double V_reset_;
250 double t_ref_;
251
252 double g_L;
253 double C_m;
254 double E_L;
255 double Delta_T;
256 double tau_w;
257 double a;
258 double b;
259 double V_th;
260 double tau_syn_ex;
261 double tau_syn_in;
262 double I_e;
263
264 double gsl_error_tol;
265
266 Parameters_();
267
268 void get( Dictionary& ) const;
269 void set( const Dictionary&, Node* node );
270 };
271
272public:
273 // ----------------------------------------------------------------
274
279 struct State_
280 {
287 enum StateVecElems
288 {
289 V_M = 0,
290 I_EXC, // 1
291 I_INH, // 2
292 W, // 3
293 STATE_VEC_SIZE
294 };
295
297 double y_[ STATE_VEC_SIZE ];
298 unsigned int r_;
299
300 State_( const Parameters_& );
301 State_( const State_& );
302
303 State_& operator=( const State_& );
304
305 void get( Dictionary& ) const;
306 void set( const Dictionary&, const Parameters_&, Node* );
307 };
308
309 // ----------------------------------------------------------------
310
314 struct Buffers_
315 {
316 Buffers_( aeif_psc_exp& );
317 Buffers_( const Buffers_&, aeif_psc_exp& );
318
320 UniversalDataLogger< aeif_psc_exp > logger_;
321
323 RingBuffer spike_exc_;
324 RingBuffer spike_inh_;
325 RingBuffer currents_;
326
328 gsl_odeiv_step* s_;
329 gsl_odeiv_control* c_;
330 gsl_odeiv_evolve* e_;
331 gsl_odeiv_system sys_;
332
333 // Since IntegrationStep_ is initialized with step_, and the resolution
334 // cannot change after nodes have been created, it is safe to place both
335 // here.
336 double step_;
337 double IntegrationStep_;
338
346 double I_stim_;
347 };
348
349 // ----------------------------------------------------------------
350
354 struct Variables_
355 {
360 double V_peak;
361
362 unsigned int refractory_counts_;
363 };
364
365 // Access functions for UniversalDataLogger -------------------------------
366
368 template < State_::StateVecElems elem >
369 double
370 get_y_elem_() const
371 {
372 return S_.y_[ elem ];
373 }
374
375 // ----------------------------------------------------------------
376
377 Parameters_ P_;
378 State_ S_;
379 Variables_ V_;
380 Buffers_ B_;
381
383 static RecordablesMap< aeif_psc_exp > recordablesMap_;
384};
385
386inline size_t
387aeif_psc_exp::send_test_event( Node& target, size_t receptor_type, synindex, bool )
388{
390 e.set_sender( *this );
391
392 return target.handles_test_event( e, receptor_type );
393}
394
395inline size_t
396aeif_psc_exp::handles_test_event( SpikeEvent&, size_t receptor_type )
397{
398 if ( receptor_type != 0 )
399 {
400 throw UnknownReceptorType( receptor_type, get_name() );
401 }
402 return 0;
403}
404
405inline size_t
406aeif_psc_exp::handles_test_event( CurrentEvent&, size_t receptor_type )
407{
408 if ( receptor_type != 0 )
409 {
410 throw UnknownReceptorType( receptor_type, get_name() );
411 }
412 return 0;
413}
414
415inline size_t
416aeif_psc_exp::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
417{
418 if ( receptor_type != 0 )
419 {
420 throw UnknownReceptorType( receptor_type, get_name() );
421 }
422 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
423}
424
425inline void
426aeif_psc_exp::get_status( Dictionary& d ) const
427{
428 P_.get( d );
429 S_.get( d );
431
432 d[ names::recordables ] = recordablesMap_.get_list();
433}
434
435inline void
436aeif_psc_exp::set_status( const Dictionary& d )
437{
438 Parameters_ ptmp = P_; // temporary copy in case of errors
439 ptmp.set( d, this ); // throws if BadProperty
440 State_ stmp = S_; // temporary copy in case of errors
441 stmp.set( d, ptmp, this ); // throws if BadProperty
442
443 // We now know that (ptmp, stmp) are consistent. We do not
444 // write them back to (P_, S_) before we are also sure that
445 // the properties to be set in the parent class are internally
446 // consistent.
448
449 // if we get here, temporaries contain consistent set of properties
450 P_ = ptmp;
451 S_ = stmp;
452}
453
454} // namespace
455
456#endif // HAVE_GSL
457#endif // AEIF_PSC_EXP_H
A node which archives spike history for the purposes of spike-timing dependent plasticity (STDP).
Definition archiving_node.h:49
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition archiving_node.cpp:249
void set_status(const Dictionary &d) override
Change properties of the node according to the entries in the dictionary.
Definition archiving_node.cpp:265
Event for electrical currents.
Definition event.h:608
Request data to be logged/logged data to be sent.
Definition event.h:675
Base class for all NEST network objects.
Definition node.h:99
Event for spike information.
Definition event.h:420
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
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
RecordablesMap< binary_neuron< TGainfunction > > binary_neuron< TGainfunction >::recordablesMap_
Definition binary_neuron.h:319
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121
const double e
Definition numerics.cpp:32