GeNN
2.2.3
GPU enhanced Neuronal Networks (GeNN)
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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
const
double
limit
[7][2]= {{1.0, 200.0},
// gNa
50
{0.0, 100.0},
// ENa
51
{1.0, 100.0},
// gKd
52
{-100.0, -20.0},
// EKd
53
{1.0, 50.0},
// gleak
54
{-100.0, -20.0},
// Eleak
55
{1e-1, 10.0}};
// C
56
57
58
void
single_var_init_fullrange
(
int
n)
59
{
60
gNaHH[n]=
limit
[0][0]+
R
.
n
()*(
limit
[0][1]-
limit
[0][0]);
// uniform in allowed interval
61
ENaHH[n]=
limit
[1][0]+
R
.
n
()*(
limit
[1][1]-
limit
[1][0]);
// uniform in allowed interval
62
gKHH[n]=
limit
[2][0]+
R
.
n
()*(
limit
[2][1]-
limit
[2][0]);
// uniform in allowed interval
63
EKHH[n]=
limit
[3][0]+
R
.
n
()*(
limit
[3][1]-
limit
[3][0]);
// uniform in allowed interval
64
glHH[n]=
limit
[4][0]+
R
.
n
()*(
limit
[4][1]-
limit
[4][0]);
// uniform in allowed interval
65
ElHH[n]=
limit
[5][0]+
R
.
n
()*(
limit
[5][1]-
limit
[5][0]);
// uniform in allowed interval
66
CHH[n]=
limit
[6][0]+
R
.
n
()*(
limit
[6][1]-
limit
[6][0]);
// uniform in allowed interval
67
}
68
69
void
single_var_reinit
(
int
n,
double
fac)
70
{
71
gNaHH[n]*= (1.0+fac*
sigGNa
*
RG
.
n
());
// multiplicative Gaussian noise
72
ENaHH[n]+= fac*
sigENa
*
RG
.
n
();
// additive Gaussian noise
73
gKHH[n]*= (1.0+fac*
sigGK
*
RG
.
n
());
// multiplicative Gaussian noise
74
EKHH[n]+= fac*
sigEK
*
RG
.
n
();
// additive Gaussian noise
75
glHH[n]*= (1.0+fac*
sigGl
*
RG
.
n
());
// multiplicative Gaussian noise
76
ElHH[n]+= fac*
sigEl
*
RG
.
n
();
// additive Gaussian noise
77
CHH[n]*= (1.0+fac*
sigC
*
RG
.
n
());
// multiplicative Gaussian noise
78
}
79
80
void
copy_var
(
int
src,
int
trg)
81
{
82
gNaHH[trg]= gNaHH[src];
83
ENaHH[trg]= ENaHH[src];
84
gKHH[trg]= gKHH[src];
85
EKHH[trg]=EKHH[src];
86
glHH[trg]= glHH[src];
87
ElHH[trg]= ElHH[src];
88
CHH[trg]= CHH[src];
89
}
90
91
void
var_init_fullrange
()
92
{
93
for
(
int
n= 0; n <
NPOP
; n++) {
94
single_var_init_fullrange
(n);
95
}
96
#ifndef CPU_ONLY
97
copyStateToDevice();
98
#endif
99
}
100
101
void
var_reinit
(
double
fac)
102
{
103
// add noise to the parameters
104
for
(
int
n= 0; n <
NPOP
; n++) {
105
single_var_reinit
(n, fac);
106
}
107
#ifndef CPU_ONLY
108
copyStateToDevice();
109
#endif
110
}
111
112
void
truevar_init
()
113
{
114
for
(
int
n= 0; n <
NPOP
; n++) {
115
VHH[n]=
myHH_ini
[0];
116
mHH[n]=
myHH_ini
[1];
117
hHH[n]=
myHH_ini
[2];
118
nHH[n]=
myHH_ini
[3];
119
errHH[n]= 0.0;
120
}
121
#ifndef CPU_ONLY
122
copyStateToDevice();
123
#endif
124
}
125
126
127
double
Vexp
;
128
double
mexp
;
129
double
hexp
;
130
double
nexp
;
131
double
gNaexp
;
132
double
ENaexp
;
133
double
gKexp
;
134
double
EKexp
;
135
double
glexp
;
136
double
Elexp
;
137
double
Cexp
;
138
139
void
initexpHH
()
140
{
141
Vexp
=
myHH_ini
[0];
142
mexp
=
myHH_ini
[1];
143
hexp
=
myHH_ini
[2];
144
nexp
=
myHH_ini
[3];
145
gNaexp
=
myHH_ini
[4];
146
ENaexp
=
myHH_ini
[5];
147
gKexp
=
myHH_ini
[6];
148
EKexp
=
myHH_ini
[7];
149
glexp
=
myHH_ini
[8];
150
Elexp
=
myHH_ini
[9];
151
Cexp
=
myHH_ini
[10];
152
}
153
154
void
truevar_initexpHH
()
155
{
156
Vexp
=
myHH_ini
[0];
157
mexp
=
myHH_ini
[1];
158
hexp
=
myHH_ini
[2];
159
nexp
=
myHH_ini
[3];
160
}
161
162
163
void
runexpHH
(
float
t)
164
{
165
// calculate membrane potential
166
double
Imem;
167
unsigned
int
mt;
168
double
mdt=
DT
/100.0;
169
for
(mt=0; mt < 100; mt++) {
170
IsynGHH= 200.0*(stepVGHH-
Vexp
);
171
// cerr << IsynGHH << " " << Vexp << endl;
172
Imem= -(
mexp
*
mexp
*
mexp
*
hexp
*
gNaexp
*(
Vexp
-(
ENaexp
))+
173
nexp
*
nexp
*
nexp
*
nexp
*
gKexp
*(
Vexp
-(
EKexp
))+
174
glexp
*(
Vexp
-(
Elexp
))-IsynGHH);
175
double
_a= (3.5+0.1*
Vexp
) / (1.0-exp(-3.5-0.1*
Vexp
));
176
double
_b= 4.0*exp(-(
Vexp
+60.0)/18.0);
177
mexp
+= (_a*(1.0-
mexp
)-_b*
mexp
)*mdt;
178
_a= 0.07*exp(-
Vexp
/20.0-3.0);
179
_b= 1.0 / (exp(-3.0-0.1*
Vexp
)+1.0);
180
hexp
+= (_a*(1.0-
hexp
)-_b*
hexp
)*mdt;
181
_a= (-0.5-0.01*
Vexp
) / (exp(-5.0-0.1*
Vexp
)-1.0);
182
_b= 0.125*exp(-(
Vexp
+60.0)/80.0);
183
nexp
+= (_a*(1.0-
nexp
)-_b*
nexp
)*mdt;
184
Vexp
+= Imem/
Cexp
*mdt;
185
}
186
}
187
188
189
void
initI
(
inputSpec
&I)
190
{
191
I.
t
= 200.0;
192
I.
baseV
= -60.0;
193
I.
N
= 12;
194
I.
st
.push_back(10.0);
195
I.
V
.push_back(-30.0);
196
I.
st
.push_back(20.0);
197
I.
V
.push_back(-60.0);
198
199
I.
st
.push_back(40.0);
200
I.
V
.push_back(-20.0);
201
I.
st
.push_back(50.0);
202
I.
V
.push_back(-60.0);
203
204
I.
st
.push_back(70.0);
205
I.
V
.push_back(-10.0);
206
I.
st
.push_back(80.0);
207
I.
V
.push_back(-60.0);
208
209
I.
st
.push_back(100.0);
210
I.
V
.push_back(0.0);
211
I.
st
.push_back(110.0);
212
I.
V
.push_back(-60.0);
213
214
I.
st
.push_back(130.0);
215
I.
V
.push_back(10.0);
216
I.
st
.push_back(140.0);
217
I.
V
.push_back(-60.0);
218
219
I.
st
.push_back(160.0);
220
I.
V
.push_back(20.0);
221
I.
st
.push_back(170.0);
222
I.
V
.push_back(-60.0);
223
assert((I.
N
== I.
V
.size()) && (I.
N
== I.
st
.size()));
224
}
225
inputSpec::V
vector< double > V
Definition:
helper.h:21
Elexp
double Elexp
Definition:
helper.h:136
inputSpec::st
vector< double > st
Definition:
helper.h:20
runexpHH
void runexpHH(float t)
Definition:
helper.h:163
var_init_fullrange
void var_init_fullrange()
Definition:
helper.h:91
EKexp
double EKexp
Definition:
helper.h:134
var_reinit
void var_reinit(double fac)
Definition:
helper.h:101
operator<<
ostream & operator<<(ostream &os, inputSpec &I)
Definition:
helper.h:32
nexp
double nexp
Definition:
helper.h:130
write_para
void write_para()
Definition:
helper.h:44
limit
const double limit[7][2]
Definition:
helper.h:49
inputSpec::t
double t
Definition:
helper.h:17
mexp
double mexp
Definition:
helper.h:128
glexp
double glexp
Definition:
helper.h:135
copy_var
void copy_var(int src, int trg)
Definition:
helper.h:80
single_var_init_fullrange
void single_var_init_fullrange(int n)
Definition:
helper.h:58
sigEK
double sigEK
Definition:
helper.h:27
inputSpec::baseV
double baseV
Definition:
helper.h:18
gNaexp
double gNaexp
Definition:
helper.h:131
sigENa
double sigENa
Definition:
helper.h:25
sigEl
double sigEl
Definition:
helper.h:29
RG
randomGauss RG
Definition:
VClampGA.h:37
inputSpec::N
int N
Definition:
helper.h:19
randomGauss::n
double n()
Method for obtaining a random number with Gaussian distribution.
Definition:
gauss.cc:75
DT
#define DT
This defines the global time step at which the simulation will run.
Definition:
HHVclampGA_project/model/MBody1.cc:21
inputSpec
Definition:
helper.h:16
Cexp
double Cexp
Definition:
helper.h:137
single_var_reinit
void single_var_reinit(int n, double fac)
Definition:
helper.h:69
R
randomGen R
Definition:
VClampGA.h:36
sigGl
double sigGl
Definition:
helper.h:28
truevar_init
void truevar_init()
Definition:
helper.h:112
ENaexp
double ENaexp
Definition:
helper.h:132
truevar_initexpHH
void truevar_initexpHH()
Definition:
helper.h:154
hexp
double hexp
Definition:
helper.h:129
initI
void initI(inputSpec &I)
Definition:
helper.h:189
sigC
double sigC
Definition:
helper.h:30
NPOP
#define NPOP
Definition:
HHVClampParameters.h:1
Vexp
double Vexp
Definition:
helper.h:127
gKexp
double gKexp
Definition:
helper.h:133
initexpHH
void initexpHH()
Definition:
helper.h:139
sigGK
double sigGK
Definition:
helper.h:26
randomGen::n
double n()
Method to obtain a random number from a uniform ditribution on [0,1].
Definition:
randomGen.cc:60
sigGNa
double sigGNa
Definition:
helper.h:24
myHH_ini
double myHH_ini[11]
Definition:
HHVClamp.cc:26
userproject
HHVclampGA_project
model
helper.h
Generated on Tue May 30 2017 12:01:09 for GeNN by
1.8.11