Ticket #74 (new defect)

Opened 2 months ago

Last modified 4 days ago

how to re-initialze a contiuous variable which isn't a state

Reported by: AHaumer Owned by: ModelicaDesignList
Priority: normal Milestone: Design58
Component: --Modelica Specification-- Version: 3.0
Severity: normal Keywords: reinit
Cc: Hide ticket: no

Description

The Modelica specification doesn't allow to reinit a continuous variable which isn't a state;
but how should I get the peak value of a signal with respect to predefined periods:

block PosPeak "Positive peak during one period"
  extends Modelica.Blocks.Interfaces.SISO;
  parameter Modelica.SIunits.Frequency f=1 "Basic signal frequency";
protected
  Real x;
equation
  x=max(u,x);
  when sample(0, 1/f) then
    y=x;
    reinit(x,u); // not standard compliant!
  end when;
end PosPeak;

Attachments

Change History

  Changed 2 months ago by dietmarw

  • hide_ticket unset
  • component changed from *unspecified* to --Modelica Specification--

in reply to: ↑ description   Changed 4 days ago by sebastien

Replying to AHaumer:

The Modelica specification doesn't allow to reinit a continuous variable which isn't a state;
but how should I get the peak value of a signal with respect to predefined periods:
{{{
block PosPeak "Positive peak during one period"
extends Modelica.Blocks.Interfaces.SISO;
parameter Modelica.SIunits.Frequency f=1 "Basic signal frequency";
protected
Real x;
equation
x=max(u,x);
when sample(0, 1/f) then
y=x;
reinit(x,u); // not standard compliant!
end when;
end PosPeak;
}}}

This model is not correct. "x=max(u, x)" does not constraint x when x >= u. IMO a correct version is:

block PosPeak "Positive peak during one period"

extends Modelica.Blocks.Interfaces.SISO;
parameter Modelica.SIunits.Frequency f=1 "Basic signal frequency";

protected

Real x;

equation

der(x) = if u >= x then der(u) else 0;
when sample(0, 1 / f) then

y = x;
reinit(x, u);

end when;

end PosPeak;

so that x is now a real state.

Add/Change #74 (how to re-initialze a contiuous variable which isn't a state)

Author



Action
as new
 
Note: See TracTickets for help on using tickets.