Recent Changes - Search:

edit SideBar

OpenModelicaFMI

This page has information about Functional Mock-up Units (FMI) and Open Modelica

References

Issues

Generating a fmu fails because share/omc/runtime/c is not present

12/20/2015

Under both Mac OS X and RHEL 6.7, when building just omc, share/omc/runtime/c is not present.

bash-4.1$ mkdir /tmp/fmi
bash-4.1$ cd /tmp/fmi
bash-4.1$ cp /home/jenkins/src/OpenModelica/OMCompiler/Examples/VanDerPol.mo .
bash-4.1$ cat VanDerPol.mos
loadModel(Modelica, {"3.2.1"});
getErrorString();
loadFile("VanDerPol.mo"); getErrorString();
OpenModelica.Scripting.translateModelFMU(
className=VanDerPol,
version="2.0");
getErrorString();
bash-4.1$ /usr/local/openmodelica/bin/omc VanDerPol.mos
true
""
true
""

"Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
Error: Error building simulator. Build log: rm -f VanDerPol.fmutmp/sources/VanDerPol_init.xml
cp -a /usr/local/openmodelica/include/omc/c/* VanDerPol.fmutmp/sources/include/
cp -a /usr/local/openmodelica/share/omc/runtime/c/fmi/buildproject/* VanDerPol.fmutmp/sources
cp: cannot stat `/usr/local/openmodelica/share/omc/runtime/c/fmi/buildproject/*': No such file or directory
make: *** [fmu] Error 1
Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
Error: Error building simulator. Build log: rm -f VanDerPol.fmutmp/sources/VanDerPol_init.xml
cp -a /usr/local/openmodelica/include/omc/c/* VanDerPol.fmutmp/sources/include/
cp -a /usr/local/openmodelica/share/omc/runtime/c/fmi/buildproject/* VanDerPol.fmutmp/sources
cp: cannot stat `/usr/local/openmodelica/share/omc/runtime/c/fmi/buildproject/*': No such file or directory
make: *** [fmu] Error 1
"
bash-4.1$

Indeed, /usr/local/openmodelica/share/omc/ does not exist

bash-4.1$ ls -l /usr/local/openmodelica/share/omc/
total 12
drwxrwxr-x. 2 jenkins jenkins 4096 May 11  2015 java
-rw-rw-r--  1 jenkins jenkins  189 Dec 20 09:19 omc_communication.idl
drwxrwxr-x. 3 jenkins jenkins 4096 Dec 29  2014 scripts

The solution is to copy the directory:

bash-4.1$ cp -r ~/src/OpenModelica/build/share/omc/runtime /usr/local/openmodelica/share/omc
bash-4.1$ /usr/local/openmodelica/bin/omc VanDerPol.mos
true
""
true
""
"SimCode: The model VanDerPol has been translated to FMU"
"Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
"

bash-4.1$ ls -l *.fmu
-rw-rw-r-- 1 jenkins jenkins 866471 Dec 22 08:15 VanDerPol.fmu
bash-4.1$

2/20/2015 OpenModelica FMI Issues

Running an OpenModelica FMU crashes Java

cd $PTII/ptolemy/actor/lib/fmi/fmus/omc/HeatConductorComplex
make
$PTII/bin/vergil HeatConductorComplex.xml

At run time, it fails with:

FMUFile: Extracting to /tmp/FMUFile2238913665047057849.tmp
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f1883c3b794, pid=3585, tid=139741560760064
#
# JRE version: Java(TM) SE Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.31-b07 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x9e6794] NMethodSweeper::sweep_code_cache()+0x474
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/cxh/src/ptII/ptolemy/actor/lib/fmi/fmus/omc/HeatConductorComplex/hs_err_pid3585.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Aborted (core dumped)

However, running make test, which runs the HeatConductorComplex.fmu with CoSimulation using JFMI works.

Running make test_me, which runs HeatConductorComplex.fmu with model exchange using JFMI also works.

BouncingBall log messages

cd $PTII/ptolemy/actor/lib/fmi/fmus/omc/BouncingBall
make
make test

The error message below is unusual:

[cxh@terra BouncingBallFMI20]$ make test
/usr/java/jdk1.8.0_31/bin/java -classpath /home/cxh/src/ptII:/home/cxh/src/ptII/lib/jna-4.0.0-variadic.jar org.ptolemy.fmi.driver.FMUCoSimulation\
BouncingBallFMI20.fmu 1.0 0.1 true
FMUFile: Extracting to /tmp/FMUFile4354210307734215046.tmp
org/ptolemy/fmi/FMULog.java called Pointer.nativeCif(fmiCoomponent), but received a value of 0? This can happen if the the jna jar file has the \
Java side of the variadic extensions, but the C side of the variadic extensions have not been compiled for your platform. To compile them, see h\
ttp://chess.eecs.berkeley.edu/ptexternal/wiki/Main/JNA#PatchJNAToWorkWithVarargsCallBacks
FMULogger: status: 0 message: fmi2Instantiate: GUID=%s
instantiatedSlave
about to initializeSlave
FMUCoSimulation: about to write header
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.0, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.1, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.2, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.30000000000000004, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.4, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.5, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.6, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.7, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.7999999999999999, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.8999999999999999, /* stepSize */0.1, 1)
FMUCoSimulation: about to call BouncingBallFMI20_fmiDoStep(Component, /* time */ 0.9999999999999999, /* stepSize */0.1, 1)
Results are in /home/cxh/src/ptII/ptolemy/actor/lib/fmi/fmus/omc/BouncingBallFMI20/results.csv

