Opened 10 years ago

Closed 10 years ago

#2978 closed defect (fixed)

Modelica3d fails

Reported by: Adam Dershowitz <dersh@…> Owned by: Lennart Ochel
Priority: high Milestone: 1.9.2
Component: Backend Version: trunk
Keywords: Cc:

Description

I have tried this with recent Mac builds, and also Linux 1.9.1 release.
For example, just doing this in OMShell:

loadModelica3D();getErrorString();
loadString("model DoublePendulum
  extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;
  inner ModelicaServices.Modelica3D.Controller m3d_control;
end DoublePendulum;");getErrorString();
simulate(DoublePendulum);

As suggested here: https://build.openmodelica.org/Documentation/OpenModelica.Scripting.loadModelica3D.html gives many errors (after some warnings). The begging set of errors are here:

/usr/bin/clang        "-I/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Include" -I"/opt/local/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o DoublePendulum_10asr.o DoublePendulum_10asr.c
DoublePendulum.c:195:171: error: too many arguments to function call, expected single argument 'threadData', have 3 arguments
        $Pworld$Px_label$Pcylinders$lB1$rB$Pres = omc_ModelicaServices_Modelica3D_rotate(threadData, omc_ModelicaServices_Modelica3D_State$m3d__control$state(threadData, $Pm3d_control$Pstate$Pconn, $Pm3d_control$Pstate$Pcontext), $Pworld$Px_label$Pcylinders$lB1$rB$Pid, tmp722, time);
                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./DoublePendulum_model.h:14499:36: note: expanded from macro '$Pm3d_control$Pstate$Pconn'
#define $Pm3d_control$Pstate$Pconn data->simulationInfo.extObjs[6]
                                   ^
./DoublePendulum_functions.h:83:1: note: 'omc_ModelicaServices_Modelica3D_State$m3d__control$state' declared here
ModelicaServices_Modelica3D_State$m3d__control$state omc_ModelicaServices_Modelica3D_State$m3d__control$state(threadData_t *threadData); /* record head */
^
/usr/bin/clang        "-I/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Include" -I"/opt/local/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o DoublePendulum_11mix.o DoublePendulum_11mix.c
11 warnings generated.
/usr/bin/clang        "-I/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Include" -I"/opt/local/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o DoublePendulum_12jac.o DoublePendulum_12jac.c
DoublePendulum.c:222:171: error: too many arguments to function call, expected single argument 'threadData', have 3 arguments
        $Pworld$Px_label$Pcylinders$lB1$rB$Pres = omc_ModelicaServices_Modelica3D_moveTo(threadData, omc_ModelicaServices_Modelica3D_State$m3d__control$state(threadData, $Pm3d_control$Pstate$Pconn, $Pm3d_control$Pstate$Pcontext), $Pworld$Px_label$Pcylinders$lB1$rB$Pid, tmp727, time);
                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./DoublePendulum_model.h:14499:36: note: expanded from macro '$Pm3d_control$Pstate$Pconn'
#define $Pm3d_control$Pstate$Pconn data->simulationInfo.extObjs[6]
                                   ^
./DoublePendulum_functions.h:83:1: note: 'omc_ModelicaServices_Modelica3D_State$m3d__control$state' declared here
ModelicaServices_Modelica3D_State$m3d__control$state omc_ModelicaServices_Modelica3D_State$m3d__control$state(threadData_t *threadData); /* record head */
^
DoublePendulum_06inz.c:77:186: error: too many arguments to function call, expected single argument 'threadData', have 3 arguments

And these keep going until reaching the "fatal limit":

./DoublePendulum_functions.h:83:1: note: 'omc_ModelicaServices_Modelica3D_State$m3d__control$state' declared here
ModelicaServices_Modelica3D_State$m3d__control$state omc_ModelicaServices_Modelica3D_State$m3d__control$state(threadData_t *threadData); /* record head */
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [DoublePendulum_08bnd.o] Error 1

Attachments (1)

m3d-fix.diff (15.8 KB ) - added by james.goppert@… 10 years ago.
m3d patch to fix state record

Download all attachments as: .zip

Change History (24)

comment:1 by anonymous, 10 years ago

Also happens to me under Ubuntu 14.04 with OpenModelica 1.9.2.

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

Owner: changed from somebody to Adrian Pop
Status: newassigned

comment:3 by Adam Dershowitz <dersh@…>, 10 years ago

Now, modelica3d fails to build at all. I filed a separate ticket here:
https://trac.openmodelica.org/OpenModelica/ticket/3056

by james.goppert@…, 10 years ago

Attachment: m3d-fix.diff added

m3d patch to fix state record

comment:4 by james.goppert@…, 10 years ago

I just submitted the fix for this, thanks to andik86, see original post:
https://www.openmodelica.org/forum/default-topic/1455-3d-visualisation-win7-in-nightly-once-again.

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

Note that the modelica3d repository is on github: https://github.com/OpenModelica/modelica3d

comment:6 by Adrian Pop, 10 years ago

I think I know what the problem is (without the patch).

Record State was declared as:

  record State 
    Connection conn; 
    Context context; 
  end State; 

We added checks of what can be used as type of components inside a record and we ignore anything that is not basic type or record and because of that we ignore ExternalObject:

ExternalObject ModelicaServices.modbus.Connection conn;
ExternalObject ModelicaServices.modcount.Context context;

which means that the state sent to external functions has no components.

So, how should we fix this?
Allowing ExternalObjects inside records or using the patch?

I created a pull request just now:
https://github.com/OpenModelica/modelica3d/pull/7
if we decide to use the patch.

Last edited 10 years ago by Adrian Pop (previous) (diff)

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

Specialized class record:

May only contain components of specialized class record and type.

But ExternalObject is neither, right?

comment:8 by Adrian Pop, 10 years ago

Yes, as far as I can tell is not legal to have ExternalObject components inside records. We currently give a warning and ignore such components.

So, I guess you can just accept my pull request and the Modelica3D stuff will start working again (I tested it in Windows and it does with those changes).

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

Warnings are bad. It should be an error; because right now you get a C compiler error...

comment:10 by Adrian Pop, 10 years ago

Unfortunately there are some libraries (such as PowerSystems) that use this (an inner model inside a record) so I cannot make it an error. At least the warnings point to what the problem is.

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

There are no occurrences of "Ignoring record component" in test.openmodelica.org/libraries or the test suite (we only remove based on type, not prefixes).

comment:12 by Adrian Pop, 10 years ago

As far as I know they changed the library and they might have removed those, so i guess you could make it an error if you want: Error.ILLEGAL_RECORD_COMPONENT.

comment:13 by Adam Dershowitz <dersh@…>, 10 years ago

I can't test any of this, because, I can't get modelica3d to build at all on a mac. See the ticket also mentioned above: https://trac.openmodelica.org/OpenModelica/ticket/3056

comment:14 by anonymous, 10 years ago

This is what happens when running the snippet of the ticket description in OMShell 1.9.2+dev (r24558) under ubuntu:

Notification: It was not possible to analyze the given system symbolically, because the relevant equations are part of an algebraic loop. This is not supported yet.
[/home/build/tmp/build/openmodelica-24558/Compiler/BackEnd/BackendDAETransform.mo:463:9-463:50:writable] Error: Internal error BackendDAETransform.analyseStrongComponentBlock failed
Sorry - Support for Discrete Equation Systems is not yet implemented
world.z_label.cylinders[1].rotated
$PRE.world.z_label.cylinders[1].rotated
world.z_label.cylinders[1].rotated = $PRE.world.z_label.cylinders[1].rotated
world.z_label.cylinders[1].rotated = $PRE.world.z_label.cylinders[1].rotated
[/home/build/tmp/build/openmodelica-24558/Compiler/BackEnd/BackendDAETransform.mo:469:9-469:92:writable] Error: Internal error function analyseStrongComponentBlock failed
[/home/build/tmp/build/openmodelica-24558/Compiler/BackEnd/BackendDAETransform.mo:114:7-115:62:writable] Error: Internal error function strongComponentsScalar failed
- sorting equations (strongComponents) failed
Error: Internal error Transformation Module sort components failed!
Error: No system for the symbolic initialization was generated.

comment:15 by Adrian Pop, 10 years ago

Component: UnknownBackend
Owner: changed from Adrian Pop to Lennart Ochel

Lennart, can you have a look at this?
As far as I know this happens after removal of numeric initialization.

comment:16 by Lennart Ochel, 10 years ago

This is the actual error message:

[trunk/Compiler/BackEnd/BackendDAETransform.mo:463:9-463:50:writable] Error: Internal error BackendDAETransform.analyseStrongComponentBlock failed
Sorry - Support for Discrete Equation Systems is not yet implemented
world.z_label.cylinders[1].rotated
$PRE.world.z_label.cylinders[1].rotated
world.z_label.cylinders[1].rotated = $PRE.world.z_label.cylinders[1].rotated
world.z_label.cylinders[1].rotated = $PRE.world.z_label.cylinders[1].rotated
[trunk/Compiler/BackEnd/BackendDAETransform.mo:469:9-469:92:writable] Error: Internal error function analyseStrongComponentBlock failed
[trunk/Compiler/BackEnd/BackendDAETransform.mo:114:7-115:62:writable] Error: Internal error function strongComponentsScalar failed
- sorting equations (strongComponents) failed
Error: Internal error Transformation Module sort components failed!

That means that the model contains a discrete equation system for initialization. I assume that this message was there already before, but it was caught by the numeric initialization, which probably initialized the model wrong anyway.

comment:17 by Adrian Pop, 10 years ago

Milestone: Future1.9.2
Resolution: fixed
Status: assignedclosed

Fixed in r25016. Duplicate of #3209.

comment:18 by Adam Dershowitz <dersh@…>, 10 years ago

I thought that it is worth mentioning that it is not possible to test this on a Mac due to this outstanding ticket:
https://trac.openmodelica.org/OpenModelica/ticket/3056

comment:19 by Adam Dershowitz <dersh@…>, 10 years ago

There is still a link error when I try to actually run a Modelica3D case. If I do the above example I get this:

/usr/bin/clang -I. -o DoublePendulum DoublePendulum.o DoublePendulum_functions.o DoublePendulum_records.o DoublePendulum_01exo.o DoublePendulum_02nls.o DoublePendulum_03lsy.o DoublePendulum_04set.o DoublePendulum_05evt.o DoublePendulum_06inz.o DoublePendulum_07dly.o DoublePendulum_08bnd.o DoublePendulum_09alg.o DoublePendulum_10asr.o DoublePendulum_11mix.o DoublePendulum_12jac.o DoublePendulum_13opt.o DoublePendulum_14lnz.o "-I/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Include" -I"/opt/local/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  "-L/opt/local/lib/" "-L/opt/local/lib/omc" "-L/Users/adershowitz/.openmodelica/binaries/OpenModelica" "-L/opt/local/lib/omc/Resources/Library/x86_64-darwin13.4.0" "-L/opt/local/lib/omc/Resources/Library" -lModelicaExternalC "-L/Users/adershowitz/.openmodelica/binaries/ModelicaServices" "-L/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Library/x86_64-darwin13.4.0" "-L/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Library" -lmodcount -lmodbus -ldbus-1 "-L/Users/adershowitz/.openmodelica/binaries/Modelica" "-L/opt/local/lib/omlibrary/Modelica 3.2.1/Resources/Library/x86_64-darwin13.4.0" "-L/opt/local/lib/omlibrary/Modelica 3.2.1/Resources/Library"     -O0 -falign-functions -march=native     -L"/opt/local/lib/omc" -L"/opt/local/lib" -Wl,-rpath,"/opt/local/lib/omc" -Wl,-rpath,"/opt/local/lib"    -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -lSimulationRuntimeC -llapack -lblas -lm -lgc 
ld: warning: directory not found for option '-L/Users/adershowitz/.openmodelica/binaries/OpenModelica'
ld: warning: directory not found for option '-L/opt/local/lib/omc/Resources/Library/x86_64-darwin13.4.0'
ld: warning: directory not found for option '-L/opt/local/lib/omc/Resources/Library'
ld: warning: directory not found for option '-L/Users/adershowitz/.openmodelica/binaries/ModelicaServices'
ld: warning: directory not found for option '-L/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Library/x86_64-darwin13.4.0'
ld: warning: directory not found for option '-L/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Library'
ld: warning: directory not found for option '-L/Users/adershowitz/.openmodelica/binaries/Modelica'
ld: warning: directory not found for option '-L/opt/local/lib/omlibrary/Modelica 3.2.1/Resources/Library/x86_64-darwin13.4.0'
ld: warning: directory not found for option '-L/opt/local/lib/omlibrary/Modelica 3.2.1/Resources/Library'
ld: library not found for -lmodcount
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [omc_main_target] Error 1

modcount is actually installed here:

/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/modcount

Which is not one of the paths passed, so it that is why it is not being found.

comment:20 by Adam Dershowitz <dersh@…>, 10 years ago

Resolution: fixed
Status: closedreopened

comment:21 by Adam Dershowitz <dersh@…>, 10 years ago

Correction: The path above is actually to a directory that contains only package.mo. And, I can also find a header file here:

/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Resources/Include/modcount.h

And similarly for modbus, there is a directory, and a header file.
So, it appears that neither libmodbus, nor modcount libraries are actually being installed.

comment:22 by Adam Dershowitz <dersh@…>, 10 years ago

This was actually still issue #3056, so it wasn't actually building modelica3d.

comment:23 by Adrian Pop, 10 years ago

Resolution: fixed
Status: reopenedclosed

I suggest we close this one as modelica3d is now working but there is an issue with build on Mac which is #3056 so we'll continue with that one.

Note: See TracTickets for help on using tickets.