Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#5139 closed defect (fixed)

Initialization failures due to min/max and assert() violations do not trigger the homotopy-based initialization

Reported by: casella Owned by: AnHeuermann
Priority: high Milestone: 1.16.0
Component: Run-time Version:
Keywords: Cc: lochel, Karim.Abdelhak, adeas31

Description (last modified by casella)

Please run this model

model Test
  Real x(min = 0);
  Real y(start = 0, fixed = true);
equation
  0 = homotopy(1e-6*x + sin(x+0.5),
               x-2.65);
  der(y) = x;
  annotation(__OpenModelica_commandLineOptions = "-d=nowarnMinMax");
end Test;

The simulation fails with

assert | warning | The following assertion has been violated at time 0.000000 x > = 0.0
assert | error | Variable violating min constraint: 0.0 <= x, has value: -0.5
assert | info | simulation terminated by an assertion at initialization
stdout | error | Simulation process failed. Exited with code -1.

The User's Guide says about -homotopyOnFirstTry:

If the model contains the homotopy operator, directly use the homotopy method to solve the initialization problem. Without this flag, the solver first tries to solve the initialization problem without homotopy and only uses homotopy as fallback option.

If this was actually done, homotopy would ensure the convergence of the nonlinear solver to the positive solution, which would then be accepted by the min/max checks.

A similar issue takes place with ModelicaTest.Blocks.LimitersHomotopy, which currently fails with the message:

Regular simulation: ./ModelicaTest_3.2.3_ModelicaTest.Blocks.LimitersHomotopy -abortSlowSimulation -alarm=480   
assert            | warning | The following assertion has been violated during initialization at time 0.000000
|                 | |       | abs(mustUseHomotopy.x - 100.0) < 1e-06
assert            | error   | Wrong solution selected
assert            | info    | simulation terminated by an assertion at initialization

as well as many other test cases in ModelicaTest.

In both cases I would suggest to print out the following notification message:

Invalid initial solution obtained without homotopy. Trying with homotopy-based initialization. You can skip the attempt without homotopy with the -homotopyOnFirstTry simulation flag.

then restart the solution process with the homotopy-based solver.

Attachments (3)

resultAdaptiveStepsize.xml (523.0 KB) - added by AnHeuermann 5 years ago.
Results for failing tests with adaptive homotopy
resultFixedStepsize.xml (1.8 MB) - added by AnHeuermann 5 years ago.
Results for failing tests with fixed stepsize homotopy
comparison.xlsx (10.4 KB) - added by AnHeuermann 5 years ago.
Comparision between homotpy with fixed and adaptive steps

Change History (34)

comment:1 Changed 5 years ago by casella

  • Milestone changed from 1.13.0 to 1.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:2 Changed 5 years ago by casella

  • Cc lochel AnHeuermann added
  • Description modified (diff)
  • Owner changed from wbraun to AnHeuermann
  • Status changed from new to assigned
  • Summary changed from Initialization failure due to min/max violations do not trigger the homotopy-based initialization to Initialization failures due to min/max and assert() violations do not trigger the homotopy-based initialization

Widened the scope of the ticket and made it a blocker for 1.14.0, as it involves ModelicaTest 3.2.3. Should be a quick fix.

Andreas, Karim, Lennart, please have a look and decide who takes care of it.

comment:3 Changed 5 years ago by casella

  • Cc Karim.Abdelhak added; AnHeuermann removed
  • Description modified (diff)

comment:4 Changed 5 years ago by AnHeuermann