This error message occurs if I run a bouncingBall FMU from FMUSDK-2.0:

[cxh@terra BouncingBallFMI20]$ /usr/java/jdk1.8.0_31/bin/java -classpath /home/cxh/src/ptII:/home/cxh/src/ptII/lib/jna-4.0.0-variadic.jar org.pto\
lemy.fmi.driver.FMUCoSimulation /home/cxh/src/ptII/ptolemy/actor/lib/fmi/test/auto/bouncingBall20.fmu 1.0 0.1 true
FMUFile: Extracting to /tmp/FMUFile5153054737620530695.tmp
org/ptolemy/fmi/FMULog.java called Pointer.nativeCif(fmiCoomponent), but received a value of 0? This can happen if the the jna jar file has the \
Java side of the variadic extensions, but the C side of the variadic extensions have not been compiled for your platform. To compile them, see h\
ttp://chess.eecs.berkeley.edu/ptexternal/wiki/Main/JNA#PatchJNAToWorkWithVarargsCallBacks
FMULogger: status: 0 message: fmi2Instantiate: GUID=%s
instantiatedSlave
about to initializeSlave
FMUCoSimulation: about to write header
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.0, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.1, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.2, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.30000000000000004, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.4, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.5, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.6, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.7, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.7999999999999999, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.8999999999999999, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.9999999999999999, /* stepSize */0.1, 1)
Results are in /home/cxh/src/ptII/ptolemy/actor/lib/fmi/fmus/omc/BouncingBallFMI20/results.csv
[cxh@terra BouncingBallFMI20]$

Editing FMULog.java and reverting to the old logger gets rid of the messages but does not fix the crash.

Note that running with FMUs from FMUSDK also produces the same odd message:

[cxh@terra jna]$ cd /home/cxh/src/ptII/ptolemy/actor/lib/fmi/test/auto
[cxh@terra auto]$ /usr/java/jdk1.8.0_31/bin/java -classpath /home/cxh/src/ptII:/home/cxh/src/ptII/lib/jna-4.0.0-variadic.jar org.ptolemy.fmi.driv\
er.FMUCoSimulation bouncingBall20.fmu 1.0 0.1 true
FMUFile: Extracting to /tmp/FMUFile1422086609466797604.tmp
org/ptolemy/fmi/FMULog.java called Pointer.nativeCif(fmiCoomponent), but received a value of 0? This can happen if the the jna jar file has the \
Java side of the variadic extensions, but the C side of the variadic extensions have not been compiled for your platform. To compile them, see
http://chess.eecs.berkeley.edu/ptexternal/wiki/Main/JNA#PatchJNAToWorkWithVarargsCallBacks
FMULogger: status: 0 message: fmi2Instantiate: GUID=%s
instantiatedSlave
about to initializeSlave
FMUCoSimulation: about to write header
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.0, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.1, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.2, /* stepSize */0.1, 1)
FMUCoSimulation: about to call bouncingBall20_fmiDoStep(Component, /* time */ 0.30000000000000004, /* stepSize */0.1, 1)

