Can ‘delay’ statement be used in explicit equations? If yes, how would it be coded? Suppose to simulate this case - C0 is to be constant from t=0 to 5 hr. Afterward, It starts to decline mono-exponentially. Can this case be handled by ‘delay’? I tried the following, but it didn’t work.
When you write the delay statement and here you are talking about discrete delay, you need a differential equation for the variable you delay. For example you can write
deriv(A1=-k*A1)
C=A1/V
cdelay=delay(C,tlag)
Since C depends on A1 and we have A1 defined as a differential equation, it will work.
In your example I do not know what you delay and delay(t,T) has no meaning unless you would have a differential equation for t or a function of it.
I want to add that the delay can be used in assignments:
cdelay=delay(C,tlag)
but also in differential equations also it is good to know that a differential equation can be defined conditionally like this:
deriv(z = t < T ? 0 : … k1/k2*(1-exp(-k2*(t-T)))*z)
in the above you are defining the equation in what happens before time is less than the variable T here a simple zero but can be any funciton. then what happens when this condition is not met:
you can read it like this
when t < T ? do this : otherwise do that