NEST  2.6.0,not_revisioned_source_dir@0
aeif_cond_alpha_RK5.h
Go to the documentation of this file.
1 /*
2  * aeif_cond_alpha_RK5.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_COND_ALPHA_RK5_H
24 #define AEIF_COND_ALPHA_RK5_H
25 
26 #include "nest.h"
27 #include "event.h"
28 #include "archiving_node.h"
29 #include "ring_buffer.h"
30 #include "connection.h"
31 #include "universal_data_logger.h"
32 
33 /* BeginDocumentation
34 Name: aeif_cond_alpha_RK5 - Conductance based exponential integrate-and-fire neuron model according to Brette and Gerstner (2005).
35 
36 Description:
37 aeif_cond_alpha_RK5 is the adaptive exponential integrate and fire neuron according to Brette and Gerstner (2005).
38 Synaptic conductances are modelled as alpha-functions.
39 
40 This implementation uses a 5th order Runge-Kutta solver with adaptive stepsize to integrate
41 the differential equation (see Numerical Recipes 3rd Edition, Press et al. 2007, Ch. 17.2).
42 
43 The membrane potential is given by the following differential equation:
44 C dV/dt= -g_L(V-E_L)+g_L*Delta_T*exp((V-V_T)/Delta_T)-g_e(t)(V-E_e) -g_i(t)(V-E_i)-w +I_e
45 
46 and
47 
48 tau_w * dw/dt= a(V-E_L) -w
49 
50 Parameters:
51 The following parameters can be set in the status dictionary.
52 
53 Dynamic state variables:
54  V_m double - Membrane potential in mV
55  g_ex double - Excitatory synaptic conductance in nS.
56  dg_ex double - First derivative of g_ex in nS/ms
57  g_in double - Inhibitory synaptic conductance in nS.
58  dg_in double - First derivative of g_in in nS/ms.
59  w double - Spike-adaptation current in pA.
60 
61 Membrane Parameters:
62  C_m double - Capacity of the membrane in pF
63  t_ref double - Duration of refractory period in ms.
64  V_reset double - Reset value for V_m after a spike. In mV.
65  E_L double - Leak reversal potential in mV.
66  g_L double - Leak conductance in nS.
67  I_e double - Constant external input current in pA.
68 
69 Spike adaptation parameters:
70  a double - Subthreshold adaptation in nS.
71  b double - Spike-triggered adaptation in pA.
72  Delta_T double - Slope factor in mV
73  tau_w double - Adaptation time constant in ms
74  V_th double - Spike initiation threshold in mV
75  V_peak double - Spike detection threshold in mV.
76 
77 Synaptic parameters:
78  E_ex double - Excitatory reversal potential in mV.
79  tau_syn_ex double - Rise time of excitatory synaptic conductance in ms (alpha function).
80  E_in double - Inhibitory reversal potential in mV.
81  tau_syn_in double - Rise time of the inhibitory synaptic conductance in ms (alpha function).
82 
83 Numerical integration parameters:
84  HMIN double - Minimal stepsize for numerical integration in ms (default 0.001ms).
85  MAXERR double - Error estimate tolerance for adaptive stepsize control (steps accepted if err<=MAXERR). In mV.
86  Note that the error refers to the difference between the 4th and 5th order RK terms.
87  Default 1e-10 mV.
88 
89 Authors: Stefan Bucher, Marc-Oliver Gewaltig.
90 
91 Sends: SpikeEvent
92 
93 Receives: SpikeEvent, CurrentEvent, DataLoggingRequest
94 
95 References: Brette R and Gerstner W (2005) Adaptive Exponential Integrate-and-Fire Model as
96  an Effective Description of Neuronal Activity. J Neurophysiol 94:3637-3642
97 
98 SeeAlso: iaf_cond_alpha, aeif_cond_exp, aeif_cond_alpha
99 */
100 
101 namespace nest
102 {
103 
105  public Archiving_Node
106  {
107 
108  public:
112 
117  using Node::handle;
119 
121 
122  void handle(SpikeEvent &);
123  void handle(CurrentEvent &);
124  void handle(DataLoggingRequest &);
125 
129 
130  void get_status(DictionaryDatum &) const;
131  void set_status(const DictionaryDatum &);
132 
133  private:
134 
135  void init_state_(const Node& proto);
136  void init_buffers_();
137  void calibrate();
138 
139  void update(Time const &, const long_t, const long_t);
140 
141  inline
142  void aeif_cond_alpha_RK5_dynamics (const double*, double*);
143 
144  // END Boilerplate function declarations ----------------------------
145 
146  // Friends --------------------------------------------------------
147 
148  // The next two classes need to be friends to access the State_ class/member
150  friend class UniversalDataLogger<aeif_cond_alpha_RK5>;
151 
152 
153  private:
154  // ----------------------------------------------------------------
155 
157  struct Parameters_ {
161 
178  Parameters_();
179 
180  void get(DictionaryDatum&) const;
181  void set(const DictionaryDatum&);
182  };
183 
184  public:
185  // ----------------------------------------------------------------
186 
192  struct State_
193  {
201  {
202  V_M = 0,
203  DG_EXC , // 1
204  G_EXC , // 2
205  DG_INH , // 3
206  G_INH , // 4
207  W , // 5
209  };
210 
223 
224  State_(const Parameters_&);
225  State_(const State_&);
226  State_& operator=(const State_&);
227 
228  void get(DictionaryDatum&) const;
229  void set(const DictionaryDatum&, const Parameters_&);
230  };
231 
232  // ----------------------------------------------------------------
233 
237  struct Buffers_ {
240 
243 
248 
249  // IntergrationStep_ should be reset with the neuron on ResetNetwork,
250  // but remain unchanged during calibration. Since it is initialized with
251  // step_, and the resolution cannot change after nodes have been created,
252  // it is safe to place both here.
255 
264  };
265 
266  // ----------------------------------------------------------------
267 
271  struct Variables_ {
274 
277 
279  };
280 
281  // Access functions for UniversalDataLogger -------------------------------
282 
284  template <State_::StateVecElems elem>
285  double_t get_y_elem_() const { return S_.y_[elem]; }
286 
287  // ----------------------------------------------------------------
288 
293 
296  };
297 
298  inline
300  {
301  SpikeEvent e;
302  e.set_sender(*this);
303 
304  return target.handles_test_event(e, receptor_type);
305  }
306 
307  inline
309  {
310  if (receptor_type != 0)
311  throw UnknownReceptorType(receptor_type, get_name());
312  return 0;
313  }
314 
315  inline
317  {
318  if (receptor_type != 0)
319  throw UnknownReceptorType(receptor_type, get_name());
320  return 0;
321  }
322 
323  inline
326  {
327  if (receptor_type != 0)
328  throw UnknownReceptorType(receptor_type, get_name());
329  return B_.logger_.connect_logging_device(dlr, recordablesMap_);
330  }
331 
332  inline
334  {
335  P_.get(d);
336  S_.get(d);
338 
339  (*d)[names::recordables] = recordablesMap_.get_list();
340  }
341 
342  inline
344  {
345  Parameters_ ptmp = P_; // temporary copy in case of errors
346  ptmp.set(d); // throws if BadProperty
347  State_ stmp = S_; // temporary copy in case of errors
348  stmp.set(d, ptmp); // throws if BadProperty
349 
350  // We now know that (ptmp, stmp) are consistent. We do not
351  // write them back to (P_, S_) before we are also sure that
352  // the properties to be set in the parent class are internally
353  // consistent.
355 
356  // if we get here, temporaries contain consistent set of properties
357  P_ = ptmp;
358  S_ = stmp;
359  }
360 
366 inline
367 void aeif_cond_alpha_RK5::aeif_cond_alpha_RK5_dynamics (const double y[], double f[])
368 {
369  // a shorthand
371 
372  // y[] is the current internal state of the integrator (yin), not the state vector in the node, node.S_.y[].
373 
374  // The following code is verbose for the sake of clarity. We assume that a
375  // good compiler will optimize the verbosity away ...
376 
377  // This constant is used below as the largest admissible value for the exponential spike upstroke
378  static const double_t largest_exp=std::exp(10.);
379 
380  // shorthand for state variables
381  const double_t& V = y[S::V_M];
382  const double_t& dg_ex = y[S::DG_EXC];
383  const double_t& g_ex = y[S::G_EXC ];
384  const double_t& dg_in = y[S::DG_INH];
385  const double_t& g_in = y[S::G_INH ];
386  const double_t& w = y[S::W];
387 
388  const double_t I_syn_exc = g_ex * (V - P_.E_ex);
389  const double_t I_syn_inh = g_in * (V - P_.E_in);
390 
391  // We pre-compute the argument of the exponential
392  const double_t exp_arg=(V - P_.V_th) / P_.Delta_T;
393  // If the argument is too large, we clip it.
394  const double_t I_spike = (exp_arg>10.)? largest_exp : P_.Delta_T * std::exp(exp_arg);
395 
396  // dv/dt
397  f[S::V_M ] = ( -P_.g_L *( (V-P_.E_L) - I_spike )
398  - I_syn_exc - I_syn_inh - w + P_.I_e + B_.I_stim_) / P_.C_m;
399  f[S::DG_EXC] = -dg_ex / P_.tau_syn_ex;
400  f[S::G_EXC ] = dg_ex - g_ex / P_.tau_syn_ex; // Synaptic Conductance (nS)
401 
402  f[S::DG_INH] = -dg_in / P_.tau_syn_in;
403  f[S::G_INH ] = dg_in - g_in / P_.tau_syn_in; // Synaptic Conductance (nS)
404 
405  // Adaptation current w.
406  f[S::W ] = ( P_.a * (V - P_.E_L) - w ) / P_.tau_w;
407 }
408 
409 
410 } // namespace
411 
412 #endif //AEIF_COND_ALPHA_RK5_H
const Name recordables("recordables")
List of recordable state data (Device parameters)
Definition: nest_names.h:244
Definition: aeif_cond_alpha_RK5.h:203
int int_t
Integer number with at least 16 bit.
Definition: nest.h:95
Definition of Archiving_Node which is capable of recording and managing a spike history.
double_t get_y_elem_() const
Read out state vector elements, used by UniversalDataLogger.
Definition: aeif_cond_alpha_RK5.h:285
const Name receptor_type("receptor_type")
Connection parameters.
Definition: nest_names.h:240
void update(Time const &, const long_t, const long_t)
Member function updating the neuron state by integrating the ODE.
Definition: aeif_cond_alpha_RK5.cpp:312
aeif_cond_alpha_RK5()
Definition: aeif_cond_alpha_RK5.cpp:244
double_t k1[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:212
Definition: aeif_cond_alpha_RK5.h:206
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
double_t MAXERR
Maximal error for adaptive stepsize solver.
Definition: aeif_cond_alpha_RK5.h:176
State variables of the model.
Definition: aeif_cond_alpha_RK5.h:192
Buffers_ B_
Definition: aeif_cond_alpha_RK5.h:292
Parameters_()
Sets default parameter values.
Definition: aeif_cond_alpha_RK5.cpp:71
Definition: aeif_cond_alpha_RK5.h:205
double_t t_ref
Refractory period in ms.
Definition: aeif_cond_alpha_RK5.h:172
void init_state_(const Node &proto)
Private function to initialize the state of a node to model defaults.
Definition: aeif_cond_alpha_RK5.cpp:269
void set_sender(Node &)
Change pointer to sending Node.
Definition: event.h:714
double_t k3[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:214
double_t E_in
Inhibitory reversal Potential in mV.
Definition: aeif_cond_alpha_RK5.h:165
State_ & operator=(const State_ &)
Definition: aeif_cond_alpha_RK5.cpp:108
double_t y_[STATE_VEC_SIZE]
neuron state
Definition: aeif_cond_alpha_RK5.h:211
double_t E_ex
Excitatory reversal Potential in mV.
Definition: aeif_cond_alpha_RK5.h:164
double_t yin[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:219
Event for electrical currents.
Definition: event.h:420
long_t rport
Connection port number to distinguish incoming connections, also called receiver port.
Definition: nest.h:147
double_t ynew[STATE_VEC_SIZE]
5th order update
Definition: aeif_cond_alpha_RK5.h:220
void init_buffers_()
Private function to initialize the buffers of a node.
Definition: aeif_cond_alpha_RK5.cpp:275
State_ S_
Definition: aeif_cond_alpha_RK5.h:290
const Name g_in("g_in")
inhibitory conductance
Definition: nest_names.h:147
Variables_ V_
Definition: aeif_cond_alpha_RK5.h:291
const Name g_ex("g_ex")
Excitatory conductance.
Definition: nest_names.h:146
Buffers_(aeif_cond_alpha_RK5 &)
Sets buffer pointers to 0.
Definition: aeif_cond_alpha_RK5.cpp:226
double_t k7[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:218
double_t tau_syn_in
Inhibitory synaptic rise time.
Definition: aeif_cond_alpha_RK5.h:174
~aeif_cond_alpha_RK5()
Definition: aeif_cond_alpha_RK5.cpp:261
double_t b
Spike-triggered adaptation in pA.
Definition: aeif_cond_alpha_RK5.h:170
double_t g0_ex_
initial value to normalise excitatory synaptic conductance
Definition: aeif_cond_alpha_RK5.h:273
void set_status(const DictionaryDatum &)
Definition: aeif_cond_alpha_RK5.h:343
Map names of recordables to data access functions.
Definition: recordables_map.h:58
const Name w("w")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:343
const Name dg_in("dg_in")
Derivative of the inhibitory conductance.
Definition: nest_names.h:98
const Name y("y")
Definition: topology_names.h:52
double_t tau_w
adaptation time-constant in ms.
Definition: aeif_cond_alpha_RK5.h:168
double_t E_L
Leak reversal Potential (aka resting potential) in mV.
Definition: aeif_cond_alpha_RK5.h:166
void get_status(DictionaryDatum &) const
Definition: aeif_cond_alpha_RK5.h:333
Definition: nest_time.h:130
double_t C_m
Membrane Capacitance in pF.
Definition: aeif_cond_alpha_RK5.h:163
State_(const Parameters_ &)
Default initialization.
Definition: aeif_cond_alpha_RK5.cpp:93
std::string get_name() const
Return class name.
Definition: node.cpp:83
int_t RefractoryCounts_
Definition: aeif_cond_alpha_RK5.h:278
friend class UniversalDataLogger< aeif_cond_alpha_RK5 >
Definition: aeif_cond_alpha_RK5.h:150
double_t t_ref_
Refractory period in ms.
Definition: aeif_cond_alpha_RK5.h:160
double_t Delta_T
Slope faktor in ms.
Definition: aeif_cond_alpha_RK5.h:167
const Name dg_ex("dg_ex")
Derivative of the excitatory conductance.
Definition: nest_names.h:97
void set(const DictionaryDatum &)
Set values from dicitonary.
Definition: aeif_cond_alpha_RK5.cpp:145
const Name S("S")
Binary state (output) of neuron (Ginzburg neuron)
Definition: nest_names.h:255
void set_status(const DictionaryDatum &d)
Definition: archiving_node.cpp:185
int_t r_
number of refractory steps remaining
Definition: aeif_cond_alpha_RK5.h:222
Definition: aeif_cond_alpha_RK5.h:207
port send_test_event(Node &, rport, synindex, bool)
Send an event to the receiving_node passed as an argument.
Definition: aeif_cond_alpha_RK5.h:299
Exception to be thrown if the specified receptor type does not exist in the node. ...
Definition: exceptions.h:254
void get(DictionaryDatum &) const
Store current values in dictionary.
Definition: aeif_cond_alpha_RK5.cpp:122
const Name target("target")
Connection parameters.
Definition: nest_names.h:282
Definition: aeif_cond_alpha_RK5.h:204
Definition: aeif_cond_alpha_RK5.h:104
void aeif_cond_alpha_RK5_dynamics(const double *, double *)
Function computing right-hand side of ODE for the ODE solver.
Definition: aeif_cond_alpha_RK5.h:367
void handle(SpikeEvent &)
Handle incoming spike events.
Definition: aeif_cond_alpha_RK5.cpp:483
double_t I_stim_
Input current injected by CurrentEvent.
Definition: aeif_cond_alpha_RK5.h:263
Independent parameters.
Definition: aeif_cond_alpha_RK5.h:157
double_t k5[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:216
static RecordablesMap< aeif_cond_alpha_RK5 > recordablesMap_
Mapping of recordables names to access functions.
Definition: aeif_cond_alpha_RK5.h:295
double_t tau_syn_ex
Excitatory synaptic rise time.
Definition: aeif_cond_alpha_RK5.h:173
RingBuffer spike_inh_
Definition: aeif_cond_alpha_RK5.h:246
a node which archives spike history for the purposes of timing dependent plasticity ...
Definition: archiving_node.h:50
double_t V_peak_
Spike detection threshold in mV.
Definition: aeif_cond_alpha_RK5.h:158
double_t yref[STATE_VEC_SIZE]
4th order update
Definition: aeif_cond_alpha_RK5.h:221
long_t port
Connection port number to distinguis outgoing connections.
Definition: nest.h:155
RingBuffer currents_
Definition: aeif_cond_alpha_RK5.h:247
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition: node.cpp:198
double double_t
Double precision floating point numbers.
Definition: nest.h:93
Definition: aeif_cond_alpha_RK5.h:208
double_t k6[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:217
virtual port handles_test_event(SpikeEvent &, rport receptor_type)
Check if the node can handle a particular event and receptor type.
Definition: node.cpp:203
void set(const DictionaryDatum &, const Parameters_ &)
Definition: aeif_cond_alpha_RK5.cpp:213
Request data to be logged/logged data to be sent.
Definition: event.h:486
RingBuffer spike_exc_
buffers and sums up incoming spikes/currents
Definition: aeif_cond_alpha_RK5.h:245
unsigned char synindex
Unsigned char type for enumerations of synapse types.
Definition: nest.h:115
double_t g_L
Leak Conductance in nS.
Definition: aeif_cond_alpha_RK5.h:162
void get(DictionaryDatum &) const
Definition: aeif_cond_alpha_RK5.cpp:203
Default types used by the NEST kernel.
Buffers of the model.
Definition: aeif_cond_alpha_RK5.h:237
void get_status(DictionaryDatum &d) const
Definition: archiving_node.cpp:175
port handles_test_event(SpikeEvent &, rport)
Check if the node can handle a particular event and receptor type.
Definition: aeif_cond_alpha_RK5.h:308
Event for spike information.
Definition: event.h:320
StateVecElems
Enumeration identifying elements in state array State_::y_.
Definition: aeif_cond_alpha_RK5.h:200
Base class for all NEST network objects.
Definition: node.h:96
Definition: aeif_cond_alpha_RK5.h:202
UniversalDataLogger< aeif_cond_alpha_RK5 > logger_
Logger for all analog data.
Definition: aeif_cond_alpha_RK5.h:242
double_t step_
simulation step size in ms
Definition: aeif_cond_alpha_RK5.h:253
double_t I_e
Intrinsic current in pA.
Definition: aeif_cond_alpha_RK5.h:175
Parameters_ P_
Definition: aeif_cond_alpha_RK5.h:289
double_t k4[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:215
Internal variables of the model.
Definition: aeif_cond_alpha_RK5.h:271
double_t V_th
Spike threshold in mV.
Definition: aeif_cond_alpha_RK5.h:171
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
double_t k2[STATE_VEC_SIZE]
Runge-Kutta variable.
Definition: aeif_cond_alpha_RK5.h:213
double_t HMIN
Smallest permissible stepsize in ms.
Definition: aeif_cond_alpha_RK5.h:177
const double e
Definition: numerics.cpp:62
double IntegrationStep_
current integration time step, updated by solver
Definition: aeif_cond_alpha_RK5.h:254
void calibrate()
Re-calculate dependent parameters of the node.
Definition: aeif_cond_alpha_RK5.cpp:292
double_t a
Subthreshold adaptation in nS.
Definition: aeif_cond_alpha_RK5.h:169
Buffer Layout.
Definition: ring_buffer.h:77
double_t g0_in_
initial value to normalise inhibitory synaptic conductance
Definition: aeif_cond_alpha_RK5.h:276
double_t V_reset_
Reset Potential in mV.
Definition: aeif_cond_alpha_RK5.h:159