Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5457 closed defect (duplicate)

Re-simulation does not consider updated value

Reported by: massimo ceraolo Owned by: somebody
Priority: high Milestone: 1.14.0
Component: *unknown* Version: v1.13.2
Keywords: Cc:

Description (last modified by massimo ceraolo)

Consider the following model

model Test2 
  import Modelica.Constants.pi;
  parameter Real Ipm = 1.5;
  parameter Real varPar (fixed=false);
initial equation
  if Ipm>1.0 then
    varPar=pi/2;
  else
    varPar=asin(Ipm);
  end if;
equation
end Test2;

When run from OMEdit with default simulation parameters (and "Evaluate all parameter at compile time" unchecked) I get for varPar, correctly 1.5708.

Now I change, from the plotting perspective, Ipm from 1.5 to 0.5, and click on re-simulate button.
Then varPar remains at the old value instead of changing into 0.523599.
Checked with Connected to v1.14.0-dev-234 under windows (64 bit)

Change History (10)

comment:1 by massimo ceraolo, 6 years ago

Summary: An issue with parameters and and initial equationsAn issue with parameters and initial equations

in reply to:  description comment:2 by Arinomo <trista.arinomo@…>, 6 years ago

Replying to ceraolo:

In the following model I get always varPar=pi/2, whatever value I give Ipm.

model Test2 
  import Modelica.Constants.pi;
  parameter Real Ipm = 1.5;
  parameter Real varPar (fixed=false);
initial equation
  if Ipm>1.0 then
    varPar=pi/2;
  else
    varPar=asin(Ipm);
  end if;
equation
end Test2;

Your model work for me using ver1.14.0-def. With Ipm = 1.5, i got varPar = 1.5708 and for Ipm = 0.5, i've got varPar = 0.523599.Do you have any additional flags set?

comment:3 by massimo ceraolo, 6 years ago

Well, my report was bad.
I'm going to change name and description of the ticket in the next few minutes.

comment:4 by massimo ceraolo, 6 years ago

Description: modified (diff)
Summary: An issue with parameters and initial equationsRe-simulation does not consider updated value

comment:5 by Arinomo <trista.arinomo@…>, 6 years ago

Could you test this itteration?

model initParam
  import Modelica.Constants.pi;
  parameter Real Ipm;
  parameter Real varPar(fixed=false);
initial equation
  if Ipm>1.0 then
    varPar=pi/2;
  else
    varPar=asin(Ipm);
  end if;
equation
end initParam;

if I understand it correctly, Re-Simulate doesn't re-build/re-compile your model, since you set Ipm to 1.5, it always take that value. But if you arn't defining Ipm, you can change its value and got a right simualtion result. Or you could set

parameter Real Ipm(start=1.5, fixed=false);

but somehow i cannot cahnge the value if it set to parameter and have a start value.

comment:6 by massimo ceraolo, 6 years ago

Your initParam works as expected.

I suspect that in this ticket's model Ipm is not changeable since it is used in an if condition and therefore considered to be a structural parameter.
In this case, however, the edit box under the Value column should not appear.

Yes, I'm pretty sure this is the reason. For this I'm going to change again this ticket's description and its priority :-)

Version 0, edited 6 years ago by massimo ceraolo (next)

comment:7 by massimo ceraolo, 6 years ago

Resolution: duplicate
Status: newclosed

comment:8 by massimo ceraolo, 6 years ago

duplicate of #5454

in reply to:  6 comment:9 by Arinomo <trista.arinomo@…>, 6 years ago

Replying to ceraolo:

Your initParam works as expected.

I suspect that in this ticket's model Ipm is not changeable since it is used in an if condition and therefore considered to be a structural parameter.
In this case, however, the edit box under the Value column should not appear.

Yes, I'm pretty sure this is the reason. I'm going to close this ticket.

Just to an idea, you could also define Ipm as input

input Real Ipm(start=1.5,fixed=fasle)

so you can change the value in plotting view. Hope it helps.

in reply to:  6 comment:10 by Francesco Casella, 6 years ago

Replying to ceraolo:

I suspect that in this ticket's model Ipm is not changeable since it is used in an if condition and therefore considered to be a structural parameter.

Absolutely.

In this case, however, the edit box under the Value column should not appear.

That's the subject of #5454, I've added a comment there.

Note: See TracTickets for help on using tickets.