-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcdt_pp.mod
executable file
·89 lines (78 loc) · 1.87 KB
/
dcdt_pp.mod
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
: Provides an example of how to manage variable capacitance using
: the relation q = c*v so that i = (c*dv/dt) + (dc/dt * v)
: The capacitance is assumed to be c(t)
: The effect of changing capacitance on the (c*dv/dt) term is accomplished
: via a POINTER to the compartment cm (set up in hoc) where the c pointer
: is assigned a value in the BEFORE BREAKPOINT block. The effect of
: the (dc/dt * v) term is accomplished in the BREAKPOINT block.
: This is a POINT_PROCESS to allow charge conservation q=c*v across a
: discontinuity in c
UNITS {
(nA) = (nanoamp)
(mV) = (millivolt)
(uF) = (microfarad)
(um) = (micron)
PI = (pi) (1)
}
NEURON {
POINT_PROCESS DcDt
THREADSAFE
RANGE c1, c2, w, tbegin, tdur, dc
POINTER c
NONSPECIFIC_CURRENT i
}
PARAMETER {
c1 = 1 (uF/cm2)
c2 = 0 (uF/cm2)
w = 0 (/ms)
tbegin = 1e9 (ms)
tdur = 0 (ms)
dc (uF/cm2-ms)
}
ASSIGNED {
c (uF/cm2)
i (nA)
v (mV)
area (um2)
}
FUNCTION cm(t(ms)) (uF/cm2) {
if (t >= tbegin && t <= (tbegin + tdur)) {
cm = c1 + c2*sin(2*PI*w*(t - tbegin))
}else{
cm = c1
}
}
FUNCTION dcmdt(t(ms))(uF/cm2-ms) {
if (t >= tbegin && t <= (tbegin + tdur)) {
dcmdt = c2*2*PI*w*cos(2*PI*w*(t - tbegin))
}else{
dcmdt = 0
}
}
INITIAL {
dc = 0
net_send(tbegin, 1)
}
BEFORE BREAKPOINT {
c = cm(t)
dc = dcmdt(t)
}
BREAKPOINT {
i = dc*v*area*(1e-5)
}
NET_RECEIVE(w) {
LOCAL qbefore, cafter, epsilon, tt
epsilon = 1e-10 (ms)
if (flag == 1) { : turn on stim
tt = tbegin
qbefore = cm(tt - epsilon)*v : charge prior to discontinuity
cafter = cm(tt + epsilon) : capacitance after discontinuity
v = qbefore/cafter
net_send(tdur, 2)
} else if (flag == 2) { : turn off stim
tt = tbegin + tdur
qbefore = cm(tt - epsilon)*v : charge prior to discontinuity
cafter = cm(tt + epsilon) : capacitance after discontinuity
v = qbefore/cafter
}
}