Menu

#46 Convergence issues (gmin stepping failed)

v1.0 (example)
open
nobody
5
2019-10-24
2019-10-21
Christoph
No

Hey Guys,

i have some convergence issues with my circuit (gmin.cir). I´m loading a varistor from the library.
https://www.tdk-electronics.tdk.com/download/385720/cefe5507ca0c95c968a140b701d54c17/siov.zip

In my userfolder: C:\Users\"Name" i created the file "spice.rc"
+++++++++++++++++++++++++++++++++++++
spice.rc:

  • user provided init file
    set ngbehavior=ps
    set filetype=binary

+++++++++++++++++++++++++++++++++++++
ngspice report:


ngspice-31 : Circuit level simulation program
The U. C. Berkeley CAD Group
Copyright 1985-1994, Regents of the University of California.
Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
Creation Date: Oct 6 2019 15:17:58


ngspice 1 -> source gmin.cir

Circuit: gmin schematic

ngspice 2 -> run
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

Note: Starting dynamic gmin stepping
Trying gmin = 1.0000E-03 Warning: Further gmin increment
Trying gmin = 5.6234E-03 Warning: Further gmin increment
Trying gmin = 8.6596E-03 Warning: Further gmin increment
Trying gmin = 9.6466E-03 Warning: Further gmin increment
Trying gmin = 9.9105E-03 Warning: Further gmin increment
Trying gmin = 9.9775E-03 Warning: Further gmin increment
Trying gmin = 9.9944E-03 Warning: Further gmin increment
Trying gmin = 9.9986E-03 Warning: Further gmin increment
Trying gmin = 9.9996E-03 Warning: Last gmin step failed
Warning: Dynamic gmin stepping failed
Note: Starting source stepping
Supplies reduced to 0.0000%
Trying gmin = 1.0000E-02 Warning: gmin step failed
Warning: source stepping failed

Transient solution failed -

Last Node Voltages

Node Last Voltage Previous Iter
---- ------------ -------------
in 0 0
out -594.637 594.637
xrvar.x1.3 -594.639 594.639

xrvar.x1.4 -594.401 594.401
xrvar.x1.5 -600.345 600.345

xrvar.x1.6 233168 -233168
xrvar.x1.e_var_int1 -606.348 606.348

xrvar.x1.7 100.99 100.99
xrvar.x1.e_sw_int1 102 102
b.xrvar.x1.be_sw#branch 0 0
b.xrvar.x1.be_var#branch 0 0
h.xrvar.x1.h_i_sense#branch -0.00023086 0.00023086
v.xrvar.x1.v_i_sense#branch 23.55 -23.55

l.xrvar.x1.l_series#branch 23.7855 -23.7855
e.xrvar.x1.e_sw#branch -9.99902e-08 -9.99902e-08
e.xrvar.x1.e_var#branch 23.3168 -23.3168

v0#branch -5.8875 5.8875 *

doAnalyses: Too many iterations without convergence

run simulation(s) aborted
ngspice 3 ->
Interrupted once . . .
Warning: clearing control structures
ngspice 3 ->
Interrupted again (ouch)
Warning: clearing control structures
ngspice 3 ->

++++++++++++++++++++++++++++++++++

When im testing the circuit in ltspice it is working (ltspice_varistor.PNG)

1 Attachments

