Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Attributes and the keyword "parameter."

Attributes and the keyword "parameter."

I'm trying to get a complete grasp on the syntax of variable declarations.

If the keyword "parameter" is used, like this:

parameter Modelica.SIunits.Length d(unit="unit", start=1.0, min=0) = 0.06 "diameter of shell";

OpenModelica does not throw any warnings or errors when I check the model.

What is the point of specifying a start or a min for a parameter?

Assuming start is the same thing as assignment with an equals sign, which one takes priority here?

Re: Attributes and the keyword "parameter."

I did some testing in OMEdit.

I can check (without errors/warnings) and run code with the following line:

  CelestialBody moon(name = "moon", mass(unit="kg, start = 7000)= 7.382e+22, radius = 1738000.0);

The actual moon.mass will be 7.382e+22 at start.  If I change the line to:

  CelestialBody moon(name = "moon", mass(unit="kg", start = 7000), radius = 1738000.0);

The checker will complain that there aren't enough equations (implying that moon.mass isn't defined?).

Am I to conclude that, for parameters, start does nothing?  Is this an error in OpenModelica?  Do min and max have any  meaning here?

Re: Attributes and the keyword "parameter."

min and max are basically shortcuts for writing

Code:

assert(x <= maxValue, "...");

assert(x >= minValue, "...");

Start values are more complicated. I suggest reading some literature. Sometimes it is used as a guess value for the initial solver. And sometimes it is used as an initial equation (fixed=false vs. fixed=true).

The following is a nonsense start-value which is also ignored because it is not used to calculate the start-value of a state or initial value. x is always 25 current/smile

Code:

Real x(start = 15) = 25;

There are 0 guests and 0 other users also viewing this topic
You are here: