Opened 6 years ago

Closed 6 years ago

#5169 closed defect (fixed)

HelmholtzMedia models failing with the NF on Hudson

Reported by: Francesco Casella Owned by: Lennart Ochel
Priority: high Milestone: 2.0.0
Component: Backend Version:
Keywords: Cc: m.thorade@…, Per Östlund

Description

Several models of HelmholtzMedia fail on Hudson like HelmholtzMedia.Examples.ConvergenceTest.SinglePhase_setState_b, giving this error message:

Failed to read output from testmodel.py, exit status != 0:
2018-10-10 21:23:05,453 - OMPython - INFO - OMC Server is up and running at file:////tmp/openmodelica.hudson.port.53caf36b2f8c44a99d34133820530e55 pid=47607
2018-10-10 21:23:05,714 - OMPython - INFO - OMC Server is up and running at file:////tmp/openmodelica.hudson.port.581abf38b7d344568e2fedb49c24eb9b pid=47614

The front-end is not reported as having finished, so I guess it just crashes badly, but I'm not sure.

Attachments (5)

SinglePhase_setState_b_stateOnly.mo (2.4 KB ) - added by Francesco Casella 6 years ago.
SinglePhase_setState_b_state_ph.mo (2.4 KB ) - added by Francesco Casella 6 years ago.
SinglePhase_setState_b_inlinedOnly.mo (2.5 KB ) - added by Francesco Casella 6 years ago.
SinglePhase_setState_b_state_ph2.mo (2.3 KB ) - added by Francesco Casella 6 years ago.
SinglePhase_setState_b_state_ph3.mo (2.4 KB ) - added by Francesco Casella 6 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by Per Östlund, 6 years ago

Component: New InstantiationBackend
Owner: changed from Per Östlund to Lennart Ochel

No, the frontend finishes, but it then seems to get stuck in evalFunc in the backend. The Hudson script crashes for some reason, so Hudson gets no information on the progress. It's possible that it's just taking a long time, but the memory consumption remains constant after a while.

comment:2 by Francesco Casella, 6 years ago

After the latest commits, Hudson reports a stack overflow in BackendDAEUtil.getSolvedSystem.

After an initial transient, the stack trace shows this periodically repeating sequence of function calls

[bt] #534 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateConstantFunction)
[bt] #535 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateConstantFunctionWrapper)
[bt] #536 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(boxptr_EvaluateFunctions_evaluateConstantFunctionWrapper)
[bt] #537 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Expression.traverseExpTopDown)
[bt] #538 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateStatement)
[bt] #539 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateAllStatements)
[bt] #540 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.predictIfOutput)
[bt] #541 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateStatement)
[bt] #542 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateAllStatements)
[bt] #543 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.predictIfOutput)
[bt] #544 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateStatement)
[bt] #545 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateIfStatement)
[bt] #546 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateStatement)
[bt] #547 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateAlgElements)
[bt] #548 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(boxptr_EvaluateFunctions_evaluateFunctions__updateAlgElements)
[bt] #549 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(List.mapFold3)
[bt] #550 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateConstantFunction)
[bt] #551 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateConstantFunctionWrapper)
[bt] #552 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(boxptr_EvaluateFunctions_evaluateConstantFunctionWrapper)
[bt] #553 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Expression.traverseExpTopDown)
[bt] #554 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateStatement)
[bt] #555 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateAllStatements)
[bt] #556 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.predictIfOutput)
[bt] #557 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateStatement)
[bt] #558 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(EvaluateFunctions.evaluateFunctions_updateAlgElements)
[bt] #559 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(boxptr_EvaluateFunctions_evaluateFunctions__updateAlgElements)
[bt] #560 /var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(List.mapFold3)

which looks to me like an infinite loop.

I tried to make the test case simpler (see attachment SinglePhase_setState_b_stateOnly.mo) by only keeping this equation

  state = Medium.setState_pT(p = p, T = T, phase = 0);

