Re: RuntimeError: Factor is exactly singular

49 views
Skip to first unread message

Jeffrey S. Oishi

unread,
Oct 15, 2025, 2:07:23 PMOct 15
to dedalu...@googlegroups.com
Hi Guangyuan,

I'm afraid your code is either a deliberately quite non-standard use of Dedalus, in which case I don't think anyone can help you, or you might not understand what Dedalus does and should go back and read our documentation and examples more clearly. Typically, we don't solve separate IVPs for each variable. Dedalus provides time stepping algorithms so you can simply implement the equations as-is, fully coupled in all variables in one IVP object, with linear terms for implicit time stepping on the left and non-linear terms for explicit time stepping on the right. The included timesteppers will do the time discretization for you, just as the spectral bases discretize space for you. 

Jeff

On Tue, Oct 14, 2025 at 11:32 PM Guangyuan Wei <weiguan...@gmail.com> wrote:

Dear Developer,

I would like to solve the NSK equations in the domain [0,1]×[0,1] , with periodic boundary conditions applied in both x and y directions. The equations are as follows:

图片1.png

I will employ a segregated approach to solve for the variables of this system, and a simple discretization scheme is shown below:

图片2.png

In Problem 4, the second equation employs the following assumption:

图片3.png

I encountered a singular matrix issue while writing the code, which occurs in Problem 4. The hint for this issue is as follows:

******************************************************************************

Traceback (most recent call last):

  File "/home/weiguangyuan/dedalus/mydedalus/fenbuqiujie1/biannianduzuizhong.py", line 111, in <module>

    solverMom1.step(timestep)

  File "/home/weiguangyuan/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/solvers.py", line 654, in step

    self.timestepper.step(dt, wall_time)

  File "/home/weiguangyuan/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/timesteppers.py", line 627, in step

    sp.LHS_solvers[i] = solver.matsolver(sp.LHS, solver)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/weiguangyuan/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/libraries/matsolvers.py", line 141, in __init__

    self.LU = spla.splu(matrix.tocsc(),

              ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/weiguangyuan/anaconda3/envs/dedalus3/lib/python3.12/site-packages/scipy/sparse/linalg/_dsolve/linsolve.py", line 438, in splu

    return _superlu.gstrf(N, A.nnz, A.data, indices, indptr,

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

RuntimeError: Factor is exactly singular

******************************************************************************

The problematic code is as follows:

******************************************************************************

#Problem

problemMas = d3.IVP([rho], namespace=locals())

problemMas.add_equation("dt(rho) -alpha1*lap(rho) = -div(rho*u) -alpha1*lap(rho)")

 

problemMasc = d3.IVP([c], namespace=locals())

problemMasc.add_equation("dt(c) - B*lap(c) +C*c = -div(c*u) +C*rho")

 

problemP = d3.IVP([p], namespace=locals())

problemP.add_equation("p = (8/27)*(rho*T/(1-rho))-rho**2")

 

problemMom1 = d3.IVP([u,p], namespace=locals())

problemMom1.add_equation("dt(u) +(1/rho0)*grad(p) =(1/rho0 - 1/rho)*grad(p) + (1/(Re*rho))*grad(miu)@tau + (4*miu/(3*Re*rho))*grad(div(u)) -(miu/(Re*rho))*(-skew(grad(w))) -u@grad(u) + A*(grad(c)-grad(rho))")

problemMom1.add_equation("div(u) = (1/rho)*(rhoold*div(u)+u@grad(rhoold)-u@grad(rho))")

 

problemMom2 = d3.IVP([u], namespace=locals())

problemMom2.add_equation("dt(u) - alpha2*lap(u) = -alpha2*grad(div(u))+alpha2*(-skew(grad(w)))")

******************************************************************************

I have attached the complete code in the attachment. I would greatly appreciate it if you could help me resolve this issue.

 

Best wishes,

Guangyuan

--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dedalus-users/7f048403-1f52-4fd4-88c9-8ef70ce3ffdan%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages