Printable Version of Topic

Click here to view this topic in its original format

Modelica Forum _ Modelica _ Maximum value of a continuous variable

Posted by: Jonathan Apr 2 2009, 11:28 AM

Hello,

I try to obtain the maximum value of a continuous variable. For this I have used two different approaches:
For the two approaches u = input and y = output (i.e. the max value of u)

1 - y=max((u), y)
This solution involvess non-linear solving and makes th e simulation heavier.

2- Detection of a max value by using a derivative of the input signal u. Comparing this value with the precendent detecting local maximum and keeping the bigger (bloc triggeredMax in the standard Modelica Library).
This solution requires a derivation and is not efficient in case of a monotonic varaition of the input signal.

Do you know another more efficient solution ?

Thanks in advance.


Posted by: Lars Apr 14 2009, 06:46 AM

Have you tried something along the lines of

y=max((u), pre(y))

to avoid the nonlinear equation?

Posted by: RungeZipperer Apr 14 2009, 09:04 AM

Itīs not so easy using continuous signals. Using discrete signals is very easy but leads to slower simulation speed.

Another approach (not tested) could be:

CODE

block HoldMax
extends Modelica.Blocks.Interfaces.SISO;
  parameter Modelica.SIunits.Time delaytime(min=1E-4)=0.001;
protected
  discrete Real max(start=0);
algorithm
  when noEvent(abs(delay(u, delaytime)))>max then
    max:=noEvent(abs(u));
  end when;
  y:=max;
end HoldMax;

Posted by: Roland May 6 2009, 10:11 AM

How about this:

CODE
block HoldMax
extends Modelica.Blocks.Interfaces.SISO;
  parameter Modelica.SIunits.Time delaytime(min=1E-4)=0.001;
equation
  if der(u) > 0 then
    der(y) = if u > y then der(u) else 0;
  else
    der(y) = 0;
  end if;
end HoldMax;


Uses the derivative again. Should only be a problem with discontinuous input signals.

Roland

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)