Possible solution is to port the JNA variadic code.

2/20/2015 Adding printfs

I added fprintf(stderr to the FMU.

With vergil, it crashes after:

  HeatConductorComplex_FMU.c start setDefaultStartValues()
  HeatConductorComplex_FMU.c end setDefaultStartValues()

When I run fmuChecker, which works, I get:

  [INFO][FMILIB] Loading 'linux64' binary with 'default' platform types
  [INFO][FMUCHK] Version returned from ME FMU: '2.0'

  HeatConductorComplex_FMU.c start setDefaultStartValues()
  HeatConductorComplex_FMU.c end setDefaultStartValues()
  HeatConductorComplex_FMU.c setReal(4, 270)
  HeatConductorComplex_FMU.c setStartValues()
  HeatConductorComplex_FMU.c getReal(0)
  HeatConductorComplex_FMU.c getReal(1)

Adding printlns to OpenModelica generated FMUs.

The fmi2* methods are defined in /usr/local/openmodelica/include/omc/c/fmi2/fmu2_model_interface.c

To create a .c file that has the fmi2* methods:

  gcc  -fPIC -O0 -falign-functions -march=native    -I"/usr/local/openmodelica/include/omc/c" -I"/usr/local/openmodelica/include/omc/c/fmi2" -I.   -E -o /tmp/H.c HeatConductorComplex_FMU.c

Then:

  cp /tmp/H.c HeatConductorComplex_FMU.c

To enable debugging, edit HeatConductorComplex_FMU.c and add a call to fmi2SetDebugLogging():

     static fmi2String logCategoriesNamesAll[] = {"logEvents", "logSingularLinearSystems", "logNonlinearSystems", "logDynamicStateSelection",
          "logStatusWarning", "logStatusDiscard", "logStatusError", "logStatusFatal", "logStatusPending", "logAll", "logFmi2Call"};

    // Set values for all variables that define a start value                                                                                     
    void setDefaultStartValues(ModelInstance *comp) {
        fprintf(stderr, "HeatConductorComplex_FMU.c start setDefaultStartValues() \n");
        fflush(stderr);

	fprintf(stderr, "HeatConductorComplex_FMU.c  calling fmi2SetDebugLoggin() \n");
        fflush(stderr);
        fmi2SetDebugLogging(comp, 1, 11, logCategoriesNamesAll);

If $PTII/bin/ptinvoke ptolemy.moml.MoMLSimpleApplication HeatConductorComplex.xml is run, then:

 FMU for model exchange or co-simulation: about to call HeatConductorComplex_fmiInstantiate
 HeatConductorComplex_FMU.c start setDefaultStartValues()
 HeatConductorComplex_FMU.c end setDefaultStartValues()
 FMULogger: status: 0 message: fmi2Instantiate: GUID=%s
 H.c end fmi2Instantiate()
 Done with fmi instantiate
 Warning, _debugListeners was null, which means that _debugging was set to true, but no listeners were added?
 Done with fmi instantiate
 Warning, _debugListeners was null, which means that _debugging was set to true, but no listeners were added?
 Called initialize()
 FMIImport.initialize() method called.
 Warning, _debugListeners was null, which means that _debugging was set to true, but no listeners were added?
 FMIImport.initialize() method called.
 H.c fmi2SetReal(): 1000,
 FMULogger: status: 0 message: fmi2SetReal: nvr = %d
 FMULogger: status: 0 message: fmi2SetReal: #r.16g
 HeatConductorComplex_FMU.c setReal(19, 1000)

However, we vergil is invoked on the same model:

 FMU for model exchange or co-simulation: about to call HeatConductorComplex_fmiInstantiate
 HeatConductorComplex_FMU.c start setDefaultStartValues()
 HeatConductorComplex_FMU.c end setDefaultStartValues()
 FMULogger: status: 0 message: fmi2Instantiate: GUID=%s
 H.c end fmi2Instantiate()
 Done with fmi instantiate
 Warning, _debugListeners was null, which means that _debugging was set to true, but no listeners were added?
 Done with fmi instantiate
 #
 # A fatal error has been detected by the Java Runtime Environment:

Where "Done with fmi instantiate" is from the end of FMUImport.preinitialize().

How to build an FMU from within OpenModelica

There are several ways to create a .fmu

The simplest way is to create a .mos file like exportFMU.mos:

  loadModel(Modelica, {"3.2.1"});
   getErrorString();
  loadModel(HeatConductor); getErrorString();
  OpenModelica.Scripting.translateModelFMU(
    className=HeatConductor,
    version="2.0");
   getErrorString();

and then invoke

  omc exportFMU.mos

To use the tearingMethod, use:

  omc +tearingMethod=noTearing exportFMU.mos

To use sparse:

  omc +s +simCodeTarget=sfmi exportFMU.mos

Using omc creates the modelDescription.xml file and binaries for one platform.

Using omc is the most reliable method, though the fmu that is produced will not work on other platforms.

Ptolemy II has an extension that builds a fmu at runtime. This extension runs "make platformName", where platformName is the fmu platform such as linux64 or darwin64.

Unfortunately, the location of the OpenModelica platform varies between installations. Under Linux, OpenModelica tends to be located in /usr/local/openmodelica. Under Mac OS X, when installed using MacPorts, /opt/local.

Thus, building OpenModelica fmus from within Ptolemy is fragile.

HeatConductor example.

Here's a full example

loadModel(Modelica, {"3.2.1"});
getErrorString();
loadFile("HeatConductor.mo"); getErrorString();
OpenModelica.Scripting.translateModelFMU(
className=HeatConductor,
version="2.0");
getErrorString();

HeatConductor.mo contains:

model HeatConductor "Test model for QSS"
extends Modelica.Icons.Example;

Modelica.Blocks.Interfaces.RealInput TOut "Outside temperature"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));

