NullPointerException when compile_fmu used for simulation of Dymola *.mo file from library

119 views Asked by At

The libraray I‘m using is based on the MSL and the Modelica Buildings Library. The model can be simulated by Dymola without any error messages or warnings. The MODELICAPATH is set in the bashrc and the PYTHONPATH too. I use JModelica 2.1, Python 2.7 and Ubuntu 16.04.
Obviously library and model are found, so I assume the path is not the actual problem. When I use compile_fmu for simulating a model that is not part of a library everything works perfectly. So to me it seems that pymodelica has problems with the library structure or something like that. Do you have any idea what is happening here?

from pymodelica import compile_fmu
...
fmu=compile_fmu('BuildingModel.Examples.ExampleBuilding','ExampleBuilding.mo')

Error message:

File 'ExampleBuilding.mo' is part of library at '/home/debs/Schreibtisch/BuildingModel', using library instead.
Unknown program error, java.lang.NullPointerException
Traceback (most recent call last):
  File "Building_Simulation.py", line 239, in <module>
    fmu=compile_fmu('BuildingModel.Examples.ExampleBuilding','ExampleBuilding.mo')
  File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler.py", line 141, in compile_fmu
    separate_process, jvm_args)       
  File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler.py", line 248, in _compile_unit
    compiler_options, compile_to, compiler_log_level, jvm_args)
  File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler.py", line 362, in compile_separate_process
    return log.end();
  File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler_logging.py", line 334, in end
    raise JError("%s\n%s" % (exception.message, exception.stacktrace))
pymodelica.compiler_exceptions.JError: 
java.lang.NullPointerException
    at org.jmodelica.modelica.compiler.CommonForIndex.addReplacementEntry(Unknown Source)
    at org.jmodelica.modelica.compiler.FIterExp.splitArrayExp(Unknown Source)
    at org.jmodelica.modelica.compiler.FArray.splitArrayExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstArrayComponentDecl.Define_splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.ASTNode.Define_splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.Define_splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.ASTNode.Define_splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.Define_splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.ASTNode.Define_splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.splitBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstAssignable.getBindingFExp_compute(Unknown Source)
    at org.jmodelica.modelica.compiler.InstAssignable.getBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstAssignable.hasBindingFExp(Unknown Source)
    at org.jmodelica.modelica.compiler.InstAssignable.isCircular_compute(Unknown Source)
    at org.jmodelica.modelica.compiler.InstAssignable.isCircular(Unknown Source)
    at org.jmodelica.modelica.compiler.FIdUseInstAccess.isCircular(Unknown Source)
    at org.jmodelica.modelica.compiler.FIdUseExp.isCircularCalc(Unknown Source)
    at org.jmodelica.modelica.compiler.FAbstractExp.isCircular_compute(Unknown Source)
    at org.jmodelica.modelica.compiler.FAbstractExp.isCircular(Unknown Source)
    at org.jmodelica.modelica.compiler.FExp.ceval(Unknown Source)
    at org.jmodelica.modelica.compiler.FExp.ceval(Unknown Source)
    at org.jmodelica.modelica.compiler.MutableSize.evaluate(Unknown Source)
    at org.jmodelica.modelica.compiler.MutableSize.get(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComponentDecl.childDimensionLength(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComponentDecl.getInstComponentDeclList_compute(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComponentDecl.getInstComponentDeclList(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComposite.getInstComponentDecls(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
    at org.jmodelica.modelica.compiler.InstArrayComponentDecl.subType(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.subType(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComponentDecl.typeCheckReplacingComponent(Unknown Source)
    at org.jmodelica.modelica.compiler.InstReplacingComposite.typeCheck(Unknown Source)
    at org.jmodelica.modelica.compiler.ErrorChecker$TypeChecker.check(Unknown Source)
    at org.jmodelica.modelica.compiler.ASTNode.allChecks(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComponentDecl.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstExtends.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstComponentDecl.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstBaseClassDecl.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstFullClassDecl.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.InstLibNode.collectErrors(Unknown Source)
    at org.jmodelica.modelica.compiler.ASTNode.errorCheck(Unknown Source)
    at org.jmodelica.modelica.compiler.InstClassDecl.checkErrorsInModelInstance(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.doInstantiateModel(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.instantiateModel(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.instantiateModel(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.doCompileModel(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.compileModel(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.doCompileUnit(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.compileUnit(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.compileUnit(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.compileModelFromCommandLine(Unknown Source)
    at org.jmodelica.modelica.compiler.ModelicaCompiler.main(Unknown Source)
1

There are 1 answers

0
Jesper Mattsson On

JModelica.org handles structured libraries with no particular problems. You can see from the first line of the log that it detected that the file you referred to is inside a library. The problem looks to be a bug that triggers on some expression used in a modification on an array of components somewhere in the model. I'd suggest trying the latest version (currently 2.4).

I'd also recommend using a working directory that is outside the library, so that generated files do not wind up in the library.