2

I created a basic model of a hot water storage cylinder in Dymola using components from the buildings library package. I have saved the model as an .mo file and successfully compiled the fmu and loaded the model in JModelica. The problem occurs when I simulate using:

res = model.simulate(final_time=100000)

This results in the following error message:

FMUException Traceback (most recent call last) in () ----> 1 res = model.simulate(final_time=100000)

src\pyfmi\fmi.pyx in pyfmi.fmi.FMUModelME1.simulate (src\pyfmi\fmi.c:35608)()

src\pyfmi\fmi.pyx in pyfmi.fmi.ModelBase._exec_simulate_algorithm (src\pyfmi\fmi.c:6045)()

src\pyfmi\fmi.pyx in pyfmi.fmi.ModelBase._exec_simulate_algorithm (src\pyfmi\fmi.c:5936)()

C:\JModelica.org-2.1\install\Python\pyfmi\fmi_algorithm_drivers.pyc in init(self, start_time, final_time, input, model, options) 300 if isinstance(self.model, fmi.FMUModelME1): 301 self.model.time = start_time #Set start time before initialization --> 302 self.model.initialize(tolerance=rtol) 303 304 elif isinstance(self.model, fmi.FMUModelME2) or isinstance(self.model, fmi_coupled.CoupledFMUModelME2):

src\pyfmi\fmi.pyx in pyfmi.fmi.FMUModelME1.initialize (src\pyfmi\fmi.c:34954)()

FMUException: Initialize returned with an error. Check the log for information (FMUModel.get_log).

As suggested I have checked the log using model.get_log() which also does not make much sense:

FMIL: module = Model, log level = 2: [ERROR][FMU status:Error] Could not bracket the root in "1". Both lower and upper are at bounds.

FMIL: module = Model, log level = 2: [INFO][FMU status:Error] Initialization failed.

FMIL: module = Model, log level = 2: [ERROR][FMU status:Error] Could not bracket the root in name="block">"1". Both lower and upper are at bounds.

FMIL: module = Model, log level = 2: [INFO][FMU status:Error] Initialization failed.

FMIL: module = Model, log level = 2: [ERROR][FMU status:Error] category="error">Could not bracket the root in name="block">"1". Both lower and upper are at> bounds.

FMIL: module = Model, log level = 2: [INFO][FMU status:Error] Initialization failed.

FMIL: module = Model, log level = 2: [ERROR][FMU status:Error] category="error">Could not bracket the root in name="block">"1". Both lower and upper are at> bounds.

FMIL: module = Model, log level = 2: [INFO][FMU status:Error] Initialization failed.

Any recommendations on what is going on here? I've heard many people constructing systems with Dymola, saving the script and then importing and simulating in JModelica. However could this be the problem here?

Jon S
  • 15,846
  • 4
  • 44
  • 45
alkey
  • 986
  • 4
  • 16
  • 33
  • .mo is for Modelica models, .mos is for scripts, so maybe you should save it as .mo instead? And you should make sure to use the latest versions of Buildings adn JModelica, because compatibility has been improved with the latest versions. – matth Mar 05 '18 at 11:43
  • 1
    @matth Apologies, I made a typo, the file is saved as a .mo and I am using the latest versions of both JModelica and the buildings library – alkey Mar 05 '18 at 12:06
  • The cause for problems like this can vary a lot from case to case. But usually it is due to different states or different iteration variables. In your case it looks like JModelica.org has different iteration variables than Dymola for initial block 1, so please, check which iteration variables you have in initial block 1. – Jon S Mar 05 '18 at 12:43
  • @Jon-S I am sorry I am new to Modelica, how do I compare the iteration variables in JModelica with Dymola? – alkey Mar 05 '18 at 13:46
  • Fully understand, unfortunately this is a big topic, I would suggest that you read some of the books about Modelica. As for finding the iteration variables for JModelica.org, generate HTML diagnostics (http://www.jmodelica.org/api-docs/usersguide/2.1/ch04s05.html#d0e1256) and check the initial BLT. – Jon S Mar 05 '18 at 13:54
  • @Jon-s Thanks for your reply. To be honest, I am trying to build a workflow that will enable me to create models with package dependencies, save them as a separate .mo file, and then compile and simulate the results in JModelica. On the surface I thought this would be simple but I suspect the errors could be creeping in at any stage of this process. – alkey Mar 05 '18 at 15:27
  • I realise I am late to the issue, but during my testing, I found that PyFMI does not work reliably with FMUs. I faced a similar issue with ThermoSysPro library FMUs, OpenIPSL FMUs. I suggest you use the FMPy library. I have tested it with almost every model FMUs and found it to be working more reliable than others. – Digvijay Gusain Dec 17 '18 at 18:20

1 Answers1

0

From the error message we get that the there is a block in the model that is difficult solve (block 1) and that we cannot find a solution with the given upper and lower bounds. Depending on if you have set min/max values on variables, this can be the problem. This is due that the block in question is one dimensional and solved using Brents method which takes into account min/max values.

I recommend to run the model with a higher log level and see if this is the case. Try and then check the log:

model = load_fmu("...", log_level=6)
model.set("_log_level", 8)
...
Christian Winther
  • 1,113
  • 1
  • 9
  • 17