myreil wrote:Ga1 changes with time and one equation of t characterizes it when ton<t< toff and a different one when t>toff
What happens when t<ton?
So in our toy example
Your toy example, not mine. Yours won't do what you want because the statements in a NET_RECEIVE block are evaluated only when an event arrives. The point process will receive only one event: the self event that it launched at initialization.
The key to the solution is suggested in my two posts from May 31. Let me be more explicit.
In your conceptual model, Ga2 is described by f1 for t<toff, but by f2 when t>=toff. It is not a STATE, and it doesn't even have to be an ASSIGNED. If you are always going to use fixed dt, you could simply write
Code: Select all
FUNCTION Ga2(t) {
if (t<toff) {
Ga2 = f1(t)
} else {
Ga2 = f2(t)
}
}
where f1(t) and f2(t) are algebraic expressions involving t (replace them with whatever you want).
So instead you use a self event that changes the value of a new ASSIGNED parameter (for this example call it a). Initialization sets a to 0 and launches a self event that returns at toff (your mechanism has a DERIVATIVE block with three STATEs O1, O2, and C1 whose values must be initialized by the INITIAL block). Arrival of a self event sets a to 1. The function for Ga2 could then be
Code: Select all
FUNCTION Ga2(t) {
if (a==0) {
Ga2 = f1(t)
} else {
Ga2 = f2(t)
}
}
and this should work during a simulation. Your DERIVATIVE block would be
Code: Select all
DERIVATIVE states {
O1'=Ga1(t)-(Gd1+e_ct+Ga1(t))*O1+(e_ct-Ga1(t))*O2-Ga1(t)*C1
O2'=e_ct*O1-(e_tc+Gd2)*O2+Ga2*C1
C1'=Gd2*O2-(Gr+Ga2)*C1
}
But this wouldn't allow you to use a simple for loop like
Code: Select all
for i=0,100 {
t = i*0.1
print t, objrefname.Ga2(t)
}
to examine how Ga2 varies with t. Why? Because a is what determines whether the value of Ga2 is generated by f1 or f2, and a will not change unless you run a simulation.
So the function for Ga2 should be
Code: Select all
FUNCTION Ga2(t) {
if ((a==0) && (t<toff)) {
Ga2 = f1(t)
} else {
Ga2 = f2(t)
}
}
and this will work during a simulation, or if you call the function directly from hoc with a simple for loop (as long as you call finitialize() first so that a is set to 0), e.g.
Code: Select all
finitialize()
for i=0,100 {
t = i*0.1
print t, objrefname.Ga2(t)
}