Opened 7 years ago
Closed 7 years ago
#5201 closed defect (fixed)
Problem in generated code from Modelica.Media mixture
| Reported by: | Francesco Casella | Owned by: | Willi Braun |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.14.0 |
| Component: | Backend | Version: | |
| Keywords: | Cc: | Lennart Ochel, Martin Sjölund |
Description
Please check Modelica.Media.Examples.TestOnly.IdealGasN2Mix. The C code compilation fails in correspondence to this code:
/*
equation index: 2
type: SIMPLE_ASSIGN
medium._MM = 1.0 / sum(medium.state.X[j] / {0.0280134} for j in 1:1)
*/
void Modelica_Media_Examples_TestOnly_IdealGasN2Mix_eqFunction_2(DATA *data, threadData_t *threadData)
{
TRACE_PUSH
const int equationIndexes[2] = {1,2};
modelica_real tmp0;
{
modelica_real $P$tmpVar179;
real_array tmp1;
modelica_real $P$tmpVar178;
int tmp2;
modelica_integer tmp3;
modelica_integer tmp4;
modelica_integer $Pj;
tmp3 = 1 /* Range step-value */;
tmp4 = ((modelica_integer) 1) /* Range stop-value */;
$Pj = ((modelica_integer) 1) /* Range start-value */;
$Pj = (((modelica_integer) 1) /* Range start-value */)-tmp3;
$P$tmpVar179 = 0.0; /* defaultValue */
while(1) {
tmp2 = 1;
if (tmp3 > 0 ? $Pj+tmp3 <= tmp4 : $Pj+tmp3 >= tmp4) {
$Pj += tmp3;
tmp2--;
}
if (tmp2 == 0) {
real_array_create(&tmp1, ((modelica_real*)&((&data->localData[0]->realVars[22] /* medium.X[1] variable */)[calc_base_index_dims_subs(1, 1, (modelica_integer)$Pj)])), 1, 1);
$P$tmpVar178 = DIVISION_SIM((*real_array_element_addr1(&tmp1, 1, /* modelica_integer */ (modelica_integer)$Pj)),_OMC_LIT25,"{0.0280134}",equationIndexes);
} else if (tmp2 == 1) {
break;
} else {
MMC_THROW_INTERNAL();
}
}
tmp0 = $P$tmpVar179;
}
data->localData[0]->realVars[19] /* medium.MM variable */ = DIVISION_SIM(1.0,tmp0,"sum(medium.state.X[j] / {0.0280134} for j in 1:1)",equationIndexes);
TRACE_POP
}
Apparently, something goes wrong with the code generated from
medium._MM = 1.0 / sum(medium.state.X[j] / {0.0280134} for j in 1:1)
I guess the root cause is the same as in #5200, please check.
Change History (2)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

#5200 was resolved but we still have this issue. I'm not sure what is special in this case (maybe that the iterator is a trival 1:1?), nor if PR #2767 addresses this.