Help - Search - Members - Calendar
Full Version: Maximum value of a continuous variable
Modelica Forum > Modelica > Modelica
Jonathan
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.

Lars
Have you tried something along the lines of

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

to avoid the nonlinear equation?
RungeZipperer
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;
Roland
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
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.