Opened 7 years ago

Closed 7 years ago

#4498 closed defect (fixed)

External object initialization dependencies

Reported by: Bernhard Thiele Owned by: Lennart Ochel
Priority: high Milestone: 1.13.0
Component: Initialization Version:
Keywords: Cc: Patrick Täuber

Description

I have a model that requires that two external objects are constructed in the correct sequence since one external object (ep1) is an argument to the constructor of the second external object (ep2). The idea is sketched below, the complete example is attached to this ticket.

  model Test_EPInit
    EP1 ep1 = EP1();
    EP2 ep2 = EP2(ep1);
  equation
    when time > 0.1 then
      EP1_Print(ep1);
      EP2_Print(ep2);
    end when;
    annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
          coordinateSystem(preserveAspectRatio=false)));
  end Test_EPInit;

Simulating this test model with a nightly build on a 64-bit Linux with

loadFile("EPInit.mo");
simulate(EPInit.Test_EPInit, startTime=0, stopTime=1); getErrorString();

results in a segmentation fault error.

...
    messages = "Simulation execution failed for model: EPInit.Test_EPInit
stdout            | info    | Entering EP1_Constructor()
stdout            | info    | The initialization finished successfully without homotopy method.
stdout            | info    | Entering EP2_Print()
stdout            | info    | EP2_Print: invalid pointer

Limited backtrace at point of segmentation fault
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10330)[0x7f3390c09330]
/home/bernhard/data/workspace/OMFMISimulator/testsuite/OMSimulatorModelica/EPInit.Test_EPInit(EP2_Print+0x44)[0x407404]
...

From the outputs it appears to me that the constructor of the second external object is not called at all.

Attachments (1)

EPInit.mo (3.4 KB ) - added by Bernhard Thiele 7 years ago.

Download all attachments as: .zip

Change History (5)

by Bernhard Thiele, 7 years ago

Attachment: EPInit.mo added

comment:1 by Lennart Ochel, 7 years ago

Cc: Patrick Täuber added
Component: BackendCode Generation

The second external object is not processed properly because of a bug or lack in the variables data structure. I added a workaround for that (OMCompiler#1771). @ptaeuber, can you please have a lock at the SimCode part that is now failing?

New error messages:

[OMCompiler/Compiler/SimCode/SimCodeUtil.mo:1356:5-1356:77:writable] Error: Internal error createEquationsForSystems failed
[OMCompiler/Compiler/SimCode/SimCodeUtil.mo:596:5-596:146:writable] Error: Internal error function createSimCode failed [Transformation from optimised DAE to simulation code structure failed]
Version 0, edited 7 years ago by Lennart Ochel (next)

comment:2 by Lennart Ochel, 7 years ago

Component: Code GenerationInitialization
Milestone: Future1.12.0
Status: newaccepted

comment:3 by Lennart Ochel, 7 years ago

This seem to work now. Here is the output that I get:

stdout            | info    | Entering EP1_Constructor()
stdout            | info    | Entering EP2_Constructor()
stdout            | info    | The initialization finished successfully without homotopy method.
stdout            | info    | Entering EP2_Print()
stdout            | info    | EP2_Print: ep2_state=13.30
stdout            | info    | Entering EP1_Print()
stdout            | info    | EP1_Print: ep1_state=3.30
stdout            | info    | The simulation finished successfully.
stdout            | info    | Entering EP1_Destructor()
stdout            | info    | Entering EP2_Destructor()

comment:4 by Lennart Ochel, 7 years ago

Milestone: 1.12.01.13.0
Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.