GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
currentSourceModels.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Standard includes
4 #include <array>
5 #include <functional>
6 #include <string>
7 #include <tuple>
8 #include <vector>
9 #include <cmath>
10 
11 // GeNN includes
12 #include "gennExport.h"
13 #include "models.h"
14 
15 //----------------------------------------------------------------------------
16 // Macros
17 //----------------------------------------------------------------------------
18 #define SET_INJECTION_CODE(INJECTION_CODE) virtual std::string getInjectionCode() const override{ return INJECTION_CODE; }
19 
20 //----------------------------------------------------------------------------
21 // CurrentSourceModels::Base
22 //----------------------------------------------------------------------------
24 {
27 {
28 public:
29  //----------------------------------------------------------------------------
30  // Declared virtuals
31  //----------------------------------------------------------------------------
33  virtual std::string getInjectionCode() const{ return ""; }
34 
35  //----------------------------------------------------------------------------
36  // Public API
37  //----------------------------------------------------------------------------
39  boost::uuids::detail::sha1::digest_type getHashDigest() const;
40 
42  void validate() const;
43 };
44 
45 //----------------------------------------------------------------------------
46 // CurrentSourceModels::DC
47 //----------------------------------------------------------------------------
49 
52 class DC : public Base
53 {
54  DECLARE_MODEL(DC, 1, 0);
55 
56  SET_INJECTION_CODE("$(injectCurrent, $(amp));\n");
57 
58  SET_PARAM_NAMES({"amp"});
59 };
60 
61 //----------------------------------------------------------------------------
62 // CurrentSourceModels::GaussianNoise
63 //----------------------------------------------------------------------------
65 
69 class GaussianNoise : public Base
70 {
72 
73  SET_INJECTION_CODE("$(injectCurrent, $(mean) + $(gennrand_normal) * $(sd));\n");
74 
75  SET_PARAM_NAMES({"mean", "sd"} );
76 };
77 
78 //----------------------------------------------------------------------------
79 // CurrentSourceModels::PoissonExp
80 //----------------------------------------------------------------------------
83 
88 class PoissonExp : public Base
89 {
91 
93  "scalar p = 1.0f;\n"
94  "unsigned int numSpikes = 0;\n"
95  "do\n"
96  "{\n"
97  " numSpikes++;\n"
98  " p *= $(gennrand_uniform);\n"
99  "} while (p > $(ExpMinusLambda));\n"
100  "$(current) += $(Init) * (scalar)(numSpikes - 1);\n"
101  "$(injectCurrent, $(current));\n"
102  "$(current) *= $(ExpDecay);\n");
103 
104  SET_PARAM_NAMES({"weight", "tauSyn", "rate"});
105  SET_VARS({{"current", "scalar"}});
107  {"ExpDecay", [](const std::vector<double> &pars, double dt){ return std::exp(-dt / pars[1]); }},
108  {"Init", [](const std::vector<double> &pars, double dt){ return pars[0] * (1.0 - std::exp(-dt / pars[1])) * (pars[1] / dt); }},
109  {"ExpMinusLambda", [](const std::vector<double> &pars, double dt){ return std::exp(-(pars[2] / 1000.0) * dt); }}});
110 };
111 } // CurrentSourceModels
#define SET_VARS(...)
Definition: models.h:39
#define SET_INJECTION_CODE(INJECTION_CODE)
Definition: currentSourceModels.h:18
Base class for all current source models.
Definition: currentSourceModels.h:26
Definition: currentSourceModels.h:23
Definition: currentSourceModels.h:88
Definition: models.h:48
#define GENN_EXPORT
Definition: gennExport.h:13
#define DECLARE_MODEL(TYPE, NUM_PARAMS, NUM_VARS)
Definition: models.h:31
DC source.
Definition: currentSourceModels.h:52
#define SET_DERIVED_PARAMS(...)
Definition: snippet.h:37
Noisy current source with noise drawn from normal distribution.
Definition: currentSourceModels.h:69
#define SET_PARAM_NAMES(...)
Definition: snippet.h:36
virtual std::string getInjectionCode() const
Gets the code that defines current injected each timestep.
Definition: currentSourceModels.h:33