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

Invalid simulator-cpp-source or simulator-binary from valid(?) Model

Invalid simulator-cpp-source or simulator-binary from valid(?) Model

Hello!

My Environment is OM 1.5.0 RC2 on Win7 64bit, and I work on a model, based on valid modelica code. (At least I believe the code is valid, because the model can be flattened without errors using the instantiateModel command on OMShell, and no errorstring is returned)

Recently I have problems running the simulation, because

1.) either the generated cpp-code is invalid, or
2.) the compiled binary crashes/hangs.

In cases where a binary executable is built successfully, the generated .log-file contains some type-conversion related warnings which basically all look like this:

Code:

myModelName.cpp:866: warning: passing `double' for converting 11 of `OIB__RL6_OENORM__B8110__5_Tabellen_Tabelle__x_lookup_rettype _OIB__RL6_OENORM__B8110__5_Tabellen_Tabelle__x_lookup(real_array, real_array, modelica_real, modelica_real, real_array, modelica_integer, modelica_integer, modelica_boolean, modelica_boolean, modelica_boolean, modelica_boolean)'

How do I deal with that?

Greetings
Hannes

EDIT: This is an example for a flattened model, where the generated binary crashes on execution:

Code:

fclass OIB_RL6.OENORM_B8110_6.Transmissionsleitwert_detailliert

