Does POINTER make NET_RECEIVE slower?
Posted: Tue May 24, 2022 9:48 pm
I have a small NMODL system that uses NET_RECEIVE with WATCH in order to force a lower limit for a state variable. I want to separate the two equations into different .mod files by adding a POINTER, but this seems to dramatically reduce the efficiency and increase the run time by a few orders of magnitude.
My test system has two equations. One is an algebraic equation that defines a variable 'b' that is just an oscillator. The other is a differential equation for variable 'a' that is driven by 'b' but which enforces a lower limit of zero for 'a'. The goal of this endeavor is to use the same approach for a much larger model (i.e. many more differential equations), such that major components of the system are separated into separate .mod files. This will require using POINTER to access state variables between each POINT_PROCESS.
Here is a version with both equations in a single .mod file:
The following .hoc code uses the above NMODL:
The performance problem occurs when the two equations are placed in separate .mod files. Below are the two separate .mod files, named 'brain' and 'body', respectively, where a POINTER is used in 'brain' to access the variable 'b' from 'body'.
The following .hoc code uses the above NMODL:
The 2nd example runs a couple orders of magnitude slower, and I assume it is due to using the POINTER. Is this expected? Thanks in advance for any feedback.
My test system has two equations. One is an algebraic equation that defines a variable 'b' that is just an oscillator. The other is a differential equation for variable 'a' that is driven by 'b' but which enforces a lower limit of zero for 'a'. The goal of this endeavor is to use the same approach for a much larger model (i.e. many more differential equations), such that major components of the system are separated into separate .mod files. This will require using POINTER to access state variables between each POINT_PROCESS.
Here is a version with both equations in a single .mod file:
Code: Select all
NEURON {
POINT_PROCESS equations
}
PARAMETER { :: Declare and set any parameters required for this mod file here.
b0 = 1.0 :: Scaling parameter
w = 0.628 :: Frequency parameter
}
STATE { a b } :: Declare state variables here.
BREAKPOINT {
SOLVE states METHOD derivimplicit :: See template for instructions.
}
INITIAL {
a = 1.0 :: Set initial value of state variable.
b = 1 :: Set initial value.
net_send(0,1)
}
DERIVATIVE states {
b = b0 * cos(w * t) :: Algebraic equation
a' = a * (1 - a) - b :: Differential equation
}
NET_RECEIVE (dummy_weight) {
if (flag == 1) {
WATCH (a < 0.0) 2
}
else if (flag == 2) {
net_event(t)
a = 0.0
}
}
Code: Select all
create model
access model
objref obj
obj = new equations(0.5)
objref cvode
cvode = new CVode(1)
cvode_active(1)
Code: Select all
NEURON {
POINT_PROCESS brain
POINTER b
}
ASSIGNED { b } :: Declare all pointer variables here.
STATE { a } :: Declare state variables here.
BREAKPOINT {
SOLVE states METHOD derivimplicit :: See template for instructions.
}
INITIAL {
a = 1.0 :: Set initial value of state variable.
net_send(0,1)
}
DERIVATIVE states {
a' = a * (1 - a) - b :: Differential equation
}
NET_RECEIVE (dummy_weight) {
if (flag == 1) {
WATCH (a < 0.0) 2
}
else if (flag == 2) {
net_event(t)
a = 0.0
}
}
Code: Select all
NEURON {
POINT_PROCESS body
}
PARAMETER { :: Declare and set any parameters required for this mod file here.
b0 = 1.0 :: Scaling parameter
w = 0.628 :: Frequency parameter
}
STATE { b } :: Declare state variables here.
BREAKPOINT {
b = b0 * cos(w * t) :: Algebraic equation
}
INITIAL {
b = 1 :: Set initial value.
}
Code: Select all
create model
access model
objref objBrain, objBody
objBrain = new brain(0.5)
objBody = new body(0.5)
// Set pointer
setpointer objBrain.b, objBody.b
objref cvode
cvode = new CVode(1)
cvode_active(1)