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

model leads to a compiler error (undefined identifier)

model leads to a compiler error (undefined identifier)

The attached model is a small part of a SystemDynamics package. Check and instantiation work, but compiling leads to the error:

Translation    17:34:26        0:0-0:0    Error building simulator. Buildlog: gcc   -falign-functions -march=native -mfpmath=sse -fPIC   -I"/usr/include/omc" -I. -L"/home/peter/tmp/raus"   -c -o TestConveyor.o TestConveyor.c
TestConveyor.c: In Funktion »eqFunction_5«:
TestConveyor.c:289:33: Fehler: »$P$PRE$Pconstantflow1$PconstRate« nicht deklariert (erste Benutzung in dieser Funktion)
TestConveyor.c:289:33: Anmerkung: jeder nicht deklarierte Bezeichner wird nur einmal für jede Funktion, in der er vorkommt, gemeldet
make: *** [TestConveyor.o] Fehler 1

Any suggestions for a workaround are highly welcome!
    Greetings
        Peter

------

Update error, therefore code following:

TestConveyor.mo
------------------------

connector MassPort
  flow Real dm;
  Real data; 
end MassPort;

model ConstantFlow
  MassPort outflow;
  parameter Real constRate = 1.0;
protected
  Real inRate;
  Real rate;
equation
  rate = inRate;
  outflow.dm = -rate;
  inRate = constRate;
end ConstantFlow;

model Conveyor
  MassPort inflow(data(start=0));
  MassPort outflow(data(start=0));
  Modelica.Blocks.Interfaces.RealOutput out1;
  parameter Integer nDelay = 5;
  parameter Modelica.SIunits.Time samplePeriod = 1;
  parameter Modelica.SIunits.Time startTime = 0.1;
protected
  Real store[nDelay-1];
  Real load, last;
equation
  when sample(startTime, samplePeriod) then
    store[1] = pre(inflow.dm);
    store[2:end] = pre(store[1:end-1]);
    last = pre(store[end]);
    load = sum(store);
  end when;
  out1 = load;
  inflow.data = 0;
  outflow.data = last;
end Conveyor;

model TestConveyor
  ConstantFlow constantflow1(constRate = 2);
  Conveyor conveyor1;
equation
  connect(constantflow1.outflow,conveyor1.inflow);
end TestConveyor;

testConveyor.mos
-------------------------
loadModel(Modelica);
loadFile("TestConveyor.mo");
simulate(TestConveyor,startTime=0.0,stopTime=6.0);
plot(conveyor1.outflow.dm);

Edited by: peterjunglas - Jun-12-12 18:52:03

Re: model leads to a compiler error (undefined identifier)

Our bugtracking system is down right now so I cannot find the relevant bug to link for you, but I could probably find similar ones that were fixed.
The issue here is that you have pre(x) where x is an alias of p, which happens to be a parameter. Since parameters cannot change, pre(x) = pre(p) = p and should have been replaced somewhere in the backend (but only the change to pre(p) was changed).
Note to self: Maybe our simplification routine should get an optional hashtable of variables and their variability so we could remove these things easier in the back-end... I'll ask the back-end people...

Re: model leads to a compiler error (undefined identifier)

fixed in revison 12049

Re: model leads to a compiler error (undefined identifier)

You can buy a commercial simulation program, throw bug reports in a black hole, pay for yearly updates and hope that some of  your bugs have been fixed in a year or so (and I could name a few examples!).

Or you can use OpenModelica!

Thanks for your fast help
   Peter

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