Opened 7 years ago

Closed 7 years ago

#4499 closed task (duplicate)

Reinit of variables

Reported by: jal.panchal@… Owned by: Jal Panchal
Priority: high Milestone: Future
Component: *unknown* Version: v1.12.0
Keywords: reinit, when Cc:

Description

I faced a problem while using reinit in my code and I have extracted the essential parts into the code below

model eracticWhenCondition
  Modelica.Blocks.Sources.Sine sine1(amplitude = 1, freqHz = 0.5)  annotation(
    Placement(visible = true, transformation(origin = {-58, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Real x (start = 1);
  Real y,z,a,b;

  equation
  when sine1.y < 0.8 then
      reinit(x, 1);
  end when;
  
  when sine1.y > -0.8 then
     reinit(x ,-1);
  end when;
  
  x = 1;
  
  y = x;
  z = x*1;
  a = x*(-1);
  b = x*2;
end eracticWhenCondition;

What I observed was, x is switching between -1 and 1 correctly, so is y and z. But a and b get constant values of -1 and 2.

So either such an equation should raise an error or the calculation must be done rightly for a and b.

Change History (1)

comment:1 Changed 7 years ago by lochel

  • Reporter changed from jal.panchal@… to jal.panchal@…
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.