I made a PR (https://github.com/OpenModelica/OpenModelica/pull/203) to solve this ticket.
I would prefere to use the homotopy solver directly for any model with homotopy operators, as statet in the user guide.
But I'm not shure if this is the fastes approach. Maybe changing the user guide and always try to initialize without homotopy first (except for -homotopyOnFirstTry) is faster for most models with homotopy. But then why whould the modeler add a homotpy operator for initialization?

@casella What is your opinion on this?

comment:5 Changed 5 years ago by casella

  • Cc adeas31 added

Good question. It's a matter of trade-off. In fact, homotopy is used for two purpose:

  • avoid convergence failures
  • steer the convergence to the preferred (or physically meaningful) solution

Note that you add homotopy at the *component* level, but then the fact that it is necessary or not depends on how you build the *system* model - in some cases, it may actually not be really necessary.

If the problem only has one solution, trying without homotopy first means that if you are lucky, you get the solution faster than by using homotopy first, while if you are not lucky, you get it slower than by using homotopy first. In this case it is only a matter of time.

If the problem has multiple solutions, trying without homotopy first may lead to convergence to the wrong solution, which is really bad. On the other hand, I'm not sure how many models around actually need this feature, probably it is a very small percentage.

Since in general you don't know in which case you are, the fail-safe approach is to always use homotopy first if it is used by the model, and that's actually the solution I prefer. In fact, Dymola developers took the other approach, because when they introduced homotopy they were worried that user would see the simulation time of previously well-working models to increase with the new version, and they have a policy against that. I don't think we have this kind of requirement, though we should avoid extreme cases, like overall simulation time getting 5 times slower because of that.

In general, I would tend to favour reliability and robustness over sheer best-case performance, unless the performance penalty is really bad.

So, my suggestion is:

  • set -homotopyOnFirstTry to true as default (of course only if homotopy is used in the model)
  • make sure that we have adaptive step-size homotopy which doesn't take more than a few steps if the initialization problem is easy to solve
  • allow to set the flag to false easily in OMEdit via some checkbox
  • in OMEdit, output a warning in the simulation logs when homotopy-based initialization is attemped first and takes more than, say, 40% of the total simulation time, like:

Homotopy-based initialization took XX% of the total simulation time. It may be possible that the model can be initialized successfully and in a shorter time without homotopy, click *here* to change the default setting to avoid using homotopy on the first attempt to solve the initialization problem.

Changed 5 years ago by AnHeuermann

Results for failing tests with adaptive homotopy

Changed 5 years ago by AnHeuermann

Results for failing tests with fixed stepsize homotopy

Changed 5 years ago by AnHeuermann

Comparision between homotpy with fixed and adaptive steps

comment:6 follow-up: Changed 5 years ago by AnHeuermann

I compared results of the failing tests with adaptive step-size and fixed step-size (4 homotpy steps).

Astonishingly the approach with fixed step-size is way more robust than with adaptive steps. Also the fixed version needs always less or equal many homotopy steps.
The total simulation time is comparable. Roughly +/- 10% but I only run the tests once each.

So in conclusion I would suggest to use homotopy with fixed step-size to get a robust initialization. There are still failing models. I'm going to have a look into them to see what's the problem there.

Last edited 5 years ago by AnHeuermann (previous) (diff)

comment:7 in reply to: ↑ 6 Changed 5 years ago by casella

Replying to AnHeuermann:

I compared results of the failing tests with adaptive step-size and fixed step-size (4 homotpy steps).

Astonishingly the approach with fixed step-size is way more robust than with adaptive steps. Also the fixed version needs always less or equal many homotopy steps.
The total simulation time is comparable. Roughly +/- 10% but I only run the tests once each.

So in conclusion I would suggest to use homotopy with fixed step-size to get a robust initialization.-

As an immediate solution, I agree. As a long-term solution, I think we should understand why the adaptive step size solver fails and improve it until it performs better than the fixed step-size one.

BTW, I suspect that in many cases, one homotopy step is enough, e.g., first solve the simplified model (which has favourable convergence properties), and then use the found results to solve the actual problem outright. I suspect in most cases this would work, and ensure even faster convergence than we hav now. @AnHeuermann, I would suggest that you try this out, and if this works in most cases, we could implement a simple step adaptation strategies that first tries to go from lambda = 0 to lambda = 1 in one step, and only try four if this fails.

There are still failing models. I'm going to have a look into them to see what's the problem there.

OK. Let me know if I can help with them.

comment:8 Changed 5 years ago by casella

@AnHeuermann, it is not clear to me what is the status with this issue and with PR 203, which now has some conflicts.

Can we get through this and close it for good?

Thanks!

comment:9 Changed 5 years ago by AnHeuermann

Ther are some test that are working better now and initialze without or with fewer asserst an simulation start.
But on the other side there are very few tests that are failing now:

  • Modelica.Fluid.Examples.BranchingDynamicPipes.mos – simulation_modelica_hpcom Converges to a different solution after initialization, gets to many asserts and crashes with segmentation fault.
  • Modelica.Fluid.Examples.Explanatory.MeasuringTemperature.mos – simulation_libraries_msl32Failing while initialiazing because homotopy is now used and Newton doesn't converge for a nonlinear loop.
  • Modelica.Fluid.Examples.BranchingDynamicPipes - simulation_libraries_msl32 converges to a solution with negative roots but simulates until the end

I'm not sure how to proceed with this. For Modelica.Fluid.Examples.Explanatory.MeasuringTemperature.mos – simulation_libraries_msl32 we could probably fine tune the Newton solver used for homotopy to try again with slightly changed start value or thomething like this. Or the model needs better start values to convergate with Newton.

comment:10 Changed 5 years ago by AnHeuermann

Output for Modelica.Fluid.Examples.BranchingDynamicPipes.mos – simulation_modelica_hpcom

==== Log /tmp/omc-rtest-unknown/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/log-Modelica.Fluid.Examples.BranchingDynamicPipes.mos
900
true
true
""
true
""
true
""
true
""
readCalcTimesFromFile: No valid profiling-file found.
Warning: The costs have been estimated. Maybe Modelica.Fluid.Examples.BranchingDynamicPipes_eqs_prof-file is missing.
Using list Scheduler for the DAE system
Using list Scheduler for the ODE system
Using list Scheduler for the ZeroFunc system
HpcOm is still under construction.
record SimulationResult
resultFile = "",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Modelica.Fluid.Examples.BranchingDynamicPipes', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "Simulation execution failed for model: Modelica.Fluid.Examples.BranchingDynamicPipes
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:8170: Invalid root: (-0.0268723)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:8170: Invalid root: (-0.0141954)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:8170: Invalid root: (-0.00186659)^(1.5)
assert | debug | The arguments x_min and x_max to OneNonLinearEquation.solve(..)
| | | | do not bracket the root of the single non-linear equation:
| | | | x_min = 190
| | | | x_max = 647
| | | | y_zero = -89184
| | | | fa = f(x_min) - y_zero = 1598.31
| | | | fb = f(x_max) - y_zero = 501163
| | | | fa and fb must have opposite sign which is not the case
assert | debug | The arguments x_min and x_max to OneNonLinearEquation.solve(..)
| | | | do not bracket the root of the single non-linear equation:
| | | | x_min = 190
| | | | x_max = 647
| | | | y_zero = -87986.9
| | | | fa = f(x_min) - y_zero = 401.16
| | | | fb = f(x_max) - y_zero = 499966
| | | | fa and fb must have opposite sign which is not the case
assert | debug | The arguments x_min and x_max to OneNonLinearEquation.solve(..)
| | | | do not bracket the root of the single non-linear equation:
| | | | x_min = 190
| | | | x_max = 647
| | | | y_zero = -130302
| | | | fa = f(x_min) - y_zero = 42716.5
| | | | fb = f(x_max) - y_zero = 542281
| | | | fa and fb must have opposite sign which is not the case
assert | debug | The arguments x_min and x_max to OneNonLinearEquation.solve(..)
| | | | do not bracket the root of the single non-linear equation:
| | | | x_min = 190
| | | | x_max = 647
| | | | y_zero = -181833
| | | | fa = f(x_min) - y_zero = 94247.3
| | | | fb = f(x_max) - y_zero = 593812
| | | | fa and fb must have opposite sign which is not the case
assert | debug | The arguments x_min and x_max to OneNonLinearEquation.solve(..)
| | | | do not bracket the root of the single non-linear equation:
| | | | x_min = 190
| | | | x_max = 647
| | | | y_zero = -112829
| | | | fa = f(x_min) - y_zero = 25243.4
| | | | fb = f(x_max) - y_zero = 524808
| | | | fa and fb must have opposite sign which is not the case
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:9306: Invalid root: (-1.08072)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:9306: Invalid root: (-0.339922)^(-1.5)
assert | debug | The arguments x_min and x_max to OneNonLinearEquation.solve(..)
| | | | do not bracket the root of the single non-linear equation:
| | | | x_min = 190
| | | | x_max = 647
| | | | y_zero = -231891
| | | | fa = f(x_min) - y_zero = 144306
| | | | fb = f(x_max) - y_zero = 643870
| | | | fa and fb must have opposite sign which is not the case
assert | debug | The arguments x_min and x_max to OneNonLinearEquation.solve(..)
| | | | do not bracket the root of the single non-linear equation:
| | | | x_min = 190
| | | | x_max = 647
| | | | y_zero = -142403
| | | | fa = f(x_min) - y_zero = 54817.7
| | | | fb = f(x_max) - y_zero = 554382
| | | | fa and fb must have opposite sign which is not the case
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-27.7862)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-18.0024)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-11.594)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-7.39653)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-4.64718)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.84635)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.66681)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.894208)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.388155)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0566904)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0185548)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-5.33431)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-3.43863)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.19696)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.38366)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.850954)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.50203)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.273485)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.123788)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0257368)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-8.51326)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-5.56291)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-3.63043)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.36465)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.53557)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.99252)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.636822)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.403841)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.251238)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.151283)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0858122)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.042929)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0148405)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-8.67546)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-5.6812)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-3.71996)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.43535)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.59392)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.04279)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.681802)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.445353)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.290479)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.189036)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.122591)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0790701)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0505636)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0318918)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0196618)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0116511)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.00640417)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0029674)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.000716315)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-8.68775)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-5.69022)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-3.72683)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.44081)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.59847)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.04674)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.685351)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.448643)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.2936)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.192046)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.125529)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0819598)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0534221)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0347299)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0224865)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0144671)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0092144)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.00577387)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.00352033)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.00204425)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.00107743)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.000444154)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.9361e-05)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
stdout | warning | While solving non-linear system an assertion failed during initialization.
| | | | | The non-linear solver tries to solve the problem that could take some time.
| | | | | It could help to provide better start-values for the iteration variables.
| | | | | For more information simulate with -lv LOG_NLS_V
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.77742)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.13634)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-1.06473)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.48832)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-1.39777)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-0.850637)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.04387)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.52122)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.55701)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.54465)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.003)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-1.56927)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-0.963057)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-1.77136)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-5.77582)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-1.20655)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-0.761815)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.448276)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.38872)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.50009)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-0.679977)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-6.35024)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.65302)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0758794)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.535259)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.04217)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.409494)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.40006)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-2.52902)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-0.623744)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-5.413)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-5.67107)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.5938)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-5.74589)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.81526)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.786135)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-5.32818)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.61418)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-5.07586)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-6.24982)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-6.35069)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-6.29086)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.385)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-0.558309)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.58014)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.46394)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.120257)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.81793)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-4.13567)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.1733)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-3.76335)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-4.44424)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0422364)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0422364)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.56756)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.264759)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0422354)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.278141)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0422354)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:2347: Invalid root: (-0.353161)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0422354)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.57333)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.41626)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-1.47967)^(1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.41626)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.41626)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:16874: Invalid root: (-2.41626)^(-1.5)
assert | debug | Modelica.Fluid.Examples.BranchingDynamicPipes_functions.c:15738: Invalid root: (-0.0617119)^(1.5)
Limited backtrace at point of segmentation fault
/var/lib/jenkins1/ws/OpenModelica_PR-203/build/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(+0x291c3)[0x7f555837b1c3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f5556f56390]
/var/lib/jenkins1/ws/OpenModelica_PR-203/build/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(+0x27b3c)[0x7f5558379b3c]
/var/lib/jenkins1/ws/OpenModelica_PR-203/build/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(alloc_real_array_data+0x16)[0x7f555838455e]
/var/lib/jenkins1/ws/OpenModelica_PR-203/build/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(copy_real_array+0x19)[0x7f5558384622]
/var/lib/jenkins1/ws/OpenModelica_PR-203/testsuite/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/Modelica.Fluid.Examples.BranchingDynamicPipes(omc_Modelica_Fluid_Pipes__omcQuot_44796E616D696350697065247069706533_Medium_saturationPressureLiquid+0x91)[0x530ae1]
/var/lib/jenkins1/ws/OpenModelica_PR-203/testsuite/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/Modelica.Fluid.Examples.BranchingDynamicPipes(omc_Modelica_Fluid_Pipes__omcQuot_44796E616D696350697065247069706533_Medium_saturationPressure+0x5e)[0x5309ae]
/var/lib/jenkins1/ws/OpenModelica_PR-203/testsuite/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/Modelica.Fluid.Examples.BranchingDynamicPipes(omc_Modelica_Fluid_Pipes__omcQuot_44796E616D696350697065247069706533_Medium_h__pTX+0x47)[0x52f9c7]
/var/lib/jenkins1/ws/OpenModelica_PR-203/testsuite/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/Modelica.Fluid.Examples.BranchingDynamicPipes(omc_Modelica_Fluid_Pipes__omcQuot_44796E616D696350697065247069706533_Medium_T__phX_Internal_f__nonlinear+0x45)[0x538235]
/var/lib/jenkins1/ws/OpenModelica_PR-203/testsuite/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/Modelica.Fluid.Examples.BranchingDynamicPipes(omc_Modelica_Fluid_Pipes__omcQuot_44796E616D696350697065247069706533_Medium_T__phX_Internal_solve+0x1ad)[0x5388bd]
/var/lib/jenkins1/ws/OpenModelica_PR-203/testsuite/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/Modelica.Fluid.Examples.BranchingDynamicPipes(Modelica_Fluid_Examples_BranchingDynamicPipes_eqFunction_842+0x6f2)[0x5f05d2]
/var/lib/jenkins1/ws/OpenModelica_PR-203/testsuite/simulation/modelica/hpcom/Modelica.Fluid.Examples.BranchingDynamicPipes.mos_temp4778/Modelica.Fluid.Examples.BranchingDynamicPipes(residualFunc1092+0x37bf)[0x5ffb5f]
/var/lib/jenkins1/ws/OpenModelica_PR-203/build/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(+0x4846a)[0x7f555839a46a]
/var/lib/jenkins1/ws/OpenModelica_PR-203/build/lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(+0x488a2)[0x7f555839a8a2]
/var/lib/jenkins1/ws/OpenModelica_PR-203/build/lib/x86_64-linux-gnu/omc/libcminpack.so.1(hybrj_+0x262)[0x7f5554526704]
Segmentation fault (core dumped)
"
end SimulationResult;
""
{"Error opening file: Modelica.Fluid.Examples.BranchingDynamicPipes_res.mat"}

