NEST main@caf0ae8
 
Loading...
Searching...
No Matches
ac_generator.h
Go to the documentation of this file.
1/*
2 * ac_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#ifndef AC_GENERATOR_H
24#define AC_GENERATOR_H
25
26// Includes from nestkernel:
27#include "connection.h"
28#include "device_node.h"
29#include "event.h"
30#include "nest_types.h"
31#include "stimulation_device.h"
33
34/* BeginUserDocs: device, generator
35
36Short description
37+++++++++++++++++
38
39Produce an alternating current (AC) input
40
41Description
42+++++++++++
43
44This device produces an AC input sent by CurrentEvents. The
45current is given by
46
47.. math::
48
49 I(t) = \mathrm{offset} + \mathrm{amplitude} \cdot \sin ( \omega t + \phi )
50
51where
52
53.. math::
54
55 \omega = 2 \pi \cdot \mathrm{frequency} \\
56 \phi = \frac{\mathrm{phase}}{180} \cdot \pi
57
58.. include:: ../models/stimulation_device.rst
59
60amplitude
61 Amplitude of sine current (pA)
62
63offset
64 Constant amplitude offset (pA)
65
66frequency
67 Frequency (Hz)
68
69phase
70 Phase of sine current (0-360 deg)
71
72Setting `start` and `stop` only windows the current as defined above. It
73does not shift the time axis.
74
75See also :footcite:p:`Rotter1999`.
76
77Set parameters from a stimulation backend
78~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
80The parameters in this stimulation device can be updated with input
81coming from a stimulation backend. The data structure used for the
82update holds one value for each of the parameters mentioned above.
83The indexing is as follows:
84
85 0. amplitude
86 1. offset
87 2. frequency
88 3. phase
89
90References
91++++++++++
92
93.. footbibliography::
94
95Sends
96+++++
97
98CurrentEvent
99
100See also
101++++++++
102
103dc_generator, noise_generator, step_current_generator, StimulationDevice,
104Device
105
106Examples using this model
107+++++++++++++++++++++++++
108
109.. listexamples:: ac_generator
110
111EndUserDocs */
112
113namespace nest
114{
115void register_ac_generator( const std::string& name );
116
118{
119
120public:
121 ac_generator();
122 ac_generator( const ac_generator& );
123
125 bool local_receiver() const override;
126
127 size_t send_test_event( Node&, size_t, synindex, bool ) override;
128
129 using Node::handle;
131
132 void handle( DataLoggingRequest& ) override;
133
134 size_t handles_test_event( DataLoggingRequest&, size_t ) override;
135
136 void get_status( Dictionary& ) const override;
137 void set_status( const Dictionary& ) override;
138
139 StimulationDevice::Type get_type() const override;
140 void set_data_from_stimulation_backend( std::vector< double >& input_param ) override;
141
142private:
143 void init_state_() override;
144 void init_buffers_() override;
145 void pre_run_hook() override;
146
147 void update( Time const&, const long, const long ) override;
148
149
150 // ------------------------------------------------------------
151
153 {
154 double amp_;
155 double offset_;
156 double freq_;
157 double phi_deg_;
158
159 Parameters_();
160 Parameters_( const Parameters_& );
161 Parameters_& operator=( const Parameters_& p );
162
163 void get( Dictionary& ) const;
164 void set( const Dictionary&, Node* node );
165 };
166
167 // ------------------------------------------------------------
168
169 struct State_
170 {
171 double y_0_;
172 double y_1_;
173 double I_;
175
176 State_();
177
178 void get( Dictionary& ) const;
179 };
180
181 // ------------------------------------------------------------
182
183 // The next two classes need to be friends to access the State_ class/member
184 friend class RecordablesMap< ac_generator >;
185 friend class UniversalDataLogger< ac_generator >;
186
187 // ------------------------------------------------------------
188
198
199 // ------------------------------------------------------------
200
202 {
203 // The exact integration matrix
204 double A_00_;
205 double A_01_;
206 double A_10_;
207 double A_11_;
208 };
209
210 double
211 get_I_() const
212 {
213 return S_.I_;
214 }
215
216 // ------------------------------------------------------------
217
223};
224
225inline size_t
226ac_generator::send_test_event( Node& target, size_t receptor_type, synindex syn_id, bool )
227{
229
230 CurrentEvent e;
231 e.set_sender( *this );
232
233 return target.handles_test_event( e, receptor_type );
234}
235
236inline size_t
238{
239 if ( receptor_type != 0 )
240 {
241 throw UnknownReceptorType( receptor_type, get_name() );
242 }
243 return B_.logger_.connect_logging_device( dlr, recordablesMap_ );
244}
245
246inline void
248{
249 P_.get( d );
250 S_.get( d );
252
253 d[ names::recordables ] = recordablesMap_.get_list();
254}
255
256inline void
258{
259 Parameters_ ptmp = P_; // temporary copy in case of errors
260 ptmp.set( d, this ); // throws if BadProperty
261
262 // State_ is read-only
263
264 // We now know that ptmp is consistent. We do not write it back
265 // to P_ before we are also sure that the properties to be set
266 // in the parent class are internally consistent.
268
269 // if we get here, temporaries contain consistent set of properties
270 P_ = ptmp;
271}
272
273inline bool
275{
276 return true;
277}
278
284
285} // namespace
286
287#endif // AC_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 ac_generator.h:118
void set_data_from_stimulation_backend(std::vector< double > &input_param) override
Definition ac_generator.cpp:239
void init_buffers_() override
Configure persistent internal data structures.
Definition ac_generator.cpp:172
Buffers_ B_
Definition ac_generator.h:222
void init_state_() override
Configure state variables depending on runtime information.
Definition ac_generator.cpp:166
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition ac_generator.cpp:204
State_ S_
Definition ac_generator.h:220
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition ac_generator.h:247
double get_I_() const
Definition ac_generator.h:211
Variables_ V_
Definition ac_generator.h:221
size_t handles_test_event(DataLoggingRequest &, size_t) override
Definition ac_generator.h:237
ac_generator()
Definition ac_generator.cpp:143
static RecordablesMap< ac_generator > recordablesMap_
Definition ac_generator.h:218
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition ac_generator.h:257
StimulationDevice::Type get_type() const override
Definition ac_generator.h:280
bool local_receiver() const override
Allow multimeter to connect to local instances.
Definition ac_generator.h:274
Parameters_ P_
Definition ac_generator.h:219
size_t send_test_event(Node &, size_t, synindex, bool) override
Send an event to the receiving_node passed as an argument.
Definition ac_generator.h:226
void pre_run_hook() override
Re-calculate dependent parameters of the node.
Definition ac_generator.cpp:179
friend class UniversalDataLogger< ac_generator >
Definition ac_generator.h:185
void handle(DataLoggingRequest &) override
Handler for universal data logging request.
Definition ac_generator.cpp:229
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_ac_generator(const std::string &name)
Definition ac_generator.cpp:42
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Buffers of the model.
Definition ac_generator.h:193
UniversalDataLogger< ac_generator > logger_
Definition ac_generator.h:196
Definition ac_generator.h:153
double freq_
Standard frequency in Hz.
Definition ac_generator.h:156
Parameters_()
Sets default parameter values.
Definition ac_generator.cpp:60
double offset_
Offset of sine-current.
Definition ac_generator.h:155
double phi_deg_
Phase of sine current (0-360 deg)
Definition ac_generator.h:157
void get(Dictionary &) const
Store current values in Dictionary.
Definition ac_generator.cpp:114
double amp_
Amplitude of sine-current.
Definition ac_generator.h:154
Parameters_ & operator=(const Parameters_ &p)
Definition ac_generator.cpp:77
void set(const Dictionary &, Node *node)
Set values from Dictionary.
Definition ac_generator.cpp:130
Definition ac_generator.h:170
State_()
Sets default parameter values.
Definition ac_generator.cpp:92
double I_
Instantaneous current value; used for recording current Required to handle current values when device...
Definition ac_generator.h:173
void get(Dictionary &) const
Store current values in Dictionary.
Definition ac_generator.cpp:123
double y_0_
Definition ac_generator.h:171
double y_1_
Definition ac_generator.h:172
Definition ac_generator.h:202
double A_01_
Definition ac_generator.h:205
double A_10_
Definition ac_generator.h:206
double A_11_
Definition ac_generator.h:207
double A_00_
Definition ac_generator.h:204