NEST main@f146f75
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
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 dI_ex pA/ms First derivative of I_ex
126 I_in pA Inhibitory synaptic current
127 dI_in pA/ms First derivative of I_in
128 w pA Spike-adaptation current
129 g pA Spike-adaptation current
130======== ======= =======================================
131
132======== ======= =======================================
133**Membrane Parameters**
134--------------------------------------------------------
135 C_m pF Capacity of the membrane
136 t_ref ms Duration of refractory period
137 V_reset mV Reset value for V_m after a spike
138 E_L mV Leak reversal potential
139 g_L nS Leak conductance
140 I_e pA Constant external input current
141======== ======= =======================================
142
143======== ======= ==================================
144**Spike adaptation parameters**
145---------------------------------------------------
146 a nS Subthreshold adaptation
147 b pA Spike-triggered adaptation
148 Delta_T mV Slope factor
149 tau_w ms Adaptation time constant
150 V_th mV Spike initiation threshold
151 V_peak mV Spike detection threshold
152======== ======= ==================================
153
154=========== ======= ===========================================================
155**Synaptic parameters**
156-------------------------------------------------------------------------------
157 tau_syn_ex ms Rise time of excitatory synaptic conductance (alpha
158 function)
159 tau_syn_in ms Rise time of the inhibitory synaptic conductance
160 (alpha function)
161=========== ======= ===========================================================
162
163============= ======= =========================================================
164**Integration parameters**
165-------------------------------------------------------------------------------
166gsl_error_tol real This parameter controls the admissible error of the
167 GSL integrator. Reduce it if NEST complains about
168 numerical instabilities
169============= ======= =========================================================
170
171Sends
172+++++
173
174SpikeEvent
175
176Receives
177++++++++
178
179SpikeEvent, CurrentEvent, DataLoggingRequest
180
181References
182++++++++++
183
184.. footbibliography::
185
186See also
187++++++++
188
189iaf_psc_alpha, aeif_cond_exp
190
191Examples using this model
192+++++++++++++++++++++++++
193
194.. listexamples:: aeif_psc_alpha
195
196EndUserDocs */
197
198void register_aeif_psc_alpha( const std::string& name );
199
200class aeif_psc_alpha : public ArchivingNode
201{
202
203public:
204 aeif_psc_alpha();
205 aeif_psc_alpha( const aeif_psc_alpha& );
206 ~aeif_psc_alpha() override;
207
213 using Node::handle;
214 using Node::handles_test_event;
215
216 size_t send_test_event( Node&, size_t, synindex, bool ) override;
217
218 void handle( SpikeEvent& ) override;
219 void handle( CurrentEvent& ) override;
220 void handle( DataLoggingRequest& ) override;
221
222 size_t handles_test_event( SpikeEvent&, size_t ) override;
223 size_t handles_test_event( CurrentEvent&, size_t ) override;
224 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
225
226 void get_status( Dictionary& ) const override;
227 void set_status( const Dictionary& ) override;
228
229private:
230 void init_buffers_() override;
231 void pre_run_hook() override;
232 void update( Time const&, const long, const long ) override;
233
234 // END Boilerplate function declarations ----------------------------
235
236 // Friends --------------------------------------------------------
237
238 // make dynamics function quasi-member
239 friend int aeif_psc_alpha_dynamics( double, const double*, double*, void* );
240
241 // The next two classes need to be friends to access the State_ class/member
242 friend class RecordablesMap< aeif_psc_alpha >;
243 friend class UniversalDataLogger< aeif_psc_alpha >;
244
245private:
246 // ----------------------------------------------------------------
247
249 struct Parameters_
250 {
251 double V_peak_;
252 double V_reset_;
253 double t_ref_;
254
255 double g_L;
256 double C_m;
257 double E_L;
258 double Delta_T;
259 double tau_w;
260 double a;
261 double b;
262 double V_th;
263 double tau_syn_ex;
264 double tau_syn_in;
265 double I_e;
266
267 double gsl_error_tol;
268
269 Parameters_();
270
271 void get( Dictionary& ) const;
272 void set( const Dictionary&, Node* node );
273 };
274
275public:
276 // ----------------------------------------------------------------
277
282 struct State_
283 {
290 enum StateVecElems
291 {
292 V_M = 0,
293 DI_EXC, // 1
294 I_EXC, // 2
295 DI_INH, // 3
296 I_INH, // 4
297 W, // 5
298 STATE_VEC_SIZE
299 };
300
301 double y_[ STATE_VEC_SIZE ];
303 unsigned int r_;
304
305 State_( const Parameters_& );
306 State_( const State_& );
307
308 State_& operator=( const State_& );
309
310 void get( Dictionary& ) const;
311 void set( const Dictionary&, const Parameters_&, Node* );
312 };
313
314 // ----------------------------------------------------------------
315
319 struct Buffers_
320 {
321 Buffers_( aeif_psc_alpha& );
322 Buffers_( const Buffers_&, aeif_psc_alpha& );
323
325 UniversalDataLogger< aeif_psc_alpha > logger_;
326
328 RingBuffer spike_exc_;
329 RingBuffer spike_inh_;
330 RingBuffer currents_;
331
333 gsl_odeiv_step* s_;
334 gsl_odeiv_control* c_;
335 gsl_odeiv_evolve* e_;
336 gsl_odeiv_system sys_;
337
338 // Since IntegrationStep_ is initialized with step_, and the resolution
339 // cannot change after nodes have been created, it is safe to place both
340 // here.
341 double step_;
342 double IntegrationStep_;
343
351 double I_stim_;
352 };
353
354 // ----------------------------------------------------------------
355
359 struct Variables_
360 {
362 double i0_ex_;
363
365 double i0_in_;
366
371 double V_peak;
372
373 unsigned int refractory_counts_;
374 };
375
376 // Access functions for UniversalDataLogger -------------------------------
377
379 template < State_::StateVecElems elem >
380 double
381 get_y_elem_() const
382 {
383 return S_.y_[ elem ];
384 }
385
386 // ----------------------------------------------------------------
387
388 Parameters_ P_;
389 State_ S_;
390 Variables_ V_;
391 Buffers_ B_;
392
394 static RecordablesMap< aeif_psc_alpha > recordablesMap_;
395};
396
397inline size_t
398aeif_psc_alpha::send_test_event( Node& target, size_t receptor_type, synindex, bool )
399{
401 e.set_sender( *this );
402
403 return target.handles_test_event( e, receptor_type );
404}
405
406inline size_t
407aeif_psc_alpha::handles_test_event( SpikeEvent&, size_t receptor_type )
408{
409 if ( receptor_type != 0 )
410 {
411 throw UnknownReceptorType( receptor_type, get_name() );
412 }
413 return 0;
414}
415
416inline size_t
417aeif_psc_alpha::handles_test_event( CurrentEvent&, size_t receptor_type )
418{
419 if ( receptor_type != 0 )
420 {
421 throw UnknownReceptorType( receptor_type, get_name() );
422 }
423 return 0;
424}
425
426inline size_t
427aeif_psc_alpha::handles_test_event( DataLoggingRequest& dlr, size_t receptor_type )
428{
429 if ( receptor_type != 0 )
430 {
431 throw UnknownReceptorType( receptor_type, get_name() );
432 }
433 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
434}
435
436inline void
437aeif_psc_alpha::get_status( Dictionary& d ) const
438{
439 P_.get( d );
440 S_.get( d );
442
443 d[ names::recordables ] = recordablesMap_.get_list();
444}
445
446inline void
447aeif_psc_alpha::set_status( const Dictionary& d )
448{
449 Parameters_ ptmp = P_; // temporary copy in case of errors
450 ptmp.set( d, this ); // throws if BadProperty
451 State_ stmp = S_; // temporary copy in case of errors
452 stmp.set( d, ptmp, this ); // throws if BadProperty
453
454 // We now know that (ptmp, stmp) are consistent. We do not
455 // write them back to (P_, S_) before we are also sure that
456 // the properties to be set in the parent class are internally
457 // consistent.
459
460 // if we get here, temporaries contain consistent set of properties
461 P_ = ptmp;
462 S_ = stmp;
463}
464
465} // namespace
466
467#endif // HAVE_GSL
468#endif // AEIF_PSC_ALPHA_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