NEST main@caf0ae8
 
Loading...
Searching...
No Matches
dc_generator.h
Go to the documentation of this file.
1/*
2 * dc_generator.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
24#ifndef DC_GENERATOR_H
25#define DC_GENERATOR_H
26
27// C++ includes:
28#include <vector>
29
30// Includes from nestkernel:
31#include "connection.h"
32#include "device_node.h"
33#include "event.h"
34#include "nest_types.h"
35#include "ring_buffer.h"
36#include "stimulation_device.h"
38
39namespace nest
40{
41
42/* BeginUserDocs: device, generator
43
44Short description
45+++++++++++++++++
46
47Provide a direct current (DC) input
48
49Description
50+++++++++++
51
52The ``dc_generator`` provides a constant DC input to the connected
53node. The unit of the current is pA.
54
55The ``dc_generator`` is rather inefficient, since it needs to send the
56same current information on each time step. If you only need a
57constant bias current into a neuron, you could instead directly set
58the property ``I_e``, which is available in many neuron models.
59
60.. include:: ../models/stimulation_device.rst
61
62amplitude
63 Amplitude of current (pA)
64
65Set parameters from a stimulation backend
66~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67
68The parameters in this stimulation device can be updated with input
69coming from a stimulation backend. The data structure used for the
70update holds one value for each of the parameters mentioned above.
71The indexing is as follows:
72
73 0. amplitude
74
75Sends
76+++++
77
78CurrentEvent
79
80See also
81++++++++
82
83ac_generator, noise_generator, step_current_generator
84
85Examples using this model
86+++++++++++++++++++++++++
87
88.. listexamples:: dc_generator
89
90EndUserDocs */
91
92void register_dc_generator( const std::string& name );
93
95{
96
97public:
99 dc_generator( const dc_generator& );
100
102 bool local_receiver() const override;
103
104 size_t send_test_event( Node&, size_t, synindex, bool ) override;
105
106 using Node::handle;
108
109 void handle( DataLoggingRequest& ) override;
110
111 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
112
113 void get_status( Dictionary& ) const override;
114 void set_status( const Dictionary& ) override;
115
116 StimulationDevice::Type get_type() const override;
117
118 void set_data_from_stimulation_backend( std::vector< double >& input_param ) override;
119
120private:
121 void init_state_() override;
122 void init_buffers_() override;
123 void pre_run_hook() override;
124
125 void update( Time const&, const long, const long ) override;
126
127 // ------------------------------------------------------------
128
133 {
134 double amp_;
135
136 Parameters_();
137 Parameters_( const Parameters_& );
138 Parameters_& operator=( const Parameters_& p );
139
140 void get( Dictionary& ) const;
141 void set( const Dictionary&, Node* node );
142 };
143
144 // ------------------------------------------------------------
145
146 struct State_
147 {
148 double I_;
150
151 State_();
152 };
153
154 // ------------------------------------------------------------
155
156 // The next two classes need to be friends to access the State_ class/member
157 friend class RecordablesMap< dc_generator >;
158 friend class UniversalDataLogger< dc_generator >;
159
160 // ------------------------------------------------------------
161
171
172 // ------------------------------------------------------------
173
174 double
175 get_I_() const
176 {
177 return S_.I_;
178 }
179
180 // ------------------------------------------------------------
181
186};
187
188inline size_t
189dc_generator::send_test_event( Node& target, size_t receptor_type, synindex syn_id, bool )
190{
192
193 CurrentEvent e;
194 e.set_sender( *this );
195
196 return target.handles_test_event( e, receptor_type );
197}
198
199inline size_t
201{
202 if ( receptor_type != 0 )
203 {
204 throw UnknownReceptorType( receptor_type, get_name() );
205 }
206 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
207}
208
209inline void
211{
212 P_.get( d );
214
215 d[ names::recordables ] = recordablesMap_.get_list();
216}
217
218inline void
220{
221 Parameters_ ptmp = P_; // temporary copy in case of errors
222 ptmp.set( d, this ); // throws if BadProperty
223
224 // We now know that ptmp is consistent. We do not write it back
225 // to P_ before we are also sure that the properties to be set
226 // in the parent class are internally consistent.
228
229 // if we get here, temporaries contain consistent set of properties
230 P_ = ptmp;
231}
232
233inline bool
235{
236 return true;
237}
238
244
245} // namespace
246
247#endif /* #ifndef DC_GENERATOR_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Event for electrical currents.
Definition event.h:569
Request data to be logged/logged data to be sent.
Definition event.h:636
Base class for all NEST network objects.
Definition node.h:99
std::string get_name() const
Return class name.
Definition node.cpp:105
Map names of recordables to data access functions.
Definition recordables_map.h:61
Base class for common properties of StimulationDevices.
Definition stimulation_device.h:154
void enforce_single_syn_type(synindex)
Throws IllegalConnection if synapse id differs from initial synapse id.
Definition stimulation_device.cpp:62
Type
Device type.
Definition stimulation_device.h:187
@ CURRENT_GENERATOR
Definition stimulation_device.h:188
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition stimulation_device.cpp:125
void get_status(Dictionary &d) const override
Export properties of the node by setting entries in the status dictionary.
Definition stimulation_device.cpp:168
Definition nest_time.h:135
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Definition dc_generator.h:95
size_t handles_test_event(DataLoggingRequest &, size_t) override
Definition dc_generator.h:200
void init_state_() override
Configure state variables depending on runtime information.
Definition dc_generator.cpp:138
dc_generator()
Definition dc_generator.cpp:116
Buffers_ B_
Definition dc_generator.h:185
void handle(DataLoggingRequest &) override
Handler for universal data logging request.
Definition dc_generator.cpp:183
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition dc_generator.h:210
StimulationDevice::Type get_type() const override
Definition dc_generator.h:240
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition dc_generator.cpp:164
void set_data_from_stimulation_backend(std::vector< double > &input_param) override
Definition dc_generator.cpp:189
static RecordablesMap< dc_generator > recordablesMap_
Definition dc_generator.h:182
State_ S_
Definition dc_generator.h:184
void init_buffers_() override
Configure persistent internal data structures.
Definition dc_generator.cpp:144
bool local_receiver() const override
Allow multimeter to connect to local instances.
Definition dc_generator.h:234
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition dc_generator.cpp:151
Parameters_ P_
Definition dc_generator.h:183
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition dc_generator.h:189
double get_I_() const
Definition dc_generator.h:175
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition dc_generator.h:219
friend class UniversalDataLogger< dc_generator >
Definition dc_generator.h:158
virtual size_t handles_test_event(SpikeEvent &, size_t receptor_type)
Check if the node can handle a particular event and receptor type.
Definition node.cpp:271
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:265
const std::string recordables("recordables")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_dc_generator(const std::string &name)
Definition dc_generator.cpp:38
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Buffers of the model.
Definition dc_generator.h:166
UniversalDataLogger< dc_generator > logger_
Definition dc_generator.h:169
Store independent parameters of the model.
Definition dc_generator.h:133
double amp_
stimulation amplitude, in pA
Definition dc_generator.h:134
void get(Dictionary &) const
Store current values in dictionary.
Definition dc_generator.cpp:100
void set(const Dictionary &, Node *node)
Set values from dictionary.
Definition dc_generator.cpp:106
Parameters_()
Sets default parameter values.
Definition dc_generator.cpp:56
Parameters_ & operator=(const Parameters_ &p)
Definition dc_generator.cpp:67
Definition dc_generator.h:147
State_()
Sets default parameter values.
Definition dc_generator.cpp:79
double I_
Instantaneous current value; used for recording current Required to handle current values when device...
Definition dc_generator.h:148