output Real L_T.result.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_e.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_u.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_g.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_psi.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_chi.value(quantity = "ThermalConductance", unit = "W/K");
output Real L_g.result.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g1.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g2.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g3.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g4.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g5.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g6.value(quantity = "ThermalConductance", unit = "W/K");
output Real L_e.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_e.A[1] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[2] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[3] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[4] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[5] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[6] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[7] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[8] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[9] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[10] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.U[1] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[2] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[3] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[4] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[5] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[6] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[7] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[8] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[9] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[10] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
output Real L_u.result.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_u.L_iu.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_u.L_ue.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_u.L_Vue.value(quantity = "ThermalConductance", unit = "W/K");
output Real L_Vue.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_Vue.rho_L = 1.2 "Dichte von Luft [kg/m^3]";
parameter Real L_Vue.c_pL = 0.283333333333333 "spezifische Wärmekapazität von Luft [(W*h)/(kg*K)]";
parameter Real L_Vue.n_Lu = 0.5 "stündliche Luftwechselrate zw. unkondittioniertem Raum u. außen [h^(-1)]";
parameter Real L_Vue.V_fu = 0 "freies Luftvolumen des unkonditionierten Raumes [m^3]";
output Real L_iu.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_iu.A_iu[1] = 0 "Vektor der Bauteilflächen zwischen innen und unkonditionierten Räumen [m^2]";
parameter Real L_iu.U_iu[1] = 0 "Vektor der Wärmedurchgangskoeffizienten [W/(m^2*K)]";
parameter Real L_iu.l_psiiu[1] = 0 "Vektor der Längen von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [m]";
parameter Real L_iu.psi_iu[1] = 0 "Vektor der Leitwerte von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [W/(m*K)]";
parameter Real L_iu.chi_iu[1] = 0 "Vektor der Leitwerte von 3D-Wärmebrücken [W/(m^2*K)]";
output Real L_ue.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_ue.A_ue[1] = 0 "Vektor der Bauteilflächen zwischen außen und unkonditionierten Räumen [m^2]";
parameter Real L_ue.U_ue[1] = 0 "Vektor der Wärmedurchgangskoeffizienten [W/(m^2*K)]";
parameter Real L_ue.l_psiue[1] = 0 "Vektor der Längen von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [m]";
parameter Real L_ue.psi_ue[1] = 0 "Vektor der Leitwerte von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [W/(m*K)]";
parameter Real L_ue.chi_ue[1] = 0 "Vektor der Leitwerte von 3D-Wärmebrücken [W/(m^2*K)]";
output Real L_gB1.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gB1.A[1] = 9 "Vektor der Bauteilflächen von Bodenplatten [m^2]";
parameter Real L_gB1.U_0[1] = 0.1 "Vektor der fiktiven Wärmedurchgangskoeffizienten von Bodenplatten [W/(m^2*K)]";
output Real L_gB2.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gB2.A[1] = 9 "Vektor der Bauteilflächen der Bodenplatten [m^2]";
parameter Real L_gB2.U_0[1] = 0.1 "Vektor der fiktiven Wärmedurchgangskoeffizienten von Bodenplatten [W/(m^2*K)]";
parameter Real L_gB2.P[1] = 12 "Vektor der Perimeterlängen [m]";
parameter Real L_gB2.deltaPsi[1] = 0 "Vektor der längenbezogenen Korrekturkoeffizienten [W/(m*K)]";
output Real L_gB3.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gB3.A[1] = 9 "Vektor der Bauteilflächen der Bodenplatten [m^2]";
parameter Real L_gB3.U_0[1] = 0.1 "Vektor der fiktiven Wärmedurchgangskoeffizienten von Bodenplatten [W/(m^2*K)]";
parameter Real L_gB3.P[1] = 12 "Vektor der Perimeterlängen [m]";
parameter Real L_gB3.deltaPsi[1] = 0 "Vektor der längenbezogenen Korrekturkoeffizienten [W/(m*K)]";
output Real L_gK1.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gK1.A[1] = 0 "Vektor der Bauteilflächen der Kellerdecke [m^2]";
parameter Real L_gK1.U[1] = 0 "Vektor der Wärmedurchgangskoeffizienten [W/(m^2*K)]";
output Real L_gH.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gH.A_bf[1] = 0 "Vektor der Bauteilflächen des Kellerbodens [m^2]";
parameter Real L_gH.U_bf[1] = 0 "Vektor der Wärmedurchgangskoeffizienten des Kellerbodens [W/(m^2*K)]";
parameter Real L_gH.H[1] = 0 "Vektor der Höhen der Keller-Räume (Höhe unter Erdniveau) [m]";
parameter Real L_gH.P[1] = 0 "Vektor der Keller-Perimeterlängen (='erdberührte Wandlänge') [m]";
parameter Real L_gH.U_bw[1] = 0 "Vektor der fiktiven Wärmedurchgangskoeffizienten der erdberührten Kellerwand [W/(m^2*K)]";
Real L_gH.sum_L_bw(quantity = "ThermalConductance", unit = "W/K");
output Real L_gK2.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gK2.A[1] = 0 "Vektor der Bauteilflächen des Kellerbodens [m^2]";
parameter Real L_gK2.U[1] = 0 "Vektor der Wärmedurchgangskoeffizienten des Kellerbodens [W/(m^2*K)]";
output Real L_psi.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_psi.l[1] = 0 "Vektor der Längen der 2D-Wärmebrücken [m]";
parameter Real L_psi.psi[1] = 0 "Vektor der Korrekturkoeffizienten der 2D-Wärmebrücken [W/(m*K)]";
output Real L_chi.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_chi.chi[1] = 0 "Vektor der Korrekturkoeffizienten der 3D-Wärmebrücken [W/(m*K)]";
equation
  L_T.result.value = L_T.L_e.value + (L_T.L_u.value + (L_T.L_g.value + (L_T.L_psi.value + L_T.L_chi.value)));
  L_g.result.value = L_g.L_g1.value + (L_g.L_g2.value + (L_g.L_g3.value + (L_g.L_g4.value + (L_g.L_g5.value + L_g.L_g6.value))));
  L_e.result.value = L_e.A[1] * L_e.U[1] + (L_e.A[2] * L_e.U[2] + (L_e.A[3] * L_e.U[3] + (L_e.A[4] * L_e.U[4] + (L_e.A[5] * L_e.U[5] + (L_e.A[6] * L_e.U[6] + (L_e.A[7] * L_e.U[7] + (L_e.A[8] * L_e.U[8] + (L_e.A[9] * L_e.U[9] + L_e.A[10] * L_e.U[10]))))))));
  L_u.result.value = L_u.L_iu.value * (L_u.L_ue.value + L_u.L_Vue.value) / (L_u.L_iu.value + (L_u.L_ue.value + L_u.L_Vue.value));
  L_Vue.result.value = L_Vue.rho_L * (L_Vue.c_pL * (L_Vue.n_Lu * L_Vue.V_fu));
  L_iu.result.value = L_iu.A_iu[1] * L_iu.U_iu[1] + (L_iu.l_psiiu[1] * L_iu.psi_iu[1] + L_iu.chi_iu[1]);
  L_ue.result.value = L_ue.A_ue[1] * L_ue.U_ue[1] + (L_ue.l_psiue[1] * L_ue.psi_ue[1] + L_ue.chi_ue[1]);
  L_gB1.result.value = L_gB1.A[1] * L_gB1.U_0[1];
  L_gB2.result.value = L_gB2.A[1] * L_gB2.U_0[1] + L_gB2.P[1] * L_gB2.deltaPsi[1];
  L_gB3.result.value = L_gB3.A[1] * L_gB3.U_0[1] + L_gB3.P[1] * L_gB3.deltaPsi[1];
  L_gK1.result.value = L_gK1.A[1] * L_gK1.U[1];
  L_gH.sum_L_bw = <reduction>sum(L_gH.H[j] * (L_gH.P[j] * L_gH.U_bw[j]) for j in {1});
  L_gH.result.value = L_gH.A_bf[1] * L_gH.U_bf[1] + L_gH.sum_L_bw;
  L_gK2.result.value = L_gK2.A[1] * L_gK2.U[1];
  L_psi.result.value = L_psi.l[1] * L_psi.psi[1];
  L_chi.result.value = L_chi.chi[1];
