37 #include <cuda_runtime.h>
46 #define CHECK_CUDA_ERRORS(call) \
48 cudaError_t error = call; \
49 if (error != cudaSuccess) \
51 fprintf(stderr, "%s: %i: cuda error %i: %s\n", \
52 __FILE__, __LINE__, (int)error, cudaGetErrorString(error)); \
65 ifstream is(
"header.src");
79 void substitute(
string &s,
const string trg,
const string rep)
81 size_t found= s.find(trg);
82 while (found != string::npos) {
83 s.replace(found,trg.length(),rep);
93 bool find(
string &s,
const string trg)
95 size_t found= s.find(trg);
96 return (found != string::npos);
106 unsigned int size = 0;
107 if (type ==
"int") size =
sizeof(int);
108 if (type ==
"unsigned int") size =
sizeof(
unsigned int);
109 if (type ==
"float") size =
sizeof(float);
110 if (type ==
"double") size =
sizeof(double);
111 if (type ==
"long double") size =
sizeof(
long double);
135 float ip0(vector<float> pars) {
136 return pars[0]*pars[0]*pars[1];
138 float ip1(vector<float> pars) {
139 return pars[0]*pars[2];
141 float ip2(vector<float> pars) {
142 return pars[0]*pars[1]+pars[0]*pars[2];
162 return expf(-dt/pars[0]);
194 $(V)= $(ip0)/(($(Vspike)) - $(V) - ($(beta))*$(Isyn)) +($(ip1));\n\
197 if (($(V) < $(ip2)) && ($(preV) <= 0.0)) {\n\
203 $(V)= -($(Vspike));\n\
229 if ($(V) > $(Vrest)) {\n\
233 if (t - $(spikeTime) > ($(trefract))) {\n\
234 RAND($(seed),theRnd);\n\
235 if (theRnd < lrate) {\n\
268 float mdt= DT/25.0f;\n\
269 for (mt=0; mt < 25; mt++) {\n\
270 Imem= -($(m)*$(m)*$(m)*$(h)*$(gNa)*($(V)-($(ENa)))+\n\
271 $(n)*$(n)*$(n)*$(n)*$(gK)*($(V)-($(EK)))+\n\
272 $(gl)*($(V)-($(El)))-Isyn);\n\
273 float _a= 0.32f*(-52.0f-$(V)) / (exp((-52.0f-$(V))/4.0f)-1.0f);\n\
274 float _b= 0.28f*($(V)+25.0f)/(exp(($(V)+25.0f)/5.0f)-1.0f);\n\
275 $(m)+= (_a*(1.0f-$(m))-_b*$(m))*mdt;\n\
276 _a= 0.128*expf((-48.0f-$(V))/18.0f);\n\
277 _b= 4.0f / (expf((-25.0f-$(V))/5.0f)+1.0f);\n\
278 $(h)+= (_a*(1.0f-$(h))-_b*$(h))*mdt;\n\
279 _a= .032f*(-50.0f-$(V)) / (expf((-50.0f-$(V))/5.0f)-1.0f); \n\
280 _b= 0.5f*expf((-55.0f-$(V))/40.0f);\n\
281 $(n)+= (_a*(1.0-$(n))-_b*$(n))*mdt;\n\
282 $(V)+= Imem/$(C)*mdt;\n\
308 $(V)+=0.5f*(0.04f*$(V)*$(V)+5*$(V)+140-$(U)+$(Isyn))*DT; //at two times for numerical stability\n\
309 $(V)+=0.5f*(0.04f*$(V)*$(V)+5*$(V)+140-$(U)+$(Isyn))*DT;\n\
310 $(U)+=$(a)*($(b)*$(V)-$(U))*DT;\n\
311 // if ($(V) > 30){ //keep this only for visualisation -- not really necessaary otherwise \n\
346 $(V)+=0.5f*(0.04f*$(V)*$(V)+5*$(V)+140-$(U)+$(Isyn))*DT; //at two times for numerical stability\n\
347 $(V)+=0.5f*(0.04f*$(V)*$(V)+5*$(V)+140-$(U)+$(Isyn))*DT;\n\
348 $(U)+=$(a)*($(b)*$(V)-$(U))*DT;\n\
349 //if ($(V) > 30){ //keep this only for visualisation -- not really necessaary otherwise \n\
float calculateDerivedParameter(int index, vector< float > pars, float dt=1.0)
Definition: utils.h:153
vector< string > varNames
Names of the variables in the postsynaptic model.
Definition: modelSpec.h:134
vector< postSynModel > postSynModels
Definition: utils.h:7
vector< string > pNames
Names of (independent) parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:118
#define tS(X)
Macro providing the abbreviated syntax tS() instead of toString().
Definition: toString.h:43
Contains a template function for string conversion from const char* to C++ string.
vector< string > pNames
Names of (independent) parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:136
void prepareSynapseModels()
Definition: utils.h:8
bool find(string &s, const string trg)
Tool for finding strings in another string.
Definition: utils.h:93
string simCode
Code that defines the execution of one timestep of integration of the neuron model.
Definition: modelSpec.h:109
Contains three macros that allow simple bit manipulations on an (presumably unsigned) 64 bit integer...
vector< neuronModel > nModels
Global c++ vector containing all neuron model descriptions.
Definition: utils.h:166
vector< string > dpNames
Names of dependent parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:137
float ip0(vector< float > pars)
Definition: utils.h:135
void substitute(string &s, const string trg, const string rep)
Tool for substituting strings in the neuron code strings or other templates.
Definition: utils.h:79
Header file that contains the class (struct) definition of neuronModel for defining a neuron model an...
string thresholdConditionCode
Code evaluating to a bool (e.g. "V > 20") that defines the condition for a true spike in the describe...
Definition: modelSpec.h:112
Definition: modelSpec.h:99
void prepareStandardModels()
Function that defines standard neuron models.
Definition: utils.h:176
vector< string > varTypes
Types of the variable named above, e.g. "float". Names and types are matched by their order of occurr...
Definition: modelSpec.h:116
string postSyntoCurrent
Definition: modelSpec.h:132
void preparePostSynModels()
Definition: utils.h:14
float calculateDerivedParameter(int index, vector< float > pars, float dt=1.0)
Definition: utils.h:123
Definition: modelSpec.h:130
float ip1(vector< float > pars)
Definition: utils.h:138
string postSynDecay
Definition: modelSpec.h:133
float expDecay(vector< float > pars, float dt)
Definition: utils.h:161
dpclass * dps
Definition: modelSpec.h:138
unsigned int theSize(string type)
Tool for determining the size of variable types on the current architecture.
Definition: utils.h:104
vector< string > varTypes
Types of the variable named above, e.g. "float". Names and types are matched by their order of occurr...
Definition: modelSpec.h:135
class (struct) for specifying a neuron model.
Definition: modelSpec.h:107
void writeHeader(ostream &os)
Definition: utils.h:62
float ip2(vector< float > pars)
Definition: utils.h:141
Class defining the dependent parameters of teh Rulkov map neuron.
Definition: utils.h:120
vector< string > varNames
Names of the variables in the neuron model.
Definition: modelSpec.h:114
Class defining the dependent parameter for exponential decay.
Definition: utils.h:150
vector< string > dpNames
Names of dependent parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:119
dpclass * dps
Definition: modelSpec.h:126