Opened 11 years ago

Closed 8 years ago

Last modified 7 years ago

#2572 closed defect (fixed)

Generates an internal error

Reported by: Michael Tiller Owned by: Lennart Ochel
Priority: normal Milestone:
Component: Backend Version: trunk
Keywords: Cc: Willi Braun, Lennart Ochel, Mahder Alemseged Gebremedhin

Description

This model generates in internal error. I'm using OM r18788 on MacOSX.

The error message is:

Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed!

https://github.com/xogeny/ModelicaBook/blob/61ce55adbe02828ba3c86eeb1e3b55447912d890/ModelicaByExample/Components/ChemicalReactions/Examples/ABX_System.mo

This repo is currently private, but Martin S. has access to it. I'll be happy to give access to any other developer who requires it in order to address the issue.

Attachments (1)

ABX_System.mo (3.0 KB ) - added by Martin Sjölund 11 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 by Martin Sjölund, 11 years ago

Cc: Willi Braun Lennart Ochel added

This is indeed giving bad error-messages. With default settings I got:

Model is structurally singular, error found sorting equations 
 10: 'A+B->X'.C[3] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.X];
7: 'A+B<-X'.C[3] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.X];
16: solution.C[3] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.X];
4: 'X+B->R+S'.C[3] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.X];
11: 'A+B->X'.C[2] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.B];
8: 'A+B<-X'.C[2] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.B];
17: solution.C[2] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.B];
5: 'X+B->R+S'.C[2] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.B];
12: 'A+B->X'.C[1] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.A];
9: 'A+B<-X'.C[1] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.A];
18: solution.C[1] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.A];
6: 'X+B->R+S'.C[1] = solution.mixture.C[ModelicaByExample.Components.ChemicalReactions.ABX.Species.A];

With +t (type information when printing expressions), I got:

Error: Internal error Found Equation without time dependent variables /*Real*/ 'X+B->R+S'.mixture.R[/* 1 */ModelicaByExample.Components.ChemicalReactions.ABX.Species.A] = 0.0
Error: Internal error pre-optimization module removeSimpleEquations failed.
Error: Too many equations, over-determined system. The model has 65 equation(s) and 57 variable(s).

From what I understand, solution.C is an alias of solution.mixture.C. Except one is using enumeration indexes, and the other uses integers. So alias elimination fails and sorting fails due to this.

The error-message says index reduction fails, but I believe if sorting fails it always prints this error even if index reduction is not performed or needed.

comment:2 by Michael Tiller, 11 years ago

Nothing is using integer indices that I know of. If you know otherwise, please point it out. I used the enumeration in all array declarations to specify the dimension and I use only values of the enumeration to index the arrays. As such, it should be completely legal Modelica.

I don't know where those .C[3] references are coming from in the error messages. I think those are being inserted by OM, not me.

comment:3 by Martin Sjölund, 11 years ago

Yes, the flattened code is:

  /*Real[ModelicaByExample.Components.ChemicalReactions.ABX.Species]*/ solution.C = /* scalar */ {/*Real*/ solution.mixture.C[/* 1 */ModelicaByExample.Components.ChemicalReactions.ABX.Species.A], /*Real*/ solution.mixture.C[/* 2 */ModelicaByExample.Components.ChemicalReactions.ABX.Species.B], /*Real*/ solution.mixture.C[/* 3 */ModelicaByExample.Components.ChemicalReactions.ABX.Species.X]} /* array equation [ModelicaByExample.Components.ChemicalReactions.ABX.Species] */;

Which obviously the backend does expand to something wrong (using the integer indexes when expanding the left side I would guess).

by Martin Sjölund, 11 years ago

Attachment: ABX_System.mo added

comment:4 by Martin Sjölund, 11 years ago

Owner: changed from probably noone to Lennart Ochel
Status: newassigned

Go Lennart. No sleep for you until you fix it. With the full model attached it should be very simple, right?

comment:5 by Lennart Ochel, 11 years ago

Well, the error messages generated with +t are probably misleading.
The equations get expended, but the variables not. Hence there are 65 equations and only 57 variables.
Without the flag +t there are 57 variables and 57 equations and the proper error messages occure.
I still do not know what that means ...

comment:6 by Lennart Ochel, 10 years ago

Cc: Mahder Alemseged Gebremedhin added

Now, there are issues with the generated c code - probably due to Q-Idents:

foo.TestMe.c: In function ‘foo_TestMe_eqFunction_17’:
foo.TestMe.c:111: error: ‘$P_omcQuot_412B423C2D58$Pmixture$PR$lB1$rB’ undeclared (first use in this function)
foo.TestMe.c:111: error: (Each undeclared identifier is reported only once
foo.TestMe.c:111: error: for each function it appears in.)
foo.TestMe.c:111: error: ‘$P_omcQuot_582B422D3E522B53$Pmixture$PR$lB1$rB’ undeclared (first use in this function)
foo.TestMe.c:111: error: ‘$P_omcQuot_412B422D3E58$Pmixture$PR$lB1$rB’ undeclared (first use in this function)
102: /*
103:  equation index: 17
104:  type: SIMPLE_ASSIGN
105:  solution._mixture._R[foo.ModelicaByExample.Components.ChemicalReactions.ABX.Species.X] = (-'A+B<-X'.mixture.R[foo.ModelicaByExample.Components.ChemicalReactions.ABX.Species.X]) - 'X+B->R+S'.mixture.R[foo.ModelicaByExample.Components.ChemicalReactions.ABX.Species.X] - 'A+B->X'.mixture.R[foo.ModelicaByExample.Components.ChemicalReactions.ABX.Species.X]
106:  */
107: void foo_TestMe_eqFunction_17(DATA *data)
108: {
109:   const int equationIndexes[2] = {1,17};
110:   TRACE_PUSH
111:   $Psolution$Pmixture$PR$lB3$rB = (((-$P_omcQuot_412B423C2D58$Pmixture$PR$lB1$rB) - $P_omcQuot_582B422D3E522B53$Pmixture$PR$lB1$rB) - $P_omcQuot_412B422D3E58$Pmixture$PR$lB1$rB);
112:   TRACE_POP
113: }

comment:7 by Martin Sjölund, 10 years ago

Milestone: 1.9.11.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:8 by Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:9 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:10 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:11 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:12 by Dietmar Winkler, 8 years ago

Any updates on this. It would be nice to finally be able to include the plots in the Modelica by Example book. :-)

comment:13 by Mahder Alemseged Gebremedhin, 8 years ago

Resolution: fixed
Status: assignedclosed

Fixed in: 93bd45e/OMCompiler. The only thing left for this was that apostrophes (single quotes) were not escaped in the _init.xml file.

comment:14 by Martin Sjölund, 7 years ago

Milestone: 1.10.0

Milestone deleted

Note: See TracTickets for help on using tickets.