L_chi.result.value = L_T.L_chi.value;
L_psi.result.value = L_T.L_psi.value;
L_g.result.value = L_T.L_g.value;
L_u.result.value = L_T.L_u.value;
L_e.result.value = L_T.L_e.value;
L_gH.result.value = L_g.L_g6.value;
L_gK2.result.value = L_g.L_g5.value;
L_gK1.result.value = L_g.L_g4.value;
L_gB3.result.value = L_g.L_g3.value;
L_gB2.result.value = L_g.L_g2.value;
L_gB1.result.value = L_g.L_g1.value;
L_ue.result.value = L_u.L_ue.value;
L_iu.result.value = L_u.L_iu.value;
L_Vue.result.value = L_u.L_Vue.value;
end OIB_RL6.OENORM_B8110_6.Transmissionsleitwert_detailliert;

Edited by: edes - Apr-06-10 17:19:57

Re: Invalid simulator-cpp-source or simulator-binary from valid(?) Model

Hmmm... Not a single response within 24 hours - I start thinking that my question must be either very stupid or very tricky current/wink

Is there any more information I should provide to make this thread run?

Thanks.

Re: Invalid simulator-cpp-source or simulator-binary from valid(?) Model

Well... The flattened model doesn't seem to use a function like the one you describe (or in fact any Boolean values).

The problem probably has to do with the fact that boolean values are stored as doubles in the simulation runtime, however...

Re: Invalid simulator-cpp-source or simulator-binary from valid(?) Model

That hint was a good one. I already noticed a problem with arrays of type Boolean in past, and this is another one.

Problem Nr. 1: I noticed, that an array {true,true,true,true} became {true,false,false,false} when it was passed as an argument to a function. When I passed {false,false,false,false} to the same function everything went normal. When I found out about that, I did a workaraound by passing the 4 elements of my Boolean-array as 4 seperate boolean values to the function. Out of these 4 seperate values I reassembled the array within the function, and this way it worked.

