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

partial models in 1.14

partial models in 1.14

I have subscribed the stable release that has updated from 1.13.2 (latest release) to 1.14.0~dev.beta1-7-g9a11e9c. Now many of my developments are not working under the new compiler frontend. I can switch the the old frontend and everything work as expected.
The main difference is related to "partial model"
ExamplePartModel.mo
I add an example. If I am using variables in the partial model that are defined elsewhere, the compiler ends with an error message. "variable y not found".
I did not find any hind in the documentation. I think one sense of a "partial model" is that it could be a part of a "normal" model, where of cause all variables has to be declared.
My question is this a bug or a shift in paradigm?
Best regards
Joachim

Re: partial models in 1.14

This is a bug in the old frontend and shouldn't work, the old frontend doesn't handle inheritance correctly. The variable must be reachable in the scope where it's used, but y is not declared inside the include model. In other words, the name resolution is done in the scope where a variable is used, not the scope it's inherited into.

Re: partial models in 1.14

thank you for the explanation. But this makes the use of partial models inattractive and the code longer.

Re: partial models in 1.14

It's not necessarily going to be (much) longer. You simply declare the variable in the partial model and modify it in the extends clause.

Re: partial models in 1.14

   record Soluble
    Real O2 "gO2/m3 dissolved oxygen";
    Real I "gCOD/m3 inert soluble organic material";
    Real S "gCOD/m3 readily biodegradable organic substances";
    Real NH "gN/m3 ammonium + ammonia N";
    Real NO "gN/m3 nitrite + nitrate N";
    Real ND "gN/m3 dissolved organic N";
    Real ALK "mol/m3 alkalinity";
  end Soluble;

  record Particulate
    Real H "gCOD/m3 heterotrophic bacteria";
    Real A "gCOD/m3 autotrophic bacteria";
    Real S "gCOD/m3 particulate slowly degradable substrates";
    Real I "gCOD/m3 inert particulate organic material";
    Real P "gCOD/m3 inert particulate organic matter resulting from decay";
    Real ND "gN/m3 particulate organic nitrogen";
  end Particulate;


SS in the partial model and S in the main model  are defined as record Soluble
XX in the partial model and X in the main model  are defined as record Particulate

in the main model the partial model is included in the way.
extends WWParameters(SS = S, XX = X);

leeds to an error message
Component SS of variability parameter has binding 'DN1.S' of higher variability continuous.

So it's really hard for me to make use of the partial model approach. So I am starting a rollback and copying all partial model code into the model where they are needed. Or do I misunderstanding the error massage?
By the way the stable release Connected to OpenModelica 1.14.0~dev.beta3 crashes frequently, so at the moment i am intending to go back to the release 1.13.2
Joachim

Re: partial models in 1.14

jobehrendt wrote:


leeds to an error message
Component SS of variability parameter has binding 'DN1.S' of higher variability continuous.

That has nothing to do with partial. The error means that you're trying to give a parameter a continuous binding, like this:

Code:


model A
  parameter Real x;
end A;

model B
  Real y;
  extends A(x = y); // Not allowed.
end B;

The value of a parameter doesn't change during the simulation, so trying to give it a binding equation that can change is not allowed.

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