Opened 17 years ago

Closed 12 years ago

#128 closed defect (fixed)

Default fixed=true attribute set to state variables even when not meant

Reported by: Francesco Casella Owned by: Francesco Casella
Priority: critical Milestone:
Component: Backend Version:
Keywords: Cc: Francesco Casella, Adrian Pop

Description


Attachments (1)

TestInit.mo (1.5 KB ) - added by Francesco Casella 17 years ago.
Test Modelica file

Download all attachments as: .zip

Change History (4)

comment:1 by Francesco Casella, 17 years ago

The OMC automatically and silently sets a fixed = true attribute to all the state variables, unless the attribute fixed = false is explicitly set in the code. This is contrary to the Modelica specification, which states that the default value for variables is fixed = false (section 4.8.1, rev. 3.0).

This behaviour causes models to behave differently from what one would expect.

  1. Simulate TestInit.Example1_3. The following warning is generated: "Warning, no variable has fixed=false but model contains initial equations. Setting fixed=false to the following variables: x". In fact, according to the specification, x already has a fixed = false attribute by default, so why bother?
  1. Simulate TestInit.Example2_1. The following warning is generated: "Warning, no variable has fixed=false but model contains initial equations. Setting fixed=false to the following variables: ". Unfortunately, the list is empty, x is not set to fixed = false, therefore the simulation starts with x=0, while it should start at x=1. This happens correctly if fixed = false is set explicitly on x (TestInit.Example2_3), but this should not be necessary.
  1. Simulate TestInit.Example3_1. The start value 0.5 is meant to steer the solver towards one of the infinite number of initial states, not to provide an actual initial value. However, the simulation starts at 0.5, because a fixed = true attribute was implicitly set on x. In order to avoid this, one has to set fixed = false explicitly (Example3_2), but once again this should not be necessary.

Always adding this fixed = true attribute will be even more questionable once OMC supports state selection.

Suggestions:

  1. The fixed = true flag should not necessarily be set automatically for all state variables
  2. In particular, when initial equations are explicitly stated in the model, the user should have control over the default initial equations
  3. One option could be the one adopted by Dymola. Once all the explicit initial equations have been considered, if they are not enough fixed = true attributes are added to state variables not appearing explicitly in the initial equations, until a square system is obtained.
  4. It should be possible to get a list of all the fixed = true attributes added by the compiler
  5. It would be nice to have some kind of interface in order to steer this selection (I don't have definite ideas how to do that, but we might think about it)

by Francesco Casella, 17 years ago

Attachment: TestInit.mo added

Test Modelica file

comment:2 by Francesco Casella, 17 years ago

Created an attachment (id=18)
Test Modelica file

comment:3 by Francesco Casella, 12 years ago

Component: Backend
Resolution: fixed
Status: newclosed

OMC 1.9.0 beta implements the correct semantics

Note: See TracTickets for help on using tickets.