0

I am new to the Modelica world and installed JModelica2.14 on win10 via the binary file provided from the offical webpage. From the console I call setenv.bat, start the 64bit python envrionment and import '.\install\Python_64'. However, running the example files already throws an error. The minimal code example throwing the error is provided below. I assume that the binaries do not have a bug without anyone mentioning it. It would be great if someone could give a hint about what I am missing. Thanks a lot!

import modelicacasadi_wrapper
modelicacasadi_wrapper.OptimicaOptionsWrapper()
RuntimeError                              Traceback (most recent call last)
<ipython-input-11-ce2bcdfa3f06> in <module>()
----> 1 modelicacasadi_wrapper.OptimicaOptionsWrapper()

C:\JModelica.org-2.14\install\Python_64\modelicacasadi_wrapper\modelicacasadi_wrapper.pyc in __init__(self, *args)
3472         __init__(ModelicaCasADi::OptimicaOptionsWrapper self, OptimicaOptionsWrapper other) -> OptimicaOptionsWrapper
3473         """
-> 3474         this = _modelicacasadi_wrapper.new_OptimicaOptionsWrapper(*args)
3475         try:
3476             self.this.append(this)

RuntimeError: java.lang.NoClassDefFoundError  org/jmodelica/optimica/compiler/ModelicaCompiler
Caused by: java.lang.ClassNotFoundException: org.jmodelica.optimica.compiler.ModelicaCompiler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

This function is only given in binary format compiled from c++ code. therefore, I can not change the function without recompiling the library (I already tried). To me it seems like the org.jmodelica.optimica.compiler.ModelicaCompiler should have been a org.jmodelica.optimica.compiler.OptimicaCompiler. This would mean that I have to install the package from source and I haven't been sucessful with that yet.

S14p
  • 51
  • 1
  • 7
  • 1
    I suggest to switch to OpenModelica if you are looking for an opensource tool, the development of JModelica as open source has stopped several years ago. There is no support of the recent version of the MSL 4.0.0 https://stackoverflow.com/questions/73358199/how-to-upgrade-msl-to-4-0-in-jmodelica?rq=1 – Imke Krueger Feb 13 '23 at 09:11
  • thanks for the advice. I just wanted to try out an outdated toolbox which is based on Jmodelica. But it seems like it is quite a pain to get it running. – S14p Feb 13 '23 at 09:32
  • what do you want to do? A lot has happened in the Modelica/FMI world in the last years... – Imke Krueger Feb 13 '23 at 10:54
  • I want to use a grey_box library for buildings from KUL and I have been also been talking to one of their team members and he also suggested to look into rather recent libraries. – S14p Feb 15 '23 at 08:08

1 Answers1

0

I still use JModelica 2.14 in Python 2 and then have installed virtual environment with Conda to create a Python 3 environment where I then run the FMUs with the latest PyFMI package in Python 3.10 and Jupyter notebook. It all works very fine, but as Imke Kreuger indicated you have MSL 3.2.2 build 3 and there has been development in the Modelica Standard Library since then.

During installation you are asked whether you want "Graybox OPC Automation wrapper" and I usually say "NO" there. You may have said "YES" though, right? See Chapter 2.2.1 in the User guide.

The JModelica installation actually provide you with two different compilers. One is for standard Modelica brings as output an FMU of CS or ME type. The other compiler is for Modelica extended with Optimica and does not bring any FMU and you are bound to work in Python 2.

Tried to reproduce your error (with my installation without the "Graybox OPC..."). If I (in the Python 2 environment) literally do the two commands, I get "Press any key to continue...." and when I press key the IPython window collapse.

However if you skip the two brackets at the end of the second command, then it is accepted!

If you write a question mark at the end you get information about what arguments you should have.

If you describe better what you want to do, we likely can help you better.

Note, it seems you want to use Optimica and that is an extension of Modelica that is only partially supported by OpenModelica, what I understand. The Optimica extension is well integrated in JModelica and originated in this context. For "ordinary" Modelica use I do not think you need to use this wrapper.

janpeter
  • 681
  • 8
  • 22
  • 1
    yes, I installed it with the Gaybox OPC automation wrapper. This wrapper is used by the grey box library that I actually want to use. Therefore, I kinda need it. However, I will look into a different option. Thanks for your answer. – S14p Feb 15 '23 at 08:12
  • Ok, I understand beteter. Actually I am bit interested in grey box identification and wonder if this library is public (perhaps Github)? – janpeter Feb 15 '23 at 09:50
  • Unfortunately, no. It is only free for academia. – S14p Feb 16 '23 at 17:44