Opened 12 years ago

Closed 9 years ago

#2261 closed defect (fixed)

Problem with initialization of mixed system

Reported by: Lennart Ochel Owned by: Lennart Ochel
Priority: high Milestone: 1.9.0
Component: Backend Version: trunk
Keywords: Cc: fedebergero@…, Willi Braun, Adrian Pop

Description

Hi all, I have the following model that fails to compile (it generates
the c file but then gcc fails).
The problem is that a discrete variable is involved in a mixed
algebraic loop, appearing as an argument to the pre operator.
Then the initialization code tries to lookup the pre(pre(var))
variable and it fails.

Thanks
Fede

Attachments (1)

buck.mo (9.6 KB ) - added by Lennart Ochel 12 years ago.

Download all attachments as: .zip

Change History (13)

by Lennart Ochel, 12 years ago

Attachment: buck.mo added

comment:1 by Lennart Ochel, 11 years ago

Cc: Willi Braun added

error message:

buck.c: In function 'initializeStaticNLSData28':
buck.c:374: error: '$P$ATTRIBUTE$P$PRE$Pz_2' undeclared (first use in this function)
buck.c:374: error: (Each undeclared identifier is reported only once
buck.c:374: error: for each function it appears in.)

generated c-code:

368: void initializeStaticNLSData28(void *inData, void *inNlsData)
369: {
370:   DATA* data = (DATA*) inData;
371:   NONLINEAR_SYSTEM_DATA* nlsData = (NONLINEAR_SYSTEM_DATA*) inNlsData;
372:   int i=0;
373:   /* static nls data for $P$PRE$Pz_2 */
374:   nlsData->nominal[i] = $P$ATTRIBUTE$P$PRE$Pz_2.nominal;
375:   nlsData->min[i]     = $P$ATTRIBUTE$P$PRE$Pz_2.min;
376:   nlsData->max[i++]   = $P$ATTRIBUTE$P$PRE$Pz_2.max;
377:   /* static nls data for $Pidealdiode1__s */
378:   nlsData->nominal[i] = $P$ATTRIBUTE$Pidealdiode1__s.nominal;
379:   nlsData->min[i]     = $P$ATTRIBUTE$Pidealdiode1__s.min;
380:   nlsData->max[i++]   = $P$ATTRIBUTE$Pidealdiode1__s.max;
381:   /* static nls data for $Pidealclosingswitch1__s */
382:   nlsData->nominal[i] = $P$ATTRIBUTE$Pidealclosingswitch1__s.nominal;
383:   nlsData->min[i]     = $P$ATTRIBUTE$Pidealclosingswitch1__s.min;
384:   nlsData->max[i++]   = $P$ATTRIBUTE$Pidealclosingswitch1__s.max;
385: }

comment:2 by Lennart Ochel, 11 years ago

Owner: Lennart Ochel removed
Status: newassigned

comment:3 by Lennart Ochel, 11 years ago

Cc: Adrian Pop added

Probably the smallest model that is causing the error:

model Unnamed
  Real a;
initial equation 
  pre(a)^2 = 9;
equation 
  der(a) = 0;
end Unnamed;

Error message:

Unnamed.c: In function 'initializeStaticNLSData3':
Unnamed.c:134: error: '$P$ATTRIBUTE$P$PRE$Pa' undeclared (first use in this function)
Unnamed.c:134: error: (Each undeclared identifier is reported only once
Unnamed.c:134: error: for each function it appears in.)
OMDev\tools\MinGW\bin\mingw32-make: *** [Unnamed.o] Error 1

This can be easily fixed by introducing #define $P$ATTRIBUTE$P$PRE$Pa $P$ATTRIBUTE$Pa for all states (or continuous-time variables?).

If we do so, another error occurs:

Unnamed.o:Unnamed.c:(.text+0x1552): undefined reference to `_$P$PRE$Pa'

The current NLS implementation requires old values for each variable to inter-/extrapolate for some reasons.

comment:4 by Lennart Ochel, 11 years ago

The errors above are fixed for now (r16895). Now we run into the same issue that is already mentioned in #2310.

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

Milestone: 1.9.01.9.1

Postponed until 1.9.1

comment:6 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:7 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:8 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

in reply to:  4 comment:9 by Lennart Ochel, 9 years ago

Owner: set to Lennart Ochel

Replying to lochel:

The errors above are fixed for now (r16895). Now we run into the same issue that is already mentioned in #2310.

This is fixed for a long time. Probably this ticket should be tagged to milestone 1.9.0, however that cannot be selected anymore.

comment:10 by Lennart Ochel, 9 years ago

Resolution: fixed
Status: assignedclosed

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

Resolution: fixed
Status: closedreopened

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

Milestone: 1.9.41.9.0
Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.