comment:11 Changed 5 years ago by casella

I'll have a look at the three failing tests next week and propose a solution

comment:12 Changed 5 years ago by casella

Sorry for the delay, I had lost track of this issue.

I tried Modelica.Fluid.Examples.BranchingDynamicPipes in OMEdit, under Windows, using the last nightly build. I ran the test with -homotopyOnFirstTry and -lv=LOG_INIT,LOG_STATS.

The resulting log, see the attached log.txt, contains:

homotopy parameter lambda = 0
<some error messages>
homotopy parameter lambda = 1 done
---------------------------
homotopy parameter lambda = 0.666667
homotopy parameter lambda = 1 done
---------------------------
homotopy parameter lambda = 1
homotopy parameter lambda = 1 done
---------------------------
homotopy parameter lambda = 1 done
---------------------------
homotopy parameter lambda = 0.333333
<some more error messages>
parameter values
### SOLUTION OF THE INITIALIZATION ###
### END INITIALIZATION ###
The initialization finished successfully with 4 homotopy steps.
Warning: maximal number of iteration reached but no root found
### STATISTICS ###
timer
   0.0491135s          reading init.xml
      5.1744s [ 10.8%] simulation
     48.1131s [100.0%] total
   0.0218714s          reading info.xml
   0.0018617s [  0.0%] pre-initialization
     42.8706s [ 89.1%] initialization
   0.0013916s [  0.0%] steps
   0.0326007s [  0.1%] solver (excl. callbacks)
   0.0198511s [  0.0%] creating output-file
   0.0036462s [  0.0%] event-handling
   0.0087598s [  0.0%] overhead
