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
  • Index
  • » Users
  • » wid80
  • » Profile

Posts

Posts

Jun-08-12 18:17:22
Some algorithms for initialization do not work
Category: Developer

Hi,

I have a model, which successful compiles and an exe is built. But to simulate this model, I have to invoke the exe manually from the command line with additional argument -iom simplex or -iom newuoa. All the other algorithms for initialization try to set the value of one variable to zero and then divide by that variable, which obviously gives an error. The two algorithms simplex and newoua determine the right value of this variable and the model simulates successfully.

Are there any bugs known in these algorithms for initialization? Unfortunately, I just have a very big model, with which I get this problem. Let me know, if you need more information.

Thanks, Marcel

Jun-08-12 17:49:31
There are several errors in CodegenC.tpl which lead to invalid c code
Category: Developer

Hi,

I just wanted to add to point 3 above, that the second argument in the call of "array_alloc_scalar_real_array" is "0" in my case. Perhaps that is the point why the third argument is omitted?!

There is actually one more point I'd like to add to the above list:

5. The function "array_alloc_scalar_string_array" (line 129 in string_array.h) exspects its third argument to be of type "modelica_string_t" but in the generated c code, the third argument is of type "modelica_string". The point here is, that this casts away constness, which is bad design and the compiler emits a warning. A possible solution for me is to change line 6541 in CodegenC.tpl and replace "modelica_string" by "modelica_string_t". Of course, one can also change the type of the third parameter in the declaration of that function. As far as I can see, this should have no effect on the simulation result.

That's all for now. Marcel

Jun-08-12 12:27:13
There are several errors in CodegenC.tpl which lead to invalid c code
Category: Developer

Hi,

I encountered several errors in the generated c file:

1. The template "functionInitSample" (line 619 in CodegenC.tpl) does not generate valid c code due to missing declarations of local variables: Adding <%varDecls%> in line 630 solved the problem for me.

2. In the template "functionExtraResiduals" (line 718 in CodegenC.tpl) the generated function "void residualFunc<%index%>" contains return types of the kind "something_rettype", which were never declared (no typedef or #define). I do not know how to resolve this bug.

3. A function call to "array_alloc_scalar_real_array" is generated with only two parameters in contrast to the declaration of this function, which exspects at least 3 arguments. To be precise, the third argument "modelica_real first" is missing. The prototype of this function is defined in the header file real_array.h line 135.

4. In the following generated function the type "struct Modelica_Fluid_Interfaces_FluidPorts__b" is never declared. Perhaps this bug may be due to the incomplete support of the Fluid library by omc

Code:


void eqFunction_1426(DATA *data) {
  struct Modelica_Fluid_Interfaces_FluidPorts__b tmp663;
  modelica_integer tmp664;
  modelica_boolean tmp665;
  switch ((modelica_integer) 1) { /* ASUB */
  default:
    assert(NULL == "index out of bounds");
  }

  tmp664 = cardinality(tmp663);
  SAVEZEROCROSS(tmp665, tmp664, (modelica_integer) 1, -1,LessEq,<=);
  if (!tmp665) {
    FILE_INFO info = {"C:/OpenModelica1.8.1/lib/omlibrary/Modelica 3.1/Fluid/Sources.mo",759,7,764,3,0};
    MODELICA_ASSERT(info, "\neach ports[i] of boundary shall at most be connected to one component.\nIf two or more connections are present, ideal mixing takes\nplace with these connections, which is usually not the intention\nof the modeller. Increase nPorts to add an additional port.\n");
  }
}

I know it would be good to have a short example to reproduce these errors. But unfortunately, I just have a relatively complex model which consists of several componets. If it helps, i can send you the entire package per e-mail.

I used revision 11999 of omc from the svn trunk.

Thanks, Marcel.

  • Index
  • » Users
  • » wid80
  • » Profile
You are here: