Hello,

I'm working on a package where I would eventually like to support both
Dymola and OpenModelica. One part relies on quite a bit of
pre-processing to initialize several parameters before models are
simulated. I haven't found a good way to do this in OpenModelica. The
following example shows several ways I've tried to initialize
parameters. The first two (m1 and m2) simulate, but the parameters are
not initialized properly. The second two (m3 and m4) fail when
generating code. Does anyone see errors in my code or know of
workarounds for this? All models seem to flatten properly and pass
check (except for m4).

package testInitialAlgorithm
  model m1
    parameter Real a = 3;
    parameter Real b(fixed = false);
  initial algorithm
    b:=a ^ 2;
  end m1;

  model m2
    m1 m(a = 4);
    Real c;
  equation
    c = m.b + 1.0;
  end m2;

  function fun
    input Real x;
    output Real y;
    output Real z;
  algorithm
    y:=x ^ 2;
    z:=x ^ 3;
  end fun;

  model m3
    parameter Real a = 3;
    parameter Real b(fixed = false);
    parameter Real c(fixed = false);
  initial equation
    (b,c) = fun(a);
  end m3;

  model m4
    parameter Real a = 3;
    parameter Real b(fixed = false);
    parameter Real c(fixed = false);
  initial algorithm
    (b,c):=fun(a);
  end m4;
end testInitialAlgorithm;

The model m3 fails with the following error:

    CodegenC.tpl: Template error: Unknown expression: (b,c)

The model m4 fails with the following error:

  Tuple assignment only allowed when rhs is function call (in
testInitialAlgorithm.fun(a))

I tested this on r11033 on 64-bit win7 and r11047 on ubuntu.

- Tom

Reply via email to