user1768201
user1768201

Reputation: 147

Modelica Model robustness issue: Failed to evaluate model for ODE-Jacobian

I am running a system model in Dymola (modelica based commercial software). Model is about heat and mass transfer from porous substance under forced convection. My problem for asking this question is regarding errors generated during simulation of model.

With the current settings of the model runs successfully for given simulation time (7200 Secs). But it generates following prompts in log file (intermittently throughout the run time):

 ERROR: Failed to solve non-linear system using Newton solver.
To get more information: Turn on Simulation/Setup/Debug/Nonlinear solver diagnostics/Details
Solution to systems of equations not found at time = 882.457
   Nonlinear system of equations number = 4
   Infinity-norm of residue = 154.849
   Iteration is not making good progress.
   Accumulated number of residue calculations: 25279
   Last values of solution vector:
drum.T_e = 306.346
drum.X_e = 0.0413446
   Last values of residual vector:
{ -0.000157014, 154.849 }

I suppose my foremost question is what should I generally understand about my model when I see this. Does this imply a particular fault in way I have defined system of equations or events? This problem becomes apparent when I run robustness study on model by changing some key parameters over a range. Model then fails before end time due to this error, at random combinations of parameter values. As suggested in error message, I did run the model with diagnostic detail checked and it gives large Amat array, with following instructions:

Failed to evaluate model for ODE-Jacobian
Too many slow iterations with no progress
Line search: DX-norm scaled-residua-norm residual (unscaled)
Search direction{ -0.000634251, 6.52346E-006 }
To investigate the properties of the function, you can plot the 
function in the search direction by pasting the following 
commands in the Dymola command window:
  Amat={<...>};
  plotArray(Amat[:,1],Amat[:,2],-1);
If the graph has discontinuities, local minima above zero,
 and/or knees this explains the problem.

As you can see it gives direction to plot Amat (in order to see if discontinuities and local minima are present). Again if I do find these irregularities what should it dictate in terms of changes that I should made to my model(equations)?

I know that provided details may be insufficient to answer, but there is huge log with same repeated failure throughout run time. So if anybody is having some idea about this, please also suggest what relevant detail I may add about my model or simulation so that answering may be easy.

Upvotes: 4

Views: 1232

Answers (1)

Jesse Gohl
Jesse Gohl

Reputation: 188

The error message indicates that the solver was not able to find a solution to a nonlinear system of equations in your model. This could mean either that there is no solution to the system or just that the solver is not able to find it. If there is a solution but the solver can't find it, it could be due to the starting conditions, meaning the starting conditions for the nonlinear solver, not the ODE solver. Obviously for nonlinear systems the solution can be very sensitive to the initial conditions, especially when multiple solutions exist. Sometimes you'll find that by decreasing the solver tolerance (e.g. changing it from 1e-4 to 1e-6) can actually improve the robustness because the numerical solution found by the software will stay closer to the true solution. The other possibility is that there is no solution at that point. This is what Dymola is reporting in your second snippet with the "Amat" array. If you run those commands you might find that there is a local minima that does not cross zero like in the following image.

enter image description here

Where the "x"s represent the points that the solver tried. In this case the solver is trying to find a solution to the equation 0 = f(x) by varying values of x and checking the value of f(x). It is trying to find places where it crosses zero. It's still possible that a crossing could exist between the points that it tried but often it means there isn't a solution.

Now the question becomes what to do about this if it occurs. It could be that the system is approaching a point where no solution exists and so you might be able to guard against this region (like you might guard against a division by zero or square root of a negative number). Obviously this depends on your specific situation. The best option though is to avoid the nonlinear systems entirely. This too will depend on your model and situation. Depending on the libraries used to create your model you can investigate the system structure by generating the flattened Modelica code file (.mof) from the Translation tab of simulation setup. You can then investigate the nonlinear systems that are generated and that might give you some clues as to how to reformulate your model to avoid the nonlinear system all together.

Another thing you can do is to enable more debugging information for the nonlinear system solution from the Debug tab of the simulation setup. Here you can get more details about the solutions found by the solver (e.g. the found solution and the residual values for each step). I'm not sure if it will give you more information than the above graph in your case since no solution is found but in other cases it can be useful.

Upvotes: 3

Related Questions