Jack
Jack

Reputation: 1232

debug the structurally singular and minimize nonlinearity of Modelica models

I build a Modelica model, but when checking the model (Here is the model download link), it shows a local singularity like in the following screenshot. enter image description here

so I delete the code showed in the error message.

h[3]=(hout+hl)/2

but although the model checks fine, there is a strong nonlinearity issue which causes the initialization failure.

enter image description here enter image description here

So I try to delete the following code line:

h[1]=(hin+hv)/2

and the model not only checks but also there is no initialization issue.

enter image description here

My questions are:

  1. When debugging the model singularity, the error message showed by Dymola might be not the singularity source of the model? Is there a general method to find the source of the singularity problem? Or I have to analyze the equations in the model manually?
  2. How to minimize the nonlinearity of the Modelica model and ensure convergence? I found this problem exists in many fields, especially in the thermo-hydraulic models, I found that one way to deal with this problem is the way used in Thermao Power Library from Modelon and ThermoSysPro for EDF, these two libraries divide the models or connector into two types: flow and volume. To ensure convergence, it requires to use a staggered grid scheme like in the following screenshot.

    So is there another method to deal with the nonlinearity problem in thermo-hydraulic models? is there a common view on how to deal with the nonlinearity problem in thermo-hydraulic models?

enter image description here

Upvotes: 11

Views: 595

Answers (1)

CSchulzeTLK
CSchulzeTLK

Reputation: 101

  1. The error messages clearly state that the equation system "simulation.nonlinear[1]" could not be solved. This is a nonlinear algebraic equation system solved during the computation of the ODE RHS. Another variable calculated earlier in the computational causality might be wrong, but this is the first part of the equation system which could not be solved.

    You can activate "Simulation Setup/Translation/Model translation/Generate listing of translated Modelica code in dsmodel.mof" to get the translated model. In the dsmodel.mof file you can find a description of the equation system "simulation.nonlinear[1]".

    If "Simulation Setup/Debug/Nonlinear solver diagnostics/Details" is activated, you should get a simulation log message "...plotArray(Amat[:,1],Amat[:,2],-1);...". If you copy/paste this to the Dymola command window, you will get a plot of the residual. You should see that the residual function does not reach zero.

    Either this is a structural modeling error which is not detected by the compiler, or the model cannot be solved for the given boundary conditions.

    You should analyze the "simulation.nonlinear[1]" in the dsmodel.mof and try to get rid of the nonlinear equation system by changing the equations. Often idealized physical dependencies lead to algebraic equation systems. If you cannot do that, you must make sure that it is always possible to solve it.

  2. You can model describe systems with capacities, resistors, and inductors (e.g. Bond Graph Modelling, see "Continuous System Modelling" by Cellier). This is what you described above as "flow" (i.e. resistor) and "volume" (i.e. capacity). There should be no nonlinear equation systems due to the composition of these base components if you stick to the design rules.

    You can also describe the system using linear graph modeling. I.e. using through- and across-variables. You might have to clarify how to extend these approaches using the stream connector concept of Modelica. However, the Modelica community usually implements the first approach, and Dymola provides proper debugging features based on the first approach.

    It is a design choice how you implement your approach in Modelica component models and connectors. Using a/b connectors you will be able to enforce certain usage patterns.

Upvotes: 1

Related Questions