Jump to content


Photo

'delay' statement

delay

  • Please log in to reply
3 replies to this topic

#1 Cuyue Tang

Cuyue Tang

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 17 November 2017 - 03:43 PM

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.

 

What are other ways to handle this case?

 

Thanks,

Cuyue

 

C=(1-w)*C0 + w*(C0*exp(-k*delay(t,T)))

double(w)
sequence{
w=0
sleep(T)
w=1
}
error(eps = 0)
observe(CObs = C + eps)
stparm(C0 = tvC0)
stparm(k = tvk)
stparm(T = tvT)
fixef(tvC0 = c(, 10, ))
fixef(tvk = c(, 0.693, ))
fixef(tvT = c(, 5, ))

 



#2 serge guzy

serge guzy

    Advanced Member

  • Members
  • PipPipPip
  • 485 posts

Posted 17 November 2017 - 05:54 PM

 

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.

 

What are other ways to handle this case?

 

Thanks,

Cuyue

 

C=(1-w)*C0 + w*(C0*exp(-k*delay(t,T)))

double(w)
sequence{
w=0
sleep(T)
w=1
}
error(eps = 0)
observe(CObs = C + eps)
stparm(C0 = tvC0)
stparm(k = tvk)
stparm(T = tvT)
fixef(tvC0 = c(, 10, ))
fixef(tvk = c(, 0.693, ))
fixef(tvT = c(, 5, ))

 

Dear colleague

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.

 

Best Regards

Serge



#3 Cuyue Tang

Cuyue Tang

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 17 November 2017 - 09:25 PM

Serge, you answered my question.  Your prompt response is much appreciated.

 



#4 smouksassi1

smouksassi1

    Advanced Member

  • Members
  • PipPipPip
  • 231 posts
  • LocationMontreal

Posted 20 November 2017 - 02:29 PM

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

 

 







Also tagged with one or more of these keywords: delay

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users