Modelica.Blocks.Interfaces.RealOutput TSur "Surface temperature"
annotation (Placement(transformation(extent={{100,70},{120,90}})));

Real x "State";
initial equation
x=273.15;
equation
der(x) = TOut-x;
TSur = x;

annotation (uses(Modelica(version="3.2.1")), Diagram(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics));

end HeatConductor;

Under RHEL 6, to create HeatConductor.fmu

export LD_LIBRARY_PATH=/usr/local/gcc-4.8.2/lib64:/usr/local/lib:${LD_LIBRARY_PATH}
export OPENMODELICALIBRARY=`pwd`:/usr/local/openmodelica/lib
omc +tearingMethod=noTearing exportFMU.mos

fmuCheck

fmuCheck.csv contains:

time,TOut
0.0,270
0.1,271
0.2,272
0.3,273
0.4,274
0.5,275
0.6,276
0.7,277
0.8,278
0.9,279

Running fmuCheck -i fmuCheck.csv HeatConductor.fmu

2/20/2015 Note that this was fixed at some point

[INFO][FMI2XML] [Line:52] Detected during parsing:
[ERROR][FMI2XML] Initial 'calculated' is not allowed for variability 'continuous' and causality 'input'. \
Setting initial to 'approx'
[INFO][FMI2XML] [Line:59] Detected during parsing:
[ERROR][FMI2XML] Start attribute is required for this causality, variability and initial combination
[INFO][FMUCHK] Model name: HeatConductor
[INFO][FMUCHK] Model GUID: {8c4e810f-3df3-4a00-8276-176fa3c9f9e0}
[INFO][FMUCHK] Model version:
[INFO][FMUCHK] FMU kind: ModelExchange
[INFO][FMUCHK] The FMU contains:
0 constants
0 parameters
0 discrete variables
4 continuous variables
1 inputs
1 outputs
2 local variables
0 independent variables
0 calculated parameters
4 real variables
0 integer variables
0 enumeration variables
0 boolean variables
0 string variables