events
solver: dassl
 1538 steps taken
 1969 calls of functionODE
   54 evaluations of jacobian
   12 error test failures
    1 convergence test failures
The simulation finished successfully.
### START INITIALIZATION ###
updating min-values
updating max-values
updating nominal-values
updating primary start-values
initialization method: symbolic        [solves the initialization problem symbolically - default]
Global homotopy with equidistant step size started.
The homotopy path will be exported to Modelica.Fluid.Examples.BranchingDynamicPipes_equidistant_global_homotopy.csv.

This is completely nonsense: initialization starts after it has ended, homotopy starts with lambda = 0, ends with lambda = 1, then goes back again, and eventually ends at lambda = 0.333? What does this mean? I would have expected too see something along the lines of what I proposed in #4220 and was implemented two years ago. Appartently, something went badly wrong.

Can you please double-check? I can try to debug what happens at each homotopy step (e.g. by turning on LOG_NLS_V) if I can understand clearly what is the current value of lambda, which is definitely not the case here.

Also, I expect lambda to take the following sequence of values: 0.0, 0.333, 0.667, 1.0, and to do so only once. As explained in Section 3.7.2.4 of the Specification:

It is recommended to perform (conceptually) one homotopy iteration over the whole model, and not several homotopy iterations over the respective non-linear algebraic equation systems.