and commenting out these other ones, as well as their corresponding state record definitions

  state_dT = Medium.setState_dT(d = Medium.density(state), T = Medium.temperature(state), phase = 0);
  state_pd = Medium.setState_pd(p = Medium.pressure(state), d = Medium.density(state), phase = 0);
  state_ph = Medium.setState_ph(p = Medium.pressure(state), h = Medium.specificEnthalpy(state), phase = 0);
  state_ps = Medium.setState_ps(p = Medium.pressure(state), s = Medium.specificEntropy(state), phase = 0);
  state_Ts = Medium.setState_Ts(T = Medium.temperature(state), s = Medium.specificEntropy(state), phase = 0);

By doing so, the code generation proceeds until the C-code compilation phase, which fails with this error:

SinglePhase_setState_b_stateOnly_functions.c: In function 'omc_SinglePhase__setState__b__stateOnly_Medium_setSat__T':
SinglePhase_setState_b_stateOnly_functions.c:241:10: error: '_Medium' undeclared (first use in this function)
   tmp5 = _Medium._fluidConstants[1]._criticalMolarVolume;

which is the same issue reported in #5167.

As soon as I add the call to

  state_ph = Medium.setState_ph(p = Medium.pressure(state), h = Medium.specificEnthalpy(state), phase = 0);

(see SinglePhase_setState_b_state_ph.mo) and try to run the model, OMEdit hangs, so apparently the issue is with the equations stemming from this specific function call. The flattened model contains the equations

  state = SinglePhase_setState_b_state_ph.Medium.setState_pT(p, T, 0);
  state_ph = SinglePhase_setState_b_state_ph.Medium.setState_ph(
    SinglePhase_setState_b_state_ph.Medium.pressure(state), 
    SinglePhase_setState_b_state_ph.Medium.specificEnthalpy(state),
    0);

which seem both correct to me. So, it seems there may be some issues with the Medium.pressure(state) and Medium.temperature(state) function calls, that should be inlined and simply return state.p and state.T.

I then ran a third test case (SinglePhase_setState_b_state_inlinedOnly) where I just included this function call

  p1 = Medium.pressure(state);

which compiles correctly until it runs into issue #5167.

So, my diagnosis is that there is something wrong with function calls whose arguments are function calls that should be inlined.

by Francesco Casella, 6 years ago

by Francesco Casella, 6 years ago

by Francesco Casella, 6 years ago

comment:3 by Francesco Casella, 6 years ago

Cc: Per Östlund added

comment:4 by Francesco Casella, 6 years ago

Update: I tried this simple model using the IF97 water model

model TestInlinedCall
  package Medium = Modelica.Media.Water.StandardWater;
  Medium.AbsolutePressure p;
  Medium.Temperature T;
  Medium.ThermodynamicState state;
  Medium.ThermodynamicState state_ph;
equation
  p = 1e5*(1+time);
  T = 300+50*time;
  state = Medium.setState_pT(p,T);
  state_ph = Medium.setState_ph(Medium.pressure(state), Medium.specificEnthalpy(state),0);
end TestInlinedCall;

with the NF and it runs nicely

Apparently there is something HelmholtzMedia-specific in this failure, because the same pattern that makes the SinglePhase_setState_b_state_ph.mo fail with HelmholtzMedia runs fine with the IF97 model.

comment:5 by Francesco Casella, 6 years ago

OK, I ran a variant without the inlined function call

  state_ph = Medium.setState_ph(state.p, state.h, phase = 0);

and it still fails. In fact, SinglePhase_setState_b_state_ph3.mo, which only has the call

  state = Medium.setState_ph(p = p, h = 1e5, phase = 0);

fails already. So the problem is with Medium.setState_ph.

by Francesco Casella, 6 years ago

by Francesco Casella, 6 years ago

comment:6 by Francesco Casella, 6 years ago

Resolution: fixed
Status: newclosed

I further analyzed the issue, which now seems to me 100% due to the back-end. I have opened #5182 accordingly.

Note: See TracTickets for help on using tickets.