Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

How to make a time delay, W(t - R)

How to make a time delay, W(t - R)

Here is my code i am trying to achieve active queue management algorithm
in line 6 there is a logical error, what i wat to achieve is w(t-R) and q(t-R) respectivelyhttp://cs630419.vk.me/v630419263/205df/ui_5kRbt6cQ.jpg
https://openmodelica.org/images/agorapro/attachments/5012/mini_Снимок.PNG

but i have searched and haven't been able to find it, i am rather new at modelica and would appreciate the help
N = 1, R = 1, K = 5; 3, C = 1, W(0) = 0; 1,Q(0) = 1
where R(t)=1 just a small reference although it could be understood i guess

1)class generic
2)Real N,K,C,R;
3)Real w(start=0.1),q(start=1);
4)//AQM:
5)equation
6)    der(w)=1/R - (((w*(w-R))/2*R)*K*(q-R));
7)    der(q)=if q>0 then (N*w/R)-C else 0 ;       
8)end generic;

Attachments:

Re: How to make a time delay, W(t - R)

Re: How to make a time delay, W(t - R)

This seems to have worked..


Code:



model TimeDelay_OMForum
  parameter Real N = 1;
  parameter Real R = 1;
  parameter Real K = 5.3;
  parameter Real C = 1;
 
  Real W(start = 0.1);
  Real Q(start = 1);
 
  Real Wdelay;
  Real Qdelay;
 
equation
  Wdelay = delay(W, R);
  Qdelay = delay(Q, R);
 
  der(W) = (1/R) - (W*Wdelay*K*Qdelay)/(2*R);
 
  der(Q) = if Q > 0 then ((N*W)/R - C)  else max(((N*W)/R - C) ,0);

 
end TimeDelay_OMForum;

There are 0 guests and 0 other users also viewing this topic
You are here: