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

parameter values with equations?

parameter values with equations?

In Modelica modifications are made by means of equations (for instance in the following examples taken from sect. 7.2 of ModelicaSpec32):
Real altitude (start=59404)
parameter Real x=2;

To my understanding these should be assignments instead:
Real altitude (start:=59404)
parameter Real x:=2;

I say this because these modification copy the value at the right of sign "=" or ":=" into the variable at its left.
Indeed the Modelica grammar allows for these cases both "=" and ":=", but in the examples typically "=" is used and common tools' GUIs (such as OMEdit) use "="  when the user chooses parameter values.

I'm pretty sure that this has been chosen on purpose by Modelica designers and tool programmers.
But I cannot envisage the reasoning. They wanted there to be equations (at least either equations or assignments). To me they are definitely assignments, not equations.
Any opinions or comments about this?

Re: parameter values with equations?

You are only supposed to be able to use ":=" for bindings in functions (and then only use ":="). In all other cases "=". In the OpenModelica, we cannot distinguish between the two so both are accepted. Try for example:

Code:

loadString("model M

  Real r := time;
end M;");
list();

Re: parameter values with equations?

I see.
But what seems strange to me is that Modelica, that is so carefully designed in its syntax, and that is built from the ground up in the distinction between assignments (n algorithms, implementing imperative programming) and equations (in equation sections, implementing  the declarative programming paradigm) is so vague about bindings.
I really don't understand why they allow bindings written in equation form.
It seems to me that they really indicate assignments. But maybe I'm missing something.

Re: parameter values with equations?

what is (import ) in modelica
when should we use this straucture

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