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

Simulation error: Variable not referenced

Simulation error: Variable not referenced

Hello,

I have a simple model (see below) which fails to simulate with the current (9772) nightly windows build. I get an error about an unreferenced variable.


class Loop
  input Real sIn;
  output Real sOut;
equation
  sOut = sIn;
  //connect(sIn, sOut);
end Loop;

// This model works
model Test
  Real sIn;
  Real sOut;
  Loop l;
equation
  sIn = time;
  connect(sIn, l.sIn);
  connect(l.sOut, sOut);
end Test;

// This model does not work
model TestArray
  Real sIn;
  Real sOut;
  Loop l[1];
equation
  sIn = time;
  connect(sIn, l[1].sIn);
  connect(l[1].sOut, sOut);
end TestArray;

The error message is:
Error: Variable l[1].sIn is not referenced in any equation (possibly after symbolic manipulations)

The model TestArray references a block with an array variable of length one. If I do not use the array (model Test) it works.

Note also, that the model worked in older versions of OpenModelica, namely the last version (9366) of the nightly builds. Also, if I use the connect statement within the Loop block it works as well.

Am I missing something here or is this an error of OpenModelica?


Greetings,

Michael

Re: Simulation error: Variable not referenced

I get (after changing order of optimization modules):

Code:

Error: An independent subset of the model has imbalanced number of equations (2) and variables (1).

variables:
sIn
equations:
1 : sIn = time
2 : l[1].sIn = sIn

So something is probably wrong with the incidence matrix (it splits the equation-systems based on it); I'll have a look.

Re: Simulation error: Variable not referenced

Seems to be an OpenModelica error for sure current/smile

Code:


Variables (5)
=========
1: output  l[1].sOut:VARIABLE() .TestArray, .Loop, .Real type: Real [1]
indx = -1
2: input  l[1].sIn:VARIABLE() .TestArray, .Loop, .Real type: Real [1]
indx = -1
3:  sOut:VARIABLE() .TestArray, .Real type: Real  indx = -1
4:  sIn:VARIABLE() .TestArray, .Real type: Real  indx = -1
5:  $dummy:STATE(fixed = true )  type: Real  indx = -1

Equations (5)
=========
1 : l[1].sOut = l[1].sIn
2 : sIn = time
3 : l[1].sIn = sIn
4 : l[1].sOut = sOut
5 : der($dummy) = 0.0

number of rows: 5
1:2 1
2:4 // sIn, OK
3:4 // sIn, NOT OK - l[1].sIn missing
4:3
5:5

Anyway, you can avoid the error by using setCommandLineOptions("+preOptModules=removeFinalParameters,removeEqualFunctionCalls,expandDerOperator,removeSimpleEquations")

This will cause the offending optimization module to not run

Re: Simulation error: Variable not referenced

Thank you for your help, however, your suggested set of parameter gives me another error:

Error: Internal error - BackendDAETransform.reduceIndexDummyDer failed!
[../test.mo:24:3-24:13:writable] Error: Model is structurally singular, error found sorting equations sIn = time;
for variables

This also only effects the TestArray model, the other (model Test) still simulates without errors.

Regards,

Michael

Re: Simulation error: Variable not referenced

That error is related to the first one I think.

One equation has l[1]/*OTHER*/.sIn/*REAL*/ instead of l[1]/*DAE.ET_COMPLEX():unknown*/.sIn/*REAL*/. The internal type gets messed up somewhere and causes getVar() to fail, which means it think it has an equation without any variable in it.

Re: Simulation error: Variable not referenced

These should all work in r9802 (available in 26~27 hours from now)

Re: Simulation error: Variable not referenced

Martin S. was talking about Linux/Mac builds (availability) which are automatic.
If you're using the windows builds I'll make one by tomorrow and let you know
when is available.

Cheers,
Adrian Pop/

Re: Simulation error: Variable not referenced

Hi,

I'm uploading a new build now:
http://build.openmodelica.org/omc/build … ly-builds/
Sorry for the delay.

Cheers,
Adrian Pop/

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