-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathizhi2007b.c
556 lines (517 loc) · 13.6 KB
/
izhi2007b.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
/* Created by Language version: 7.5.0 */
/* NOT VECTORIZED */
#define NRN_VECTORIZED 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "scoplib_ansi.h"
#undef PI
#define nil 0
#include "md1redef.h"
#include "section.h"
#include "nrniv_mf.h"
#include "md2redef.h"
#if METHOD3
extern int _method3;
#endif
#if !NRNGPU
#undef exp
#define exp hoc_Exp
extern double hoc_Exp(double);
#endif
#define nrn_init _nrn_init__Izhi2007b
#define _nrn_initial _nrn_initial__Izhi2007b
#define nrn_cur _nrn_cur__Izhi2007b
#define _nrn_current _nrn_current__Izhi2007b
#define nrn_jacob _nrn_jacob__Izhi2007b
#define nrn_state _nrn_state__Izhi2007b
#define _net_receive _net_receive__Izhi2007b
#define _threadargscomma_ /**/
#define _threadargsprotocomma_ /**/
#define _threadargs_ /**/
#define _threadargsproto_ /**/
/*SUPPRESS 761*/
/*SUPPRESS 762*/
/*SUPPRESS 763*/
/*SUPPRESS 765*/
extern double *getarg();
static double *_p; static Datum *_ppvar;
#define t nrn_threads->_t
#define dt nrn_threads->_dt
#define C _p[0]
#define k _p[1]
#define vr _p[2]
#define vt _p[3]
#define vpeak _p[4]
#define a _p[5]
#define b _p[6]
#define c _p[7]
#define d _p[8]
#define Iin _p[9]
#define celltype _p[10]
#define alive _p[11]
#define cellid _p[12]
#define i _p[13]
#define u _p[14]
#define delta _p[15]
#define t0 _p[16]
#define derivtype _p[17]
#define _g _p[18]
#define _tsav _p[19]
#define _nd_area *_ppvar[0]._pval
#if MAC
#if !defined(v)
#define v _mlhv
#endif
#if !defined(h)
#define h _mlhh
#endif
#endif
#if defined(__cplusplus)
extern "C" {
#endif
static int hoc_nrnpointerindex = -1;
/* external NEURON variables */
/* declaration of user functions */
static double _hoc_derivfunc();
static int _mechtype;
extern void _nrn_cacheloop_reg(int, int);
extern void hoc_register_prop_size(int, int, int);
extern void hoc_register_limits(int, HocParmLimits*);
extern void hoc_register_units(int, HocParmUnits*);
extern void nrn_promote(Prop*, int, int);
extern Memb_func* memb_func;
extern Prop* nrn_point_prop_;
static int _pointtype;
static void* _hoc_create_pnt(_ho) Object* _ho; { void* create_point_process();
return create_point_process(_pointtype, _ho);
}
static void _hoc_destroy_pnt();
static double _hoc_loc_pnt(_vptr) void* _vptr; {double loc_point_process();
return loc_point_process(_pointtype, _vptr);
}
static double _hoc_has_loc(_vptr) void* _vptr; {double has_loc_point();
return has_loc_point(_vptr);
}
static double _hoc_get_loc_pnt(_vptr)void* _vptr; {
double get_loc_point_process(); return (get_loc_point_process(_vptr));
}
extern void _nrn_setdata_reg(int, void(*)(Prop*));
static void _setdata(Prop* _prop) {
_p = _prop->param; _ppvar = _prop->dparam;
}
static void _hoc_setdata(void* _vptr) { Prop* _prop;
_prop = ((Point_process*)_vptr)->_prop;
_setdata(_prop);
}
/* connect user functions to hoc names */
static VoidFunc hoc_intfunc[] = {
0,0
};
static Member_func _member_func[] = {
"loc", _hoc_loc_pnt,
"has_loc", _hoc_has_loc,
"get_loc", _hoc_get_loc_pnt,
"derivfunc", _hoc_derivfunc,
0, 0
};
#define derivfunc derivfunc_Izhi2007b
extern double derivfunc( );
/* declare global and static user variables */
/* some parameters have upper and lower limits */
static HocParmLimits _hoc_parm_limits[] = {
0,0,0
};
static HocParmUnits _hoc_parm_units[] = {
"vr", "mV",
"vt", "mV",
"vpeak", "mV",
"i", "nA",
"u", "mV",
0,0
};
static double v = 0;
/* connect global user variables to hoc */
static DoubScal hoc_scdoub[] = {
0,0
};
static DoubVec hoc_vdoub[] = {
0,0,0
};
static double _sav_indep;
static void nrn_alloc(Prop*);
static void nrn_init(_NrnThread*, _Memb_list*, int);
static void nrn_state(_NrnThread*, _Memb_list*, int);
static void nrn_cur(_NrnThread*, _Memb_list*, int);
static void nrn_jacob(_NrnThread*, _Memb_list*, int);
#define _watch_array _ppvar + 3
static void _hoc_destroy_pnt(_vptr) void* _vptr; {
Prop* _prop = ((Point_process*)_vptr)->_prop;
if (_prop) { _nrn_free_watch(_prop->dparam, 3, 8);}
destroy_point_process(_vptr);
}
/* connect range variables in _p that hoc is supposed to know about */
static const char *_mechanism[] = {
"7.5.0",
"Izhi2007b",
"C",
"k",
"vr",
"vt",
"vpeak",
"a",
"b",
"c",
"d",
"Iin",
"celltype",
"alive",
"cellid",
0,
"i",
"u",
"delta",
"t0",
"derivtype",
0,
0,
0};
extern Prop* need_memb(Symbol*);
static void nrn_alloc(Prop* _prop) {
Prop *prop_ion;
double *_p; Datum *_ppvar;
if (nrn_point_prop_) {
_prop->_alloc_seq = nrn_point_prop_->_alloc_seq;
_p = nrn_point_prop_->param;
_ppvar = nrn_point_prop_->dparam;
}else{
_p = nrn_prop_data_alloc(_mechtype, 20, _prop);
/*initialize range parameters*/
C = 1;
k = 0.7;
vr = -60;
vt = -40;
vpeak = 35;
a = 0.03;
b = -2;
c = -50;
d = 100;
Iin = 0;
celltype = 1;
alive = 1;
cellid = -1;
}
_prop->param = _p;
_prop->param_size = 20;
if (!nrn_point_prop_) {
_ppvar = nrn_prop_datum_alloc(_mechtype, 11, _prop);
}
_prop->dparam = _ppvar;
/*connect ionic variables to this model*/
}
static void _initlists();
#define _tqitem &(_ppvar[2]._pvoid)
static void _net_receive(Point_process*, double*, double);
extern Symbol* hoc_lookup(const char*);
extern void _nrn_thread_reg(int, int, void(*)(Datum*));
extern void _nrn_thread_table_reg(int, void(*)(double*, Datum*, Datum*, _NrnThread*, int));
extern void hoc_register_tolerance(int, HocStateTolerance*, Symbol***);
extern void _cvode_abstol( Symbol**, double*, int);
void _izhi2007b_reg() {
int _vectorized = 0;
_initlists();
_pointtype = point_register_mech(_mechanism,
nrn_alloc,nrn_cur, nrn_jacob, nrn_state, nrn_init,
hoc_nrnpointerindex, 0,
_hoc_create_pnt, _hoc_destroy_pnt, _member_func);
_mechtype = nrn_get_mechtype(_mechanism[1]);
_nrn_setdata_reg(_mechtype, _setdata);
hoc_register_prop_size(_mechtype, 20, 11);
hoc_register_dparam_semantics(_mechtype, 0, "area");
hoc_register_dparam_semantics(_mechtype, 1, "pntproc");
hoc_register_dparam_semantics(_mechtype, 2, "netsend");
hoc_register_dparam_semantics(_mechtype, 3, "watch");
hoc_register_dparam_semantics(_mechtype, 4, "watch");
hoc_register_dparam_semantics(_mechtype, 5, "watch");
hoc_register_dparam_semantics(_mechtype, 6, "watch");
hoc_register_dparam_semantics(_mechtype, 7, "watch");
hoc_register_dparam_semantics(_mechtype, 8, "watch");
hoc_register_dparam_semantics(_mechtype, 9, "watch");
hoc_register_dparam_semantics(_mechtype, 10, "watch");
add_nrn_has_net_event(_mechtype);
pnt_receive[_mechtype] = _net_receive;
pnt_receive_size[_mechtype] = 1;
hoc_register_var(hoc_scdoub, hoc_vdoub, hoc_intfunc);
ivoc_help("help ?1 Izhi2007b C:/Users/Michael/Documents/GitHub/cellmodels/izhi2007b.mod\n");
hoc_register_limits(_mechtype, _hoc_parm_limits);
hoc_register_units(_mechtype, _hoc_parm_units);
}
static int _reset;
static char *modelname = "";
static int error;
static int _ninits = 0;
static int _match_recurse=1;
static void _modl_cleanup(){ _match_recurse=1;}
double derivfunc ( ) {
double _lderivfunc;
if ( celltype == 5.0 && derivtype == 2.0 ) {
_lderivfunc = a * ( 0.0 - u ) ;
}
else if ( celltype == 5.0 && derivtype == 1.0 ) {
_lderivfunc = a * ( ( 0.025 * ( v - d ) * ( v - d ) * ( v - d ) ) - u ) ;
}
else if ( celltype == 5.0 ) {
/*VERBATIM*/
hoc_execerror("izhi2007b.mod ERRA: derivtype not set",0);
}
else {
_lderivfunc = a * ( b * ( v - vr ) - u ) ;
}
return _lderivfunc;
}
static double _hoc_derivfunc(void* _vptr) {
double _r;
_hoc_setdata(_vptr);
_r = derivfunc ( );
return(_r);
}
static double _watch1_cond(_pnt) Point_process* _pnt; {
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
v = NODEV(_pnt->node);
return ( v ) - ( ( vpeak - 0.1 * u ) ) ;
}
static double _watch2_cond(_pnt) Point_process* _pnt; {
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
v = NODEV(_pnt->node);
return ( v ) - ( ( vpeak + 0.1 * u ) ) ;
}
static double _watch3_cond(_pnt) Point_process* _pnt; {
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
v = NODEV(_pnt->node);
return ( v ) - ( vpeak ) ;
}
static double _watch4_cond(_pnt) Point_process* _pnt; {
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
v = NODEV(_pnt->node);
return ( v ) - ( - 65.0 ) ;
}
static double _watch5_cond(_pnt) Point_process* _pnt; {
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
v = NODEV(_pnt->node);
return -( ( v ) - ( - 65.0 ) ) ;
}
static double _watch6_cond(_pnt) Point_process* _pnt; {
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
v = NODEV(_pnt->node);
return ( v ) - ( d ) ;
}
static double _watch7_cond(_pnt) Point_process* _pnt; {
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
v = NODEV(_pnt->node);
return -( ( v ) - ( d ) ) ;
}
static void _net_receive (_pnt, _args, _lflag) Point_process* _pnt; double* _args; double _lflag;
{ int _watch_rm = 0;
_p = _pnt->_prop->param; _ppvar = _pnt->_prop->dparam;
if (_tsav > t){ extern char* hoc_object_name(); hoc_execerror(hoc_object_name(_pnt->ob), ":Event arrived out of order. Must call ParallelContext.set_maxstep AFTER assigning minimum NetCon.delay");}
_tsav = t; v = NODEV(_pnt->node);
if (_lflag == 1. ) {*(_tqitem) = 0;}
{
if ( _lflag == 1.0 ) {
if ( celltype == 4.0 ) {
_nrn_watch_activate(_watch_array, _watch1_cond, 1, _pnt, _watch_rm++, 2.0);
}
else if ( celltype == 6.0 ) {
_nrn_watch_activate(_watch_array, _watch2_cond, 2, _pnt, _watch_rm++, 2.0);
}
else {
_nrn_watch_activate(_watch_array, _watch3_cond, 3, _pnt, _watch_rm++, 2.0);
}
if ( celltype == 6.0 || celltype == 7.0 ) {
_nrn_watch_activate(_watch_array, _watch4_cond, 4, _pnt, _watch_rm++, 3.0);
_nrn_watch_activate(_watch_array, _watch5_cond, 5, _pnt, _watch_rm++, 4.0);
}
if ( celltype == 5.0 ) {
_nrn_watch_activate(_watch_array, _watch6_cond, 6, _pnt, _watch_rm++, 3.0);
_nrn_watch_activate(_watch_array, _watch7_cond, 7, _pnt, _watch_rm++, 4.0);
}
v = vr ;
}
else if ( _lflag == 2.0 ) {
if ( alive ) {
net_event ( _pnt, t ) ;
}
if ( celltype == 4.0 ) {
v = c + 0.04 * u ;
if ( ( u + d ) < 670.0 ) {
u = u + d ;
}
else {
u = 670.0 ;
}
}
else if ( celltype == 5.0 ) {
v = c ;
}
else if ( celltype == 6.0 ) {
v = c - 0.1 * u ;
u = u + d ;
}
else {
v = c ;
u = u + d ;
}
}
else if ( _lflag == 3.0 ) {
if ( celltype == 5.0 ) {
derivtype = 1.0 ;
}
else if ( celltype == 6.0 ) {
b = 0.0 ;
}
else if ( celltype == 7.0 ) {
b = 2.0 ;
}
}
else if ( _lflag == 4.0 ) {
if ( celltype == 5.0 ) {
derivtype = 2.0 ;
}
else if ( celltype == 6.0 ) {
b = 15.0 ;
}
else if ( celltype == 7.0 ) {
b = 10.0 ;
}
}
}
NODEV(_pnt->node) = v;
}
static void initmodel() {
int _i; double _save;_ninits++;
{
{
u = 0.0 ;
derivtype = 2.0 ;
net_send ( _tqitem, (double*)0, _ppvar[1]._pvoid, t + 0.0 , 1.0 ) ;
}
}
}
static void nrn_init(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; double _v; int* _ni; int _iml, _cntml;
#if CACHEVEC
_ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
_p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
_tsav = -1e20;
#if CACHEVEC
if (use_cachevec) {
_v = VEC_V(_ni[_iml]);
}else
#endif
{
_nd = _ml->_nodelist[_iml];
_v = NODEV(_nd);
}
v = _v;
initmodel();
}}
static double _nrn_current(double _v){double _current=0.;v=_v;{ {
delta = t - t0 ;
if ( celltype < 5.0 ) {
u = u + delta * a * ( b * ( v - vr ) - u ) ;
}
else {
if ( celltype == 5.0 ) {
if ( v < d ) {
u = u + delta * a * ( 0.0 - u ) ;
}
else {
u = u + delta * a * ( ( 0.025 * ( v - d ) * ( v - d ) * ( v - d ) ) - u ) ;
}
}
if ( celltype == 6.0 ) {
if ( v > - 65.0 ) {
b = 0.0 ;
}
else {
b = 15.0 ;
}
u = u + delta * a * ( b * ( v - vr ) - u ) ;
}
if ( celltype == 7.0 ) {
if ( v > - 65.0 ) {
b = 2.0 ;
}
else {
b = 10.0 ;
}
u = u + delta * a * ( b * ( v - vr ) - u ) ;
}
}
t0 = t ;
i = - ( k * ( v - vr ) * ( v - vt ) - u + Iin ) / C / 1000.0 ;
}
_current += i;
} return _current;
}
static void nrn_cur(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; int* _ni; double _rhs, _v; int _iml, _cntml;
#if CACHEVEC
_ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
_p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
#if CACHEVEC
if (use_cachevec) {
_v = VEC_V(_ni[_iml]);
}else
#endif
{
_nd = _ml->_nodelist[_iml];
_v = NODEV(_nd);
}
_g = _nrn_current(_v + .001);
{ _rhs = _nrn_current(_v);
}
_g = (_g - _rhs)/.001;
_g *= 1.e2/(_nd_area);
_rhs *= 1.e2/(_nd_area);
#if CACHEVEC
if (use_cachevec) {
VEC_RHS(_ni[_iml]) -= _rhs;
}else
#endif
{
NODERHS(_nd) -= _rhs;
}
}}
static void nrn_jacob(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; int* _ni; int _iml, _cntml;
#if CACHEVEC
_ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
_p = _ml->_data[_iml];
#if CACHEVEC
if (use_cachevec) {
VEC_D(_ni[_iml]) += _g;
}else
#endif
{
_nd = _ml->_nodelist[_iml];
NODED(_nd) += _g;
}
}}
static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type){
}
static void terminal(){}
static void _initlists() {
int _i; static int _first = 1;
if (!_first) return;
_first = 0;
}