Menu

#746 Getting "Warning: singular matrix: check node l.x1.l4b#branch"

v1.0 (example)
closed-works-for-me
None
5
2025-03-15
2025-02-25
No

I have a filter circuit I'm playing with, and I'm getting the warning on L4 in the circuit. I've split L4 into two inductors below and I'm getting the error on L4b. If I remove L4b (or all of L4) the warning goes away, but the circuit doesn't work at all like it's supposed to. With the inductor in, it works at least pretty close to what it's supposed to, though it doesn't exactly match the filter design program's output. Not matching the filter design program is not a big surprise, though.

I'm not sure of there's something wrong, but the warning are annoying and make me thing something is wrong.

.title 45MHz differential filter test code



*                      positive input
*                      |   negative input
*                      |   |   positive output
*                      |   |   |    negative output
*                      |   |   |    |
.SUBCKT DiffFilt45MHz inp inm outp outm

C1  inp  inm  1.4n
L1  inp  inm  2.21n

C2a inp  a1   562p
L2a inp  a1   20.5n
C3a a1   a2   604p
L3a a1   a2   22.1n

C2b inm  b1   562p
L2b inm  b1   20.5n
C3b b1   b2   604p
L3b b1   b2   22.1n

C4  a2   b2   2.26n
L4a a2   0    2.74n
L4b b2   0    2.74n
*L4 a2   b2   5.48n

C5a a2   a3   1.62n
L5a a2   a3   7.32n
C6a a3   outp 1.69n
L6a a3   outp 7.68n

C5b b2   b3   1.62n
L5b b2   b3   7.32n
C6b b3   outm 1.69n
L6b b3   outm 7.68n

C7  outp outm 1.19n
L7  outp outm 10.46n

.ENDS

V1 inp inm dc 0 AC 2 sin(0 2 45MEG 0 0 0)

Rbias1 inp 0 100k
Rbias2 inm 0 100k

Rinp inp inp1 50
Rinm inm inm1 50

X1 inp1 inm1 outp outm DiffFilt45MHz

Routp outp 0 50
Routm outm 0 50

.control
*tran 1ns 102000ns 101000ns
*plot v(outp), v(outm)
*plot v(inp1), v(inm1)
ac lin 50000 40000000 50000000
plot db((v(outp)-v(outm))/(v(inp1)-v(inm1)))
.endc

.end