In particular, a very common pattern is to have one block whose output has a homotopy transformation, and affects the remainder of the system (e.g., the load level of a power plant model). Having separate homotopy transformations for each block of the BLT would make this pattern useless.

Thanks!

comment:13 follow-up: Changed 5 years ago by AnHeuermann

The output was wrong. Lambda was changed after the assert to some different value. That's the reason why

homotopy parameter lambda = 0.666667
homotopy parameter lambda = 1 done

didn't match. Also Modelica.Fluid.Examples.BranchingDynamicPipes_equidistant_global_homotopy.csv was not generated in a way that OMEdit can open it. I changed both in PR#203.

Regarding the added asserts in test for Modelica.Fluid.Examples.BranchingDynamicPipes: All asserts are triggered in the first two homotopy steps and the final homotopy steps are okay. So I would say we can life with them. Maybe we should suppress these asserts in such cases, as long the homotopy method doesn't have an assert in it's final step.

comment:14 in reply to: ↑ 13 Changed 5 years ago by casella

Replying to AnHeuermann:

The output was wrong. Lambda was changed after the assert to some different value. That's the reason why

homotopy parameter lambda = 0.666667
homotopy parameter lambda = 1 done

didn't match. Also Modelica.Fluid.Examples.BranchingDynamicPipes_equidistant_global_homotopy.csv was not generated in a way that OMEdit can open it. I changed both in PR#203.

