NullPointerException, когда compile_fmu используется для моделирования файла Dymola * .mo из библиотеки

Библиотека, которую я использую, основана на MSL и Modelica Buildings Library. Модель может быть смоделирована 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)

person Debs    schedule 26.11.2018    source источник


Ответы (1)


JModelica.org обрабатывает структурированные библиотеки без особых проблем. Из первой строки журнала видно, что он обнаружил, что файл, на который вы ссылаетесь, находится внутри библиотеки. Проблема выглядит как ошибка, которая запускается для некоторого выражения, используемого в модификации в массиве компонентов где-то в модели. Предлагаю попробовать последнюю версию (сейчас 2.4).

Я также рекомендую использовать рабочий каталог, который находится за пределами библиотеки, чтобы сгенерированные файлы не попадали в библиотеку.

person Jesper Mattsson    schedule 25.01.2019