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

Order of equations does matter?! Class w/ string, number of variables

Order of equations does matter?! Class w/ string, number of variables

Hey everyone,

I found some weird behavior when looking for a bug in my code. I managed to break it down to this. If you have any idea where this comes from or why modelica behaves this way, please let me know.

I am using OMNotebook to simulate the "Test" class by calling

Code:

simulate(Test)

So the following Model can be simulated without a problem:

Code:

class Pool

  AClass ac;
end Pool;

class AClass
  BClass bc;
end AClass;

class BClass
  String description;
end BClass;

class Test
  AClass aclass;
  BClass b1(description="skdjfhg");
  Pool pool;
equation
  pool.ac = aclass;
  aclass.bc = b1;
end Test;

whereas the next one gives an error about the number of input variables between the model and init file ("Error, input data file does not match model"). Notice that the only difference is the order between the two lines in the equation section:

Code:

class Test 

  AClass aclass;
  BClass b1(description="skdjfhg");
  Pool pool;
equation
  aclass.bc = b1;
  pool.ac = aclass;
end Test;   

Thanks for your ideas. For now i will simply use the first way, but I found it interesting that this happens, while in the Modelica specifications it is clearly written that the order of equations does not matter.

Re: Order of equations does matter?! Class w/ string, number of variables

Hi,

Can you please provide more information. I tried the steps you said and I didn't get any error.
Download and check this test OMNotebook file http://www.ida.liu.se/~adeas31/NotebookTest.onb

Adeel.

Re: Order of equations does matter?! Class w/ string, number of variables

Hey,

if I run your OMNotebook file I get the same error as with my code when running the second "simulate()". The exact message is:

Code:

messages = "Simulation execution failed for model: Test

Error, input data file does not match model.
nx in initfile: 1 from model code :1
ny in initfile: 0 from model code :0
np in initfile: 0 from model code :0
npint in initfile: 0 from model code: 0
nyint in initfile: 0 from model code: 0
npbool in initfile: 0 from model code: 0
nybool in initfile: 0 from model code: 0
npstr in initfile: 0 from model code: 0
nystr in initfile: 2 from model code: 3
",

I have OMNotebook version 3.0 with OMC 1.7.0 running under Windows XP.

I tried the same thing with an integer instead of String and then there is no error, so maybe this has something to do with it.

Thanks for your help!

Re: Order of equations does matter?! Class w/ string, number of variables

Hi,

Any reason for using the ancient OpenModelica 1.7.0?
You can upgrade to our latest nightly build:
https://build.openmodelica.org/omc/buil … ly-builds/
or to the latest release: 1.8.1:
https://build.openmodelica.org/omc/buil … ses/1.8.1/

Cheers,
Adrian Pop/

Re: Order of equations does matter?! Class w/ string, number of variables

Hey,

I installed version 1.8.1 and now the script runs correctly. Thank you for your help!

However, since I upgraded from a really old version it seems, I now have some problems in other parts of my model. This concerns Connectors: I am using them to transmit signals between classes, but since in 1.8.1 I am forced to have equal number of flow and non-flow variables in connectors I used the input/output variation. My quastion is now how to assign or change the value of such a variable?

Code:


connector Port_in
  input Boolean Signal (start=false);
end Port_in;

and this line

Code:

instanceOfPort_in.Signal  := true;

gives me the following error message:

Error: Trying to assign to input component.

Thanks again, jcm

Re: Order of equations does matter?! Class w/ string, number of variables

Actually I just found out, that in OMNotebook the fact that having an unequal number of flow and non-flow variables inside a connector leads to an error, whereas in OMEdit this only gives a warning, but compilation works otherwise. I'll use this for now.

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