Good! I'll try this with the next nightly build once the PR is merged into master.

Regarding the added asserts in test for Modelica.Fluid.Examples.BranchingDynamicPipes: All asserts are triggered in the first two homotopy steps and the final homotopy steps are okay. So I would say we can life with them. Maybe we should suppress these asserts in such cases, as long the homotopy method doesn't have an assert in it's final step.

This is a bit borderline. I re-read section 8.3.7 of the specification, which is subject to interpretation. It says:

level = AssertionLevel.error : The current evaluation is aborted. The simulation may continue with another evaluation [e.g., with a shorter step-size, or by changing the values of iteration variables]. If the simulation is aborted, message indicates the cause of the error.


Failed assertions takes precedence over successful termination, such that if the model first triggers the end of successful analysis by reaching the stop-time or explicitly with terminate() , but the evaluation with terminal()=true triggers an assert, the analysis failed.

In this case, intermediate steps of the homotopy transformation are not valid solutions of the initialization problem anyway, so I think the second statement doesn't hold in this case. If a variable step-size homotopy solver was used, I'd say that an assertion violation should trigger a failure of the current step, causing the solver to retry with a shorter one. If a fixed step-size homotopy is used, I would try with the next step anyway, and if the final solution does not trigger asserts, that would be fine. In this case we may suppress the assert outputs (in fact, we may simply avoid evaluating asserts for intermediate steps).

