lbl-srg / modelica-buildings

Modelica Buildings library
249 stars 155 forks source link

Problem concerning the singularity of the matrix. #3990

Closed FrancescoPavarelli23 closed 4 days ago

FrancescoPavarelli23 commented 1 week ago

Strucure of the system

Impianto semplice

Components:

Mover (FlowControlled_dp).

The selected head is characterized by a ramp with an offset of 0 for the first 5 seconds, then over 10 seconds, it increases the head to 475 Pa, the value required to achieve the nominal flow rate.

Supply and return manifolds: designed as shown in the image below.

The only difference between the two manifolds is the direction of the water flow.

Collettore

Boundary_pT.

Necessary to provide a pressure reference to the system and avoid further issues. The set pressure is atmospheric, while the temperature remains unchanged.

Problem

The issue is indicated by the following warning message: 'Homotopy solver total pivot: Matrix (nearly) singular at time 5.300000. Continuing anyway. For more information, please use -lv LOG_NLS_V. Under-determined linear system not solvable!', the warning is repeated multiple times for each individual timestep before reaching 5.3. When the mover's head is zero, simulating the shutdown phase of the system, a singular matrix is obtained, which increases computation time and, in the case of more complex systems, can cause the simulation to crash with the following message: 'New front position is not smaller than previous first node. Process crashed.'

What causes the matrix singularity and what approach could be used to simulate the system's shutdown phase?

Thank you very much, have a great day

mwetter commented 1 week ago

I don't see an obvious issue with your model, other than perhaps the use of the temperature sensor. The sensor sets

Modelica.Fluid.Interfaces.FluidPort_a port_a(
    redeclare final package Medium = Medium,
     m_flow(min=if allowFlowReversal then -Modelica.Constants.inf else 0)
...

but at zero head of the mover, the numerical solution to the mass flow can be $\pm \epsilon$ which may cause difficulties for the solver. Try to remove this sensor as I don't see why its output is needed for the ambient boundary condition.

If the problem persists, you may want to report it to the OpenModelica github site as it may be a good relative small test case for robust handling of zero flow. Before doing so please try to remove as much as you can to make the model smaller. In particular the plug flow pipe adds complexity that if you can remove it and still obtain the error would make it easier for the developers to isolate the problem.

FrancescoPavarelli23 commented 1 week ago

Good morning, I tried removing the temperature sensor and replacing the PlugFlowPipe with regular pressure losses. Unfortunately, the issue persists, and as long as the ramp gives a signal of 0 Pascal of pressure head, the matrix continues to be singular. Specifically, this is the last warning message in a long series: Homotopy solver total pivot: 'Matrix (nearly) singular at time 5.001635. Continuing anyway. For more information, please use -lv LOG_NLS_V.'

The new system and collectors are showed in the following images.

System Impianto semplice

Collector Collettore

mwetter commented 4 days ago

I suggest you report this to the OpenModelica github site and also provide a test model that reproduces this issue.