Problem Nr. 2: The actual case (which is the topic of my posting) is related to exactly the same array: The array is allocated in the declaration of a class which inherits form the class where Problem Nr. 1 occured. When I set the parameter to {false,false,false,false} in the class-declaration, a defective (crashing) simulation-executeable is generated. While I was trying to find the problem by manipulating my modelica-code there have also been cases, where the generated cpp-code could not even be compiled. In other cases the simulation-binary hung on execution. Anyway - When I set the array to {true,true,true,true} everything seems fine (even if I did not check the simulation results yet, but at least the generated cpp-code compiles and the executeable is neither crashing nor hanging).

I tried to reduce my code to a small demonstration of the problems:

Code:


model myModel

type edges = enumeration ( l "left", r  "right", t "top", b "bottom");

class mother
 
  function countTrueValues
   
    input Boolean boolArray[edges] = {false,false,false,false};
    output Integer numOfTrueValues;
   
    algorithm
      numOfTrueValues := 0;
      for i in edges loop
        if boolArray[i] then numOfTrueValues := numOfTrueValues + 1; end if;
      end for;
  end countTrueValues;
 
  parameter Boolean boolArray[edges] = {true, true, true, true};
 
  Integer numOfTrueValues;
 
  equation
/* Problem 1, Case 1: Passing an array explicitly --> works well
* results in numOfTrueValues = 0 for {false,false,false,false} --> OK
* results in numOfTrueValues = 2 for {true, true, false,false} --> OK
* results in numOfTrueValues = 4 for {true, true,  true, true} --> OK
*/ 
//   numOfTrueValues = countTrueValues({true,true,true,true});

/* Problem 1, Case 2: passing parameter boolArray --> only first element handled correctly
* results in numOfTrueValues = 0 for boolArray = {false,false,false,false} --> coincidently OK
* results in numOfTrueValues = 0 for boolArray = {false,false, true, true} --> NOT OK
* results in numOfTrueValues = 1 for boolArray = { true, true,false,false} --> NOT OK
* results in numOfTrueValues = 1 for boolArray = { true, true, true, true} --> NOT OK
*/
    numOfTrueValues = countTrueValues(boolArray);
   
end mother;


class child
/* Problem 2: inheriting from a class with an array of boolen type as parameter. */
//  extends mother( boolArray = {true,true,true,true} ); // --> flattening error
//  extends mother( boolArray = {false,false,false,false} ); // --> flattening error
//  extends mother(); // --> flattening error
end child;

mother motherInstance;
child  childInstance;

end myModel;

Unfortunately  Problem Nr. 2 cannot be exactly reproduced with this small demo, because the demo-model cannot even be flattened when the inherited class is instantiated (Dont ask me, why my real model can be flattend whild the example cannot - I dont know.)

You might think now, that the problem is related to the fact that the array is indexed with enumeration values (and enumeration handling is not yet fully implemented in 1.5.0 RC2), but it is not: At least the first of the described problems (wrong values in the array after passing it to the function) also occures, whe the array is indexed conventionally.

Regards,
Hannes

Re: Invalid simulator-cpp-source or simulator-binary from valid(?) Model

Can anyone reproduce that, or is it just me, who messed something up?

Re: Invalid simulator-cpp-source or simulator-binary from valid(?) Model

Ah. This is working in the trunk version, but not rc2. I remember fixing some things regarding boolean arrays/etc after the modprod workshop (which was the week after rc2 was released).

Re: Invalid simulator-cpp-source or simulator-binary from valid(?) Model

Clear now. Thank you!


EDIT: Well... I just built an omc.exe from the SVN-trunk, but moving the .exe and the .dlls to ${OPENMODELICAHOME}/bin/ results in an error when starting OMShell, because there seems to be en entry point missing in the newly generated mico2313.dll current/hmm

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