Opened 11 years ago

Closed 11 years ago

#2504 closed defect (fixed)

Initialization: start value which is an unfixed parameter

Reported by: Christian Schubert Owned by: Lennart Ochel
Priority: high Milestone: 1.9.1
Component: Backend Version: trunk
Keywords: Initialization start value unfixed parameter Cc: Willi Braun, Jens Frenkel, Volker Waurich, georg.hess@…

Description

Hi,

while converting a model from Dymola to OpenModelica we encountered the following problem, which I hope is easy to fix.

Consider the following model

model UnfixedParameter
    parameter Real c(fixed = false);
    Real x(start=c,fixed=true);
initial equation 
    c = 1;
equation 
    der(x) = -x;
end UnfixedParameter;

Instead of starting at x(t=0)=1, it starts at 0 which is unexpected.
It's got probably to do with when start values are evaluated.

Attachments (1)

initial.mos (414 bytes ) - added by Christian Schubert 11 years ago.
Testfile

Download all attachments as: .zip

Change History (9)

by Christian Schubert, 11 years ago

Attachment: initial.mos added

Testfile

comment:1 by georg.hess@…, 11 years ago

Cc: georg.hess@… added

comment:2 by Lennart Ochel, 11 years ago

Status: newaccepted

comment:3 by Lennart Ochel, 11 years ago

I get the following messages/errors:

Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed!
Warning: No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead.
- BackendVariable.vararrayNth 1 has NONE!!!

I will fix it.

comment:4 by Vitalij Ruge, 11 years ago

This issue see very close to #2207

comment:5 by Lennart Ochel, 11 years ago

The previously mentioned errors just occurred due to my corrupted omc version.
The combination of a fixed state having a start-expression depending on an unfixed parameter is not yet supported. Good ticket ;-)

comment:6 by Lennart Ochel, 11 years ago

Resolution: fixed
Status: acceptedclosed

Again, this is a very good ticket. Thanks for contributing it. I included the model from above in the test suite.

Fixed in r18967.

@Volker: Some hpcom tests need to get updated. Can you do that?

comment:7 by georg.hess@…, 11 years ago

Resolution: fixed
Status: closedreopened

Unfortunately, this doesn't completely fix my problem.
Consider the following model

model Fehler
encapsulated model SubModel
  parameter Real n = 1 annotation(Evaluate = true);
end SubModel;

  parameter Real n_b(fixed = false, start = 2);

  SubModel subModel(n = n_b);

initial equation 
  n_b = 5;

end Fehler;

The value of parameter n is not correctly calculated if n has the annotation Evaluate=true. If the annotation is not present everything works fine.

in reply to:  7 comment:8 by Lennart Ochel, 11 years ago

Resolution: fixed
Status: reopenedclosed

Replying to georg.hess@…:

Unfortunately, this doesn't completely fix my problem.
Consider the following model

model Fehler
encapsulated model SubModel
  parameter Real n = 1 annotation(Evaluate = true);
end SubModel;

  parameter Real n_b(fixed = false, start = 2);

  SubModel subModel(n = n_b);

initial equation 
  n_b = 5;

end Fehler;

The value of parameter n is not correctly calculated if n has the annotation Evaluate=true. If the annotation is not present everything works fine.

n should be initialized with 5. This is the case with and without the Evaluate annotation. The annotation is a Compiler hint to get speedup during symbolic manipulation. (Annotations should never effect the symbolic results of a model.) Hence, your model is working fine and I see no wrong behavior of OpenModelica.

Note: See TracTickets for help on using tickets.