Opened 8 years ago

Closed 8 years ago

#4189 closed defect (fixed)

OMC compiles models with no parameter-binding equations without giving warning/errors

Reported by: casella Owned by: somebody
Priority: critical Milestone: 1.12.0
Component: Frontend Version:
Keywords: Cc:

Description (last modified by casella)

Consider the following model

package TestParameter
  model M1
    parameter Real p;
  end M1;

  model M2
    M1 m;
  end M2;
end TestParameter;

If I compile it with OMC, I get no error or warnings. When the simulation runs, I get p = 0.

The Modelica Specification 3.3 r1, Section 8.6, states that

  • For all variables declared as constant and parameter, with fixed = true; no equation is added to the initialization equations
  • If a parameter has a start-expression, does not have fixed=false, and neither has a binding equation nor is part of a record having a binding equation, the start-expression can be used as parameter-expression although a diagnostic message is recommended when initializing the model without setting the parameter value.

As p is a Real variable, Sect. 4.8.1 defines a default start-expression 0 - I guess this was used to define p = 0. However, according to the Specification, a warning message should be issued here. In fact, the intent of leaving parameter p in model M without a binding equation is precisely to force the user to set it in a modifier when instantiating the model, and to get at least a warning if this is not done.

Note that in this case, Dymola actually returns an error

The following parameter doesn't have any value: m.p

implicitly ignoring the default start-expression of the Real type when looking for the start expression of parameter m.p, since the parameter has not been explicitly set by a modifier.

At least a warning should be issued in this case. IMHO, an error would be preferable, and maybe a clarification of the Specification in this respect could be useful.

Change History (2)

comment:1 Changed 8 years ago by casella

  • Description modified (diff)

comment:2 Changed 8 years ago by ptaeuber

  • Resolution set to fixed
  • Status changed from new to closed

A warning is added in bff7053.

Note: See TracTickets for help on using tickets.