2
votes

In Dymola, I often meet a nonlinear system initialization failure or maybe a stiff system that is hard to solve in the large thermo-fluid system, but for a simple system, there wouldn't be this kind of problem. My questions are:

  1. So I am wondering how much is the largest capability of solving a nonlinear system model? For example, how many nonlinear equations I could include in my model at most?
  2. Is there any setting in Dymola which allows increasing the capability of solving nonlinear system?
  3. How could I decrease the number of nonlinear equations in the model without damage to the accuracy of the model?
2
Especially initialization can be made much more stable by using better start values. Try to build up your model from small to large, simulate each intermediate version to steady state, update your start values.matth
For matth's comment: there is an option to do that automatically after the initialization converged. (Not for Marvel, as it was your own question, but for all others this could be of help): stackoverflow.com/questions/59134138/…Markus A.
@MarkusA, but using "save start values in model" could only save the values after initialization, it doesn't ensure the model has reached a steady state. I know someone tries to do simulation until the model reaches a steady-state, extract the information about which variables are used as start values, and then change the values of these variables. Repeat the steps after adding a new component. but how to do the above steps automatically is a challenge, maybe python is a good option. but I haven't seen an example of it.Jack
@Marvel: You may take the following steps to save results from positive times as start values in the model: 1. Simulate the model. 2. “Continue” -> “Import Initial” -> Select time. 3. “Save in Model” and select “Current Variable Browser content”.Erik
@Marvel: Note, however, that if the model has initial equations, these will override any saved start values. This may be a problem when start values have been saved from a time after initialization. There is also the alternative to generate a script with the final values of a simulation.Erik

2 Answers

7
votes

These are pretty difficult questions to be answered in a generally valid fashion. Still I'll try to share some of my experience with Dymola and non-linear systems.

  1. There is no hard number which will limit the size. It depends more on how strongly non-linear the equations are than on their number. I have simulated models with non-linear systems of size 150, which are pretty stable while others of size 10 can brake...

  2. There are multiple perspectives to this

    • I have worked on some models that made the C-Compiler run out of memory during compilation. If you have this sort of problem, forcing 64Bit compilation by setting Advanced.CompileWith64=2 can help. Then you shouldn't run out of memory any more. This only refers to the size only.
    • Performance for non-linear systems can be improved by activating DAE-mode by setting Advanced.Define.DAEsolver=true. This does not work with all solvers though.
    • Additionally to the above it can help to set Advanced.MoveEquationsToDynamics=true, for which the manual states: "It forces the integrator to solve the nonlinear equations each integrator step and thereby it also updates the initial guesses more often."
    • As mentioned by Erik, the homotopy()-operator can be very important as it helps the solver converging in case of difficult initialization.
  3. This is very specific to the model. Decoupling can help, e.g. by splitting the system in smaller systems by adding energy storing elements/states. This can be done based on physics of the system and is the preferable solution if possible. As an (more artificial) alternative filter/delays can be added. Usually this has a negative effect on accuracy.

5
votes

I very much agree with Markus's advice but would also like to remind you about Modelica's homotopy operator. A well-chosen simplified model can greatly help Dymola to initialize a model with a large and difficult non-linear system.

In general good initial guesses are very important when solving non-linear systems. Using homotopy is simply an implicit way to provide these good guesses.