当compile_fmu用于模拟库中的Dymola * .mo文件

时间:2018-11-26 16:08:19

标签: jmodelica

我正在使用的天秤座基于MSL和Modelica Buildings库。 Dymola可以模拟该模型,而不会出现任何错误消息或警告。 MODELICAPATH也设置在bashrc和PYTHONPATH中。我使用JModelica 2.1,Python 2.7和Ubuntu 16.04。
显然可以找到库和模型,因此我认为路径不是实际问题。 当我使用compile_fmu模拟不属于库的模型时,一切运行正常。所以在我看来pymodelica的库结构或类似的东西有问题。你知道这里发生了什么吗?

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

错误消息:

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 个答案:

答案 0 :(得分:1)

JModelica.org处理结构化库没有任何特殊问题。您可以从日志的第一行中看到它检测到您所引用的文件在库中。问题似乎是一个错误,该错误会触发对模型中某个位置的一组组件的修改中使用的某些表达式。我建议尝试使用最新版本(当前为2.4)。

我还建议使用库外部的工作目录,以免生成的文件在库中结束。