Discussion

  • Corey Minyard

    Corey Minyard - 2025-02-25

    Oh, I forgot to say, this is with both version 44.2 and with the end of the git tree.

     
    • marcel hendrix

      marcel hendrix - 2025-02-25

      [It would be nice to upload a schematic and also state exactly what annoys you.]

      With vsn. 44 I see that ngspice needs the Transient op to find the DC operating point which is indeed rather unexpected, unless there are loops of V,C elements or cutsets of inductors (that's where the schematic comes in).

       
  • Holger Vogt

    Holger Vogt - 2025-02-25

    I do not see any ngspice bug here. This is a circuit made of linear elements only. Thus there is no need for any operating point calculation. Therefore you might run the simulation by the following .control section:

    .control
    tran 1ns 102000ns 101000ns uic
    plot v(outp), v(outm)
    plot v(inp1), v(inm1)
    option NOOPAC
    ac lin 50000 40000000 50000000
    plot db((v(outp)-v(outm))/(v(inp1)-v(inm1)))
    .endc
    
     

    Last edit: Holger Vogt 2025-02-25
  • Corey Minyard

    Corey Minyard - 2025-02-26

    Ok, a schematic is attached.

    The full output is:

    ******
    ** ngspice-44.2 : Circuit level simulation program
    ** Compiled with KLU Direct Linear Solver
    ** The U. C. Berkeley CAD Group
    ** Copyright 1985-1994, Regents of the University of California.
    ** Copyright 2001-2024, The ngspice team.
    ** Please get your ngspice manual from https://ngspice.sourceforge.io/docs.html
    ** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
    ** Creation Date: Mon Feb 24 18:14:52 UTC 2025
    ******
    
    Note: No compatibility mode selected!
    
    
    Circuit: 45MHz differential filter test code
    
    Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
    
    Using SPARSE 1.3 as Direct Linear Solver
    Warning: singular matrix:  check node l.x1.l4#branch
    
    Note: Starting dynamic gmin stepping
    Warning: singular matrix:  check node l.x1.l4#branch
    
    Warning: Dynamic gmin stepping failed
    Note: Starting true gmin stepping
    Warning: singular matrix:  check node l.x1.l4#branch
    
    Warning: singular matrix:  check node l.x1.l4#branch
    
    Warning: singular matrix:  check node l.x1.l4#branch
    
    Warning: singular matrix:  check node l.x1.l4#branch
    
    Warning: True gmin stepping failed
    Note: Starting source stepping
    Warning: source stepping failed
    Note: Transient op started
    Note: Transient op finished successfully
    
    No. of Data Rows : 50000
    

    This is with L4a and L4b commented out and L4 uncommented, but with the other way around, you get the same warnings on L4b.

    I don't know what these things mean, and from what I can tell, there's nothing wrong with the circuit or the spice code. I assume a "singular matrix" is an unconnected node. I have no idea what "True gmin stepping" is. I don't know if these things affect the results of the simulation.

    Although this has no active elements now, it will eventually go into a circuit that does. And why can't you run an operating point analysis on a circuit that has no active elements? Everything has a DC connection to ground, it should be able to compute it.

    It's confusing to get warnings like this; it make me think there is something wrong.

     
  • Corey Minyard

    Corey Minyard - 2025-02-26

    Schematic got lost, actually add it.

     
    • Holger Vogt

      Holger Vogt - 2025-02-26

      Are you aware of that the connection between L5b and L6b is broken?

       
      • Corey Minyard

        Corey Minyard - 2025-02-26

        Oops. I just threw that schematic together so you would have something to look at. It's not used for anything else at the moment. But thanks for the heads up.

         
  • Holger Vogt

    Holger Vogt - 2025-02-26

    You are trying to simulate the operating point of a circuit like this:

    L1 1 0 100u
    L2 1 2 200u
    L3 2 0 300u
    

    This is not possible. Don't know the reason, maybe Marcel can explain.
    It will be possible if you add a small series resistance to each inductor, like

    test operating point of series inductors 
    L1 1 0 100u
    L2 1 2 200u
    L3 2 0 300u
    .option rseries=1m
    .control
    op
    print all
    .endc
    .end
    
     
    • marcel hendrix

      marcel hendrix - 2025-02-27

      Capacitor voltages and inductor currents are the unknowns (to SPICE) to solve for, the former with KVL, the latter with KCL. The circuit under consideration has (at least) two loops of capacitors: C1, C2x, C3x, C4, and C4, C5x, C6x, C7. Furthermore L3a, L4, L5a is one cutset of inductors, L4 with L3b and L5b is another (maybe there are more, the definition of a cutset is not really intuitive). Picking individual voltages or currents and trying to prove that they can not be the operating point is quite difficult.

      If the inductors and capacitors have some loss (combined with an input source and all of its derivatives that are exactly 0) the problem becomes very easy, but that is not what SPICE sees here. The solution it eventually finds is (probably) based on numerical inaccuracies in the solver that can be thought of to be equivalent to circuit losses.

      Looking at the time-domain transient of this circuit might reveal some horrible details caused by its lossless parts. Maybe I will try that later today.

       

      Last edit: marcel hendrix 2025-03-02
  • Holger Vogt

    Holger Vogt - 2025-03-15
    • status: open --> closed-works-for-me
    • assigned_to: Holger Vogt
     

Log in to post a comment.

MongoDB Logo MongoDB