Discussion

  • Christoph

    Christoph - 2019-10-21

    fortgot the .cir

     

    Last edit: Christoph 2019-10-21
  • Christoph

    Christoph - 2019-10-21

    ngspice version:
    ngspice-31 : Circuit level simulation program
    Creation Date: Oct 6 2019 15:17:58

     
  • Christoph

    Christoph - 2019-10-21

    Maybe one of you can help me out. Thank you.

     
    • marcel hendrix

      marcel hendrix - 2019-10-21

      We also need siov.lib .

      -marcel

       
      • marcel hendrix

        marcel hendrix - 2019-10-21

        Hmm... a classical NR problem: pretty persistent oscillation between two extremes (look at the node voltages now and previous).

        -marcel

         
        • marcel hendrix

          marcel hendrix - 2019-10-24

          Wait a minute, this is not a varistor -- it limits no matter the device terminal voltage amplitude ... Where did I make a mistake in this translation?

          Congratulations to LTspice -- it can simulate this strangeness (but for two missing braces on the subcircuit call line).

          -marcel

          .title gmin schematic
          
          .func LIMIT(x, y, z) {min(max(x, min(y, z)), max(z, y))}
          
          V0 In  0  dc=1 pulse(-0.01k 0.01k 10n 100n 100n 300n 600n)
          R2 Out In  100
          R1 Out 0   100
          XRvar  Out 0   S14K300
          
          .save @v0[i] @r2[i] @r1[i] V(In) V(Out)
          .tran 1ns 800ns 0 1ns
          
          .subckt siov 1 2   t=1 c=1pf l=1nh b1=1 b2=1 b3=0 b4=0
          r_series  1 3 100u
          l_series  3 4 {l}
          v_i_sense 4 5 0v
          h_i_sense 6 0 v_i_sense 10k
          r_i_sense 6 0 1g
          e_var     5 2 value={t*(    
           +             pwr(10, b1+b2*(log10( limit(v(6), 1m, 100g))-4) +
           +             b3*exp(-log10( limit(v(6), 1m, 100g)) + 4)  +
           +             b4*exp( log10( limit(v(6), 1m, 100g)) - 4)) -
           +             pwr(10, b1+b2*(log10(-limit(v(6),-100g,-1m))-4) +
           +             b3*exp(-log10(-limit(v(6),-100g,-1m)) + 4)  +
           +             b4*exp( log10(-limit(v(6),-100g,-1m)) - 4)) +
           +             limit((v(6)*1k*v(7)),-v(7),v(7)) )}
          
          c_par  4   2  {c}
          e_sw   7   0  value={pwr(10,(b1+b2*(-7)+b3*exp(+7)+b4*exp(-7)))}
          r_sw   7   0  1g
          r_sw2  5   2  1MEG
          .ends SIOV
          
          .subckt s14k300 1 2 tol=0
          x1 1 2 siov  t={1+tol/100} c=300pf l=12.0nh b1=2.7733130 b2=0.0306573 b3=-0.0004977 b4=0.0042636
          .ends S14K300
          
          * .control
          *   listing e
          *   run
          *   write gmin.raw
          *   plot V(out) @R1[i]
          *   quit
          * .endc
          
          .end
          
           

          Last edit: marcel hendrix 2019-10-24
          • Holger Vogt

            Holger Vogt - 2019-10-24

            The following is an input file made of the circuit after parsing it with the ngspice inpcom parser (only slight modified to get the subcircuit calls right), as delivered by debug-out1.txt:

            gmin schematic
            * translated by ngspice inpcom parser, slightly modified
            * o.k. with LTSPICE
            .include "D:\Software\Spice\various\SIOV.LIB"
            .param gmin=1e-12
            .global gnd
            .subckt siov 1 2 params: t=1 c=1pf l=1nh b1=1 b2=1 b3=0 b4=0
            r_series 1 3 100u
            l_series 3 4 {l}
            v_i_sense 4 5 0v
            h_i_sense 6 0 v_i_sense 10k
            r_i_sense 6 0 1g
            e_var 5 2 e_var_int1 0 1
            be_var e_var_int1 0 v= ({t}) * ( ( abs (   1.0000000000e+01 ) ** ( ({b1}) + ({b2}) * ( log10 ( ( min ( max ( ( v(6) ) ,   1.0000000000e-03 ) ,   1.0000000000e+11 ) ) )  -4.0000000000e+00 ) + ({b3}) * exp ( - log10 ( ( min ( max ( ( v(6) ) ,   1.0000000000e-03 ) ,   1.0000000000e+11 ) ) ) +   4.0000000000e+00 ) + ({b4}) * exp ( log10 ( ( min ( max ( ( v(6) ) ,   1.0000000000e-03 ) ,   1.0000000000e+11 ) ) )  -4.0000000000e+00 ) ) ) - ( abs (   1.0000000000e+01 ) ** ( ({b1}) + ({b2}) * ( log10 ( - ( min ( max ( ( v(6) ) , (  -1.0000000000e+11 ) ) , (  -1.0000000000e-03 ) ) ) )  -4.0000000000e+00 ) + ({b3}) * exp ( - log10 ( - ( min ( max ( ( v(6) ) , (  -1.0000000000e+11 ) ) , (  -1.0000000000e-03 ) ) ) ) +   4.0000000000e+00 ) + ({b4}) * exp ( log10 ( - ( min ( max ( ( v(6) ) , (  -1.0000000000e+11 ) ) , (  -1.0000000000e-03 ) ) ) )  -4.0000000000e+00 ) ) ) + ( min ( max ( ( ( v(6) *   1.0000000000e+03 * v(7) ) ) , ( - v(7) ) ) , ( v(7) ) ) ) )
            c_par 4 2 {c}
            e_sw 7 0 e_sw_int1 0 1
            be_sw e_sw_int1 0 v= ( abs (   1.0000000000e+01 ) ** ( ( ({b1}) + ({b2}) * (  -7.0000000000e+00 ) + ({b3}) * exp ( +   7.0000000000e+00 ) + ({b4}) * exp (  -7.0000000000e+00 ) ) ) )
            r_sw 7 0 1g
            .ends
            .subckt s14k300 1 2 params: tol=0
            * .SUBCKT SIOV 1 2 PARAMS: T=1 C=1pF L=1nH B1=1 B2=1 B3=0 B4=0
            x1 1 2 siov T={1+tol/100} C=300pf L=12.0nh B1=2.7733130 B2=0.0306573 B3={-0.0004977} B4=0.0042636
            .ends
            v0 in 0 dc 1 ac 0 pulse(0 2k 10n 100n 100n 300n)
            r2 out in 100
            r1 out 0 100
            xrvar out 0 s14k300 tol=0
            .save @v0[i]
            .save @r2[i]
            .save @r1[i]
            .save v(in)
            .save v(out)
            .tran 1ns 1000ns
            .end
            

            Same result as with the original file, LTSPICE o.k., ngspice not.

            We have to spend some time looking at the op calculation.

             
            • Holger Vogt

              Holger Vogt - 2019-10-24

              And we should re-check if the derivatives of the pwr (**) function are o.k.

               
  • Francesco Lannutti

    Hi all,
    if a varistor is a variable resistance, I think we are suffering from non-linearity issue here...
    You need to smooth more the variations of that resistance, IMHO.

    Thank you,
    Fra

     
  • marcel hendrix

    marcel hendrix - 2019-10-24

    The following is an input file made of the circuit after parsing it with the
    ngspice inpcom parser (only slight modified to get the subcircuit calls right),
    as delivered by debug-out1.txt:

    Feeding this preparsed NGSPICE cir file to LTspice is possible, and LTspice
    converges (maybe Holger did this already, I am not sure). Therefore the
    observed differences are indeed in NGSPICE's simulation engine.

    However, in LTspice when I use the following slightly modified V0 source:

    v0 in  0   dc 1 ac 0 pulse(-700 2k 10n 100n 100n 300n 800n)
    

    ... LTspice also crashes.

    BTW, again the output is in no way resembling a varistor (e.g. the
    clipping boundaries are asymmetric).

    -marcel

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.