comment:15 Changed 5 years ago by AnHeuermann

Good! I'll try this with the next nightly build once the PR is merged into master.

The correct log should now be in the nightly builds.

comment:16 Changed 5 years ago by casella

I downloaded yesterday's nightly build and I confirm that I now get a meaningful log regarding the lambda values.

The BranchingDynamicPipes model takes 67 seconds to initialize with fixed step homotopy on my laptop, but eventually succeds, and a transient is produced. I double-checked it against the one computed by Dymola and they look pretty much the same.

I also tried to run the same model in Dymola with Advanced.OnlyUseHomotopyMethod = true (the equivalent of -homotopyOnFirstTry), and indeed I got an initialization failure, with some error messages similar to the ones reported by omc, plus this additional diagnostic message:

Jacobian inverse norm estimate: 1.74013e+012
Condition number estimate: 1.93572e+014
1-norm of the residual = 21864.4
The estimates indicate that the Jacobian is close to singular, suggesting that there is no solution.

I guess this indicates something's wrong in the parametrization of the system, which results in a singular or nearly singular Jacobian at lambda = 0. I'll investigate this further, but I'd say this is a problem with the model, not with the tools.

In general, if homotopy is used in a model, it should be parameterized in a way that the homotopy-based solution is well behaved. Particularly if the model belongs to the MSL.

comment:17 follow-up: Changed 5 years ago by AnHeuermann

Should I merge PR#203 and we accept the failing model for now or do you want to wait until the model is changed inside MSL (if it will be changed)?
Of course I would need to update my PR a little bit and update the other tests as well.

comment:18 in reply to: ↑ 17 Changed 5 years ago by casella

Replying to AnHeuermann:

Should I merge PR#203 and we accept the failing model for now or do you want to wait until the model is changed inside MSL (if it will be changed)?

I think so. We should also open a PR for Modelica 4.0.0 and 3.2.3/maintenance regarding that, do we already have one?

comment:19 Changed 5 years ago by AnHeuermann

I opened a ticket on MSL: https://github.com/modelica/ModelicaStandardLibrary/issues/3140
But I have no good solution to achieve a convergence to the right solution.

comment:20 Changed 5 years ago by casella

I'll take care of that, thanks!

comment:21 follow-up: Changed 5 years ago by AnHeuermann

I added a new flag -noHomotopyOnFirstTry to deal with models which are containing homotopy operators but the user don't wants to initialize with homotopy Method on the first try.
This is used for the Fluid models which have wrong parametrized homotopy functions.

If the PR is merged we will get some regressions, since now the MSL 3.2.2 examples from Fluid don't simulate without -noHomotopyOnFirstTry.

comment:22 in reply to: ↑ 21 ; follow-ups: Changed 5 years ago by casella

Replying to AnHeuermann:

I added a new flag -noHomotopyOnFirstTry to deal with models which are containing homotopy operators but the user don't wants to initialize with homotopy Method on the first try.

I'm not sure I understand this. We already have a -homotopyOnFirstTry flag, so I guess we don't need a new parameter, just -nohomotopyOnFirstTry with the usual rules (and with the small h). Do I miss something?

This is used for the Fluid models which have wrong parametrized homotopy functions.

Do you mean you added a vendor-specific annotation to them?

If the PR is merged we will get some regressions, since now the MSL 3.2.2 examples from Fluid don't simulate without -noHomotopyOnFirstTry.

Maybe I have a better idea: why not re-tring without homotopy if the solution with homotopy failed? That would solve our problem nicely.

comment:23 in reply to: ↑ 22 Changed 5 years ago by anonymous