[INFO][FMUCHK] Printing output file header
time,TSur
[INFO][FMUCHK] Opening input file fmuCheck.csv
[INFO][FMUCHK] Detected separator character in input file: ,
[INFO][FMUCHK] Model identifier for ModelExchange: HeatConductor
[INFO][FMILIB] Loading 'darwin64' binary with 'default' platform types
[INFO][FMUCHK] Version returned from ME FMU: '2.0'

[FMU][logFmi2Call][FMU status:OK] fmi2Instantiate: GUID={8c4e810f-3df3-4a00-8276-176fa3c9f9e0}
[FMU][logFmi2Call][FMU status:OK] fmi2SetReal: nvr = 1
[FMU][logFmi2Call][FMU status:OK] fmi2SetReal: TOut = 270
[FMU][logFmi2Call][FMU status:OK] fmi2SetupExperiment: toleranceDefined=0 tolerance=1e-06 startTime=0 stopTimeDefined=0 stopTime=0
[FMU][logFmi2Call][FMU status:OK] fmi2SetTime: time=0
[FMU][logFmi2Call][FMU status:OK] fmi2EnterInitializationMode...
[FMU][logFmi2Call][FMU status:OK] fmi2EnterInitializationMode: succeed
[FMU][logFmi2Call][FMU status:OK] fmi2ExitInitializationMode...
[FMU][logFmi2Call][FMU status:OK] fmi2ExitInitializationMode: succeed
[FMU][logFmi2Call][FMU status:OK] fmi2NewDiscreteStates
[FMU][logFmi2Call][FMU status:OK] fmi2EventUpdate: Start Event Update! Next Sample Event 0
[FMU][logFmi2Call][FMU status:OK] fmi2EventUpdate: Checked for Sample Events! Next Sample Event 0
[FMU][logFmi2Call][FMU status:OK] fmi2NewDiscreteStates
[FMU][logFmi2Call][FMU status:OK] fmi2EventUpdate: Start Event Update! Next Sample Event 0
[FMU][logFmi2Call][FMU status:OK] fmi2EventUpdate: Checked for Sample Events! Next Sample Event 0

And it repeats.

This is what is similar to what Michael got with fmusdk_me

Using the OpenModelica test fmus

openmodelica/testsuite/openmodelica/fmi/ModelExchange/2.0 contains various .mos files that generate fmus and then import them.

  BouncingBall.mos        HelloFMIWorld.mos  testAssert.mos   testInitialEquationsFMI.mos
  HelloFMIWorldEvent.mos  Makefile           testBug2764.mos

The Makefile runs ../../../../rtest -v on each .mos file. It looks like rtest looks for directives in the comments of the .mos file and does set up and tear down.

Here's BouncingBall.mos:

// name: BouncingBall
// keywords: fmu export import
// status: correct
// teardown_command: rm -rf binaries sources modelDescription.xml BouncingBallFMI20* output.log BouncingB\
allFMI20/*
// Event handling in FMU Import
//

loadString("
model BouncingBallFMI20
parameter Real e=0.7 \"coefficient of restitution\";
parameter Real g=9.81 \"gravity acceleration\";
Real h(start=1) \"height of ball\";
Real v \"velocity of ball\";
Real v_new;
equation
der(v) = -g;
der(h) = v;

when h <= 0.0 then
v_new = -e*pre(v);
reinit(v, v_new);
end when;

end BouncingBallFMI20;
"); getErrorString();
translateModelFMU(BouncingBallFMI20, version = "2.0"); getErrorString();
importFMU("BouncingBallFMI20.fmu"); getErrorString();
loadFile("BouncingBallFMI20_me_FMU.mo"); getErrorString();
simulate(BouncingBallFMI20_me_FMU, stopTime=3.0); getErrorString();
val(h,0);
val(h,1);
val(h,3);

// Result:
// true
// ""
// "SimCode: The model BouncingBallFMI20 has been translated to FMU"
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// "BouncingBallFMI20_me_FMU.mo"
// ""
// true
// ""
// record SimulationResult
// resultFile = "BouncingBallFMI20_me_FMU_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 1e-06, \
method = 'dassl', fileNamePrefix = 'BouncingBallFMI20_me_FMU', options = '', outputFormat = 'mat', variab\
leFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// 1.0
// 0.225020520707377
// -0.9555208467051863
// endResult

If I run omc BouncingBall.mos, then BouncingBallFMI20.fmu is created and then imported, which creates BouncingBallFMI20_me_FMU.mo.

The BouncingBallFMI20.fmu can be loaded and run using BouncingBallFMI20_me_FMU.mo, see above for BouncingBall.mos

bash-4.1$ omc BouncingBall.mos
true
""
"SimCode: The model BouncingBallFMI20 has been translated to FMU"
"Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
"
"BouncingBallFMI20_me_FMU.mo"
""
true
""
record SimulationResult
resultFile = "/home/cxh/src/openmodelica/testsuite/openmodelica/fmi/ModelExchange/2.0/BouncingBallFMI\
20_me_FMU_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 1e-06, met\
hod = 'dassl', fileNamePrefix = 'BouncingBallFMI20_me_FMU', options = '', outputFormat = 'mat', variableF\
ilter = '.*', cflags = '', simflags = ''",
messages = "",
timeFrontend = 0.029402416,
timeBackend = 0.005088676,
timeSimCode = 0.006797096000000001,
timeTemplates = 0.017980524,
timeCompile = 0.366838514,
timeSimulation = 0.044405144,
timeTotal = 0.470683773
end SimulationResult;
"Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
"
1.0
0.225020520707377
-0.9555208445822925
bash-4.1$

Noncompliance

2/19/20 - This was fixed at some point in the past

However, running fmuCheck on BouncingBallFMI20.fmu goes into the loop:

        [FMU][logFmi2Call][FMU status:OK] fmi2EventUpdate: Start Event Update! Next Sample Event 0
        [FMU][logFmi2Call][FMU status:OK] fmi2EventUpdate: Checked for Sample Events! Next Sample Event 0

So, it seems like the OpenModelica FMI-2.0 Model Exchange fmus are no compliant.

I tried fixing the possible bug involving eventInfo->newDiscreteStatesNeeded = fmi2False; but that did not change much.

I created a HeatConductor.mos that was similar:

loadString("
model HeatConductor \"Test model for QSS\"
extends Modelica.Icons.Example;

Modelica.Blocks.Interfaces.RealInput TOut \"Outside temperature\"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));

Modelica.Blocks.Interfaces.RealOutput TSur \"Surface temperature\"
annotation (Placement(transformation(extent={{100,70},{120,90}})));

Real x \"State\";
initial equation
x=273.15;
equation
der(x) = TOut-x;
TSur = x;

annotation (uses(Modelica(version=\"3.2.1\")), Diagram(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics));

end HeatConductor;
"); getErrorString();

OpenModelica.Scripting.translateModelFMU(className=HeatConductor, version="2.0"); getErrorString();
importFMU("HeatConductor.fmu"); getErrorString();
loadFile("HeatConductor_FMU.mo"); getErrorString();
simulate(HeatConductor_me_FMU, stopTime=3.0); getErrorString();
val(h,270);
val(h,273);
val(h,275);

and it reproduced the error message that Michael got:

bash-4.1$ omc HeatConductor.mos
true
""
"SimCode: The model HeatConductor has been translated to FMU"
"Notification: Automatically loaded package Modelica 3.2.1 due to uses annotation.
Notification: Automatically loaded package Complex 3.2.1 due to uses annotation.
Notification: Automatically loaded package ModelicaServices 3.2.1 due to uses annotation.
"
"HeatConductor_me_FMU.mo"
"Error: module = Initial 'calculated' is not allowed for variability 'continuous' and causality 'input'. \
Setting initial to 'approx', log level = ERROR: FMI2XML
Error: module = Start attribute is required for this causality, variability and initial combination, log \
level = ERROR: FMI2XML
"
false
""
record SimulationResult
resultFile = "",
simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 1e-06, met\
hod = 'dassl', fileNamePrefix = 'HeatConductor_me_FMU', options = '', outputFormat = 'mat', variableFilte\
r = '.*', cflags = '', simflags = ''",
messages = "Simulation Failed. Model: HeatConductor_me_FMU does not exist! Please load it first befor\
e simulation.",
timeFrontend = 0.0,
timeBackend = 0.0,
timeSimCode = 0.0,
timeTemplates = 0.0,
timeCompile = 0.0,
timeSimulation = 0.0,
timeTotal = 0.0
end SimulationResult;
""

OpenModelica VanDerPol crash

At some point the OpenModelica VanDerPol demo started failing.

To replicate:

cd ~/src
svn co -r '{2015-04-01}' https://repo.eecs.berkeley.edu/svn/projects/eal/p\
tII/trunk ptII2015-04-01 >& svn.out
cd ptII2015-04-01
export PTII=`pwd`
(./configure; ant) >& ant.out
cd ptolemy/actor/lib/fmi/fmus/omc/test
make

Below is a sample crash, from 2015-04-01:

------------------ testing $PTII/ptolemy/actor/lib/fmi/fmus/omc/test/auto/VanDerPol.xml
auto.tcl: Setting watchdog for 200 seconds at Mon May 11 08:56:15 PDT 2015
FMUFile: Extracting to /tmp/FMUFile884956057910432359.tmp
84 ms. Memory: 930816K Free: 817697K (88%)
util.testsuite.WatchDog.cancel(): canceling Mon May 11 08:56:15 PDT 2015
auto.tcl: Setting watchdog for 200 seconds at Mon May 11 08:56:15 PDT 2015
34 ms. Memory: 930816K Free: 815099K (88%)
util.testsuite.WatchDog.cancel(): canceling Mon May 11 08:56:15 PDT 2015
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f733efea33c, pid=39207, tid=140132213507840
#
# JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build 1.8.0_45-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V  [libjvm.so+0x8cb33c]  Monitor::wait(bool, long, bool)+0x35c
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/cxh/src/ptII2015-04-01/ptolemy/actor/lib/fmi/fmus/omc/test/hs_err_pid39207.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
  • 2015-03-29
    • HeatConductor was compiled and ran
    • LorenzAttractor ran very quickly
    • VanDerPol was not present, but copying from 2015-03-29 and running all three demos passed.
    • Running $PTII/bin/ptinvoke ptolemy.actor.gui.PtolemyApplication -run20x auto/VanDerPol.xml eventually crashes
  • 2015-03-21
    • HeatConductor was compiled and ran
    • LorenzAttractor ran very quickly
    • VanDerPol crashed:
      # J 522 java.io.UnixFileSystem.getBooleanAttributes0(Ljava/io/File;)I (0 bytes) @ 0x00007f0098fc71a0 [0x00007f0098fc70c0+0xe0]
    • Running $PTII/bin/ptinvoke ptolemy.actor.gui.PtolemyApplication -run20x auto/VanDerPol.xml eventually crashes
  • 2015-03-29
    • HeatConductor was compiled and ran
    • Lorenz stopped in iteration 1 because the results changed
    • VanDerPol passed.
    • Interestingly, setting the trainingMode in LorenzAttractor to true and re-running then caused VanDerPol to crash. This points to a memory problem.
  • 2015-04-01
    • HeatConductor was compiled
    • LorenzAttractor had training mode set to false
    • VanDerPol crashed in the second run

VanDerPol

Looking at the above analysis, it seems like VanDerPol.fmu has a problem.

  1. Download and install fmusdk2:
    git clone https://github.com/cxbrooks/fmusdk2.git
    cd fmusdk2
    make
    cd fmu20/bin
  2. Run gdb
    [cxh@terra bin]$ gdb ./fmusim_me
    GNU gdb (GDB) Red Hat Enterprise Linux (7.2-75.el6)
    Copyright (C) 2010 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "x86_64-redhat-linux-gnu".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /home/cxh/src/fmi/fmusdk2/fmu20/bin/fmusim_me...done.
    (gdb) r /home/cxh/src/ptII2015-03-29/ptolemy/actor/lib/fmi/fmus/omc/test/auto/VanDerPol.fmu
    Starting program: /home/cxh/src/fmi/fmusdk2/fmu20/bin/fmusim_me /home/cxh/src/ptII2015-03-2\
    9/ptolemy/actor/lib/fmi/fmus/omc/test/auto/VanDerPol.fmu
    warning: File "/usr/local/gcc-4.9.2/lib64/libstdc++.so.6.0.20-gdb.py" auto-loading has been\
     declined by your `auto-load safe-path' set to "/usr/share/gdb/auto-load:/usr/lib/debug:/us\
    r/bin/mono-gdb.py".
    To enable execution of this file add
            add-auto-load-safe-path /usr/local/gcc-4.9.2/lib64/libstdc++.so.6.0.20-gdb.py
    line to your configuration file "/home/cxh/.gdbinit".
    To completely disable this security protection add
            set auto-load safe-path /
    line to your configuration file "/home/cxh/.gdbinit".
    For more information about this security protection see the
    "Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
            info "(gdb)Auto-loading safe path"
    [Thread debugging using libthread_db enabled]
    cmd='
    unzip -o -d fmuTmpCTMcHr/ "/home/cxh/src/ptII2015-03-29/ptolemy/actor/lib/fmi/fmus/omc\
    /test/auto/VanDerPol.fmu"
    > /dev/null'
    Detaching after fork from child process 47182.
    fmiModelDescription
      fmiVersion=2.0
      modelName=VanDerPol
      guid={8c4e810f-3df3-4a00-8276-176fa3c9f9e0}
      description=Van der Pol oscillator model
    ModelExchange
      modelIdentifier=VanDerPol
    dllPath = fmuTmpCTMcHr/binaries/linux64/VanDerPol.so
    FMU Simulator: run '
    /home/cxh/src/ptII2015-03-29/ptolemy/actor/lib/fmi/fmus/omc/test/auto/V\
    anDerPol.fmu' from t=0..1 with step size h=0.1, loggingOn=0, csv separator=',' log categori\
    es={ }

    Program received signal SIGSEGV, Segmentation fault.
    0x00007ffff65267e2 in GC_find_limit_with_bound ()
       from /usr/local/openmodelica/lib/omc/libgc.so.1
    Missing separate debuginfos, use: debuginfo-install atlas-3.8.4-2.el6.x86_64 blas-3.2.1-4.e\
    l6.x86_64 glibc-2.12-1.149.el6_6.7.x86_64 libxml2-2.7.6-17.el6_6.1.x86_64 zlib-1.2.3-29.el6\
    .x86_64
    (gdb) where
    #0  0x00007ffff65267e2 in GC_find_limit_with_bound ()
       from /usr/local/openmodelica/lib/omc/libgc.so.1
    #1  0x00007ffff65268e2 in GC_init_linux_data_start ()
       from /usr/local/openmodelica/lib/omc/libgc.so.1
    #2  0x00007ffff6525352 in GC_init () from /usr/local/openmodelica/lib/omc/libgc.so.1
    #3  0x00007ffff651f809 in GC_generic_malloc_inner ()
       from /usr/local/openmodelica/lib/omc/libgc.so.1
    #4  0x00007ffff651f8ce in GC_generic_malloc ()
       from /usr/local/openmodelica/lib/omc/libgc.so.1
    #5  0x00007ffff767c40b in fmi2Instantiate ()
       from fmuTmpCTMcHr/binaries/linux64/VanDerPol.so
    #6  0x00000000004024ae in simulate (fmu=0x616a60, tEnd=1, h=0.10000000000000001,
        loggingOn=0, separator=44 '
    ,', nCategories=0, categories=0x0)
        at model_exchange/main.c:75
    #7  0x0000000000403139 in main (argc=2, argv=0x7fffffffe578) at model_exchange/main.c:275
    (gdb)

The same issue happens with the most recent VanDerPol.fmu in the ptII tree.

The next step is to update OpenModelica and try again.

Edit - History - Print - Recent Changes - Search
Page last modified on December 22, 2015, at 06:17 PM