GeNN  1.1
GPU enhanced Neuronal Networks (GeNN)
 All Classes Files Functions Variables Typedefs Macros Pages
helper.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------
2  Author: Thomas Nowotny
3 
4  Institute: Informatics
5  University of Sussex
6  Brighton BN1 9QJ, UK
7 
8  email to: t.nowotny@sussex.ac.uk
9 
10  initial version: 2014-06-26
11 
12 --------------------------------------------------------------------------*/
13 
14 #include <vector>
15 
16 typedef struct {
17  double t;
18  double baseV;
19  int N;
20  vector<double> st;
21  vector<double> V;
22 } inputSpec;
23 
24 double sigGNa= 0.1;
25 double sigENa= 10.0;
26 double sigGK= 0.1;
27 double sigEK= 10.0;
28 double sigGl= 0.1;
29 double sigEl= 10.0;
30 double sigC= 0.1;
31 
32 ostream &operator<<(ostream &os, inputSpec &I)
33 {
34  os << " " << I.t << " ";
35  os << " " << I.baseV << " ";
36  os << " " << I.N << " ";
37  for (int i= 0; i < I.N; i++) {
38  os << I.st[i] << " ";
39  os << I.V[i] << " ";
40  }
41  return os;
42 }
43 
44 void write_para()
45 {
46  fprintf(stderr, "# DT %f \n", DT);
47 }
48 
49 void single_var_reinit(int n, double fac)
50 {
51  gNaHH[n]*= (1.0+fac*sigGNa*RG.n()); // multiplicative Gaussian noise
52  ENaHH[n]+= fac*sigENa*RG.n(); // additive Gaussian noise
53  gKHH[n]*= (1.0+fac*sigGK*RG.n()); // multiplicative Gaussian noise
54  EKHH[n]+= fac*sigEK*RG.n(); // additive Gaussian noise
55  glHH[n]*= (1.0+fac*sigGl*RG.n()); // multiplicative Gaussian noise
56  ElHH[n]+= fac*sigEl*RG.n(); // additive Gaussian noise
57  CHH[n]*= (1.0+fac*sigC*RG.n()); // multiplicative Gaussian noise
58 }
59 
60 void copy_var(int src, int trg)
61 {
62  gNaHH[trg]= gNaHH[src];
63  ENaHH[trg]= ENaHH[src];
64  gKHH[trg]= gKHH[src];
65  EKHH[trg]=EKHH[src];
66  glHH[trg]= glHH[src];
67  ElHH[trg]= ElHH[src];
68  CHH[trg]= CHH[src];
69 }
70 
71 void var_reinit(double fac)
72 {
73  // add noise to the parameters
74  for (int n= 0; n < NPOP; n++) {
75  single_var_reinit(n, fac);
76  }
77  copyStateToDevice();
78 }
79 
81 {
82  for (int n= 0; n < NPOP; n++) {
83  VHH[n]= myHH_ini[0];
84  mHH[n]= myHH_ini[1];
85  hHH[n]= myHH_ini[2];
86  nHH[n]= myHH_ini[3];
87  errHH[n]= 0.0;
88  }
89  copyStateToDevice();
90 }
91 
92 
93 double Vexp;
94 double mexp;
95 double hexp;
96 double nexp;
97 double gNaexp;
98 double ENaexp;
99 double gKexp;
100 double EKexp;
101 double glexp;
102 double Elexp;
103 double Cexp;
104 
105 void initexpHH()
106 {
107  Vexp= myHH_ini[0];
108  mexp= myHH_ini[1];
109  hexp= myHH_ini[2];
110  nexp= myHH_ini[3];
111  gNaexp= myHH_ini[4];
112  ENaexp= myHH_ini[5];
113  gKexp= myHH_ini[6];
114  EKexp= myHH_ini[7];
115  glexp= myHH_ini[8];
116  Elexp= myHH_ini[9];
117  Cexp= myHH_ini[10];
118 }
119 
121 {
122  Vexp= myHH_ini[0];
123  mexp= myHH_ini[1];
124  hexp= myHH_ini[2];
125  nexp= myHH_ini[3];
126 }
127 
128 
129 void runexpHH(float t)
130 {
131  // calculate membrane potential
132  double Imem;
133  unsigned int mt;
134  double mdt= DT/100.0;
135  for (mt=0; mt < 100; mt++) {
136  IsynGHH= 200.0*(stepVGHH-Vexp);
137  // cerr << IsynGHH << " " << Vexp << endl;
138  Imem= -(mexp*mexp*mexp*hexp*gNaexp*(Vexp-(ENaexp))+
140  glexp*(Vexp-(Elexp))-IsynGHH);
141  double _a= (3.5+0.1*Vexp) / (1.0-exp(-3.5-0.1*Vexp));
142  double _b= 4.0*exp(-(Vexp+60.0)/18.0);
143  mexp+= (_a*(1.0-mexp)-_b*mexp)*mdt;
144  _a= 0.07*exp(-Vexp/20.0-3.0);
145  _b= 1.0 / (exp(-3.0-0.1*Vexp)+1.0);
146  hexp+= (_a*(1.0-hexp)-_b*hexp)*mdt;
147  _a= (-0.5-0.01*Vexp) / (exp(-5.0-0.1*Vexp)-1.0);
148  _b= 0.125*exp(-(Vexp+60.0)/80.0);
149  nexp+= (_a*(1.0-nexp)-_b*nexp)*mdt;
150  Vexp+= Imem/Cexp*mdt;
151  }
152 }
153 
154 
155 void initI(inputSpec &I)
156 {
157  I.t= 200.0;
158  I.baseV= -60.0;
159  I.N= 12;
160  I.st.push_back(10.0);
161  I.V.push_back(-30.0);
162  I.st.push_back(20.0);
163  I.V.push_back(-60.0);
164 
165  I.st.push_back(40.0);
166  I.V.push_back(-20.0);
167  I.st.push_back(50.0);
168  I.V.push_back(-60.0);
169 
170  I.st.push_back(70.0);
171  I.V.push_back(-10.0);
172  I.st.push_back(80.0);
173  I.V.push_back(-60.0);
174 
175  I.st.push_back(100.0);
176  I.V.push_back(0.0);
177  I.st.push_back(110.0);
178  I.V.push_back(-60.0);
179 
180  I.st.push_back(130.0);
181  I.V.push_back(10.0);
182  I.st.push_back(140.0);
183  I.V.push_back(-60.0);
184 
185  I.st.push_back(160.0);
186  I.V.push_back(20.0);
187  I.st.push_back(170.0);
188  I.V.push_back(-60.0);
189  assert((I.N == I.V.size()) && (I.N == I.st.size()));
190 }
191 
vector< double > V
Definition: helper.h:21
double Elexp
Definition: helper.h:102
vector< double > st
Definition: helper.h:20
void runexpHH(float t)
Definition: helper.h:129
double EKexp
Definition: helper.h:100
void var_reinit(double fac)
Definition: helper.h:71
ostream & operator<<(ostream &os, inputSpec &I)
Definition: helper.h:32
double nexp
Definition: helper.h:96
void write_para()
Definition: helper.h:44
double t
Definition: helper.h:17
double mexp
Definition: helper.h:94
double glexp
Definition: helper.h:101
void copy_var(int src, int trg)
Definition: helper.h:60
double sigEK
Definition: helper.h:27
double baseV
Definition: helper.h:18
randomGauss RG
Definition: gen_kcdn_syns.cc:34
double gNaexp
Definition: helper.h:97
double sigENa
Definition: helper.h:25
double sigEl
Definition: helper.h:29
int N
Definition: helper.h:19
double n()
Method for obtaining a random number with Gaussian distribution.
Definition: gauss.cc:75
float myHH_ini[11]
Definition: HHVClamp.cc:26
double t
Definition: VClampGA.h:41
Definition: helper.h:16
double Cexp
Definition: helper.h:103
void single_var_reinit(int n, double fac)
Definition: helper.h:49
double sigGl
Definition: helper.h:28
void truevar_init()
Definition: helper.h:80
double ENaexp
Definition: helper.h:98
void truevar_initexpHH()
Definition: helper.h:120
#define DT
This defines the global time step at which the simulation will run.
Definition: currentModel.cc:21
double hexp
Definition: helper.h:95
void initI(inputSpec &I)
Definition: helper.h:155
double sigC
Definition: helper.h:30
double Vexp
Definition: helper.h:93
double gKexp
Definition: helper.h:99
void initexpHH()
Definition: helper.h:105
double sigGK
Definition: helper.h:26
double sigGNa
Definition: helper.h:24