I'm not sure I understand this. We already have a -homotopyOnFirstTry flag, so I guess we don't need a new parameter, just -nohomotopyOnFirstTry with the usual rules

I came across this comment. May I ask a question? In the documentation I read:

 Flags prefixed with "-" or "no" will be disabled. The available flags are (+ are enabled by default, - are disabled):

So:

  • I would expect either to have nohomotopyOnFirstTry or -homotopyOnFirstTry, -homotopyOnFirstTry seems wrong. Am I right?
  • what is inside brackets in the above-quoted documentation is confusing, since in the list of options after that bracket I don't see any '+' or '-' sign. The defaults, instead, are explicitly indicated on individual flags.

comment:24 Changed 5 years ago by casella

My fault, I messed up between compilation flags and simulation flags. The 'no' prefix applies only to compilation flags.

-homotopyOnFirstTry is a simulation flag (i.e., it is one optional parameter of the simulation executable), so the 'no' prefix does not apply. Andreas thus rightly defined a new parameter -noHomotopyOnFirstTry.

The alternative would be to give -homotopyOnFirstTry a value, so we'd have -homotopytOnFirstTry=true and -homotopyOnFirstTry=false, with the old default being false, and the new proposed one being true. However, this would break the backwards compatibility.

comment:25 in reply to: ↑ 22 Changed 5 years ago by casella

Replying to casella:

Maybe I have a better idea: why not re-tring without homotopy if the solution with homotopy failed? That would solve our problem nicely.

This proposal remains valid, and it applies to the case -noHomotopyOnFirstTry is set.

Last edited 5 years ago by casella (previous) (diff)

comment:26 Changed 4 years ago by casella

  • Milestone changed from 1.14.0 to 1.16.0

Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0

comment:27 Changed 4 years ago by casella

@AnHeuermann, I am testing the 14 bus IEEE system for RTE with the PowerGrids library (soon to be released as open source). With homotopy, the initialization is very fast and converges to the appropriate solution. Without it, the solver finds a completely wrong solution, taking a very long time.

Of course we could include the vendor annotation on all models with -homotopyOnFirstTry but honestly don't think this is the right way to go. If homotopy is provided by the modeller, it should be used. Period.

If by doing so we have regressions on the MSL, because the simplified models were never actually tested with Dymola, that's a problem with the MSL, not with homotopy, and we have a chance to fix them both in MSL 3.2.3 and in MSL 4.0.0.

I would strongly suggest that we follow my former advice and always use homotopy on the first try if there is any homotopy() operator in the model. We can retry without it in case of failure as a backup.

comment:28 Changed 4 years ago by AnHeuermann

Okay, fine for me. I'll implement it and try to merge the PR.

Last edited 4 years ago by AnHeuermann (previous) (diff)

comment:29 Changed 4 years ago by casella

The regression report unfortunately combines four different commits, so I'm not exactly sure what cases are failing because of this commit.

In any case, if the fallback option was implemented, there should be no regression. I guess there is still something to be fixed there.

I'll try to take care about the wrong homotopies in the MSL during the holidays.

comment:30 Changed 4 years ago by casella

See also #5766

comment:31 Changed 4 years ago by casella

  • Resolution set to fixed
  • Status changed from assigned to closed

I checked the regression reports for the MSL models, there were five models affected

  1. Modelica.Electrical.Analog.Examples.OpAmps.Multivibrator
  2. Modelica.Fluid.Examples.BranchingDynamicPipes
  3. Modelica.Fluid.Examples.Explanatory.MeasuringTemperature
  4. Modelica.Fluid.Examples.HeatExchanger.HeatExchangerSimulation
  5. Modelica.Fluid.Examples.PumpingSystem

Models 1., 3., and 5. are fixed by PR #3291 which should eventually be merged in both MSL 3.2.3 maintenance and MSL 4.0.0

Models 2. and 4. are problematic, so I opened #5767 and #5768 to track them individually.

The original issue of this ticket is also solved, so I'm closing this one for good.

Last edited 4 years ago by casella (previous) (diff)
Note: See TracTickets for help on using tickets.