Program crashes when simulating subcircuit

I was trying to simulate the following model provided by infineon:

https://www.infineon.com/cms/en/product/power/mosfet/12v-800v-small-signal-mosfet/bsd214sn/#!simulation

I select the model and the symbol that matches the subcircuit (drain in pin1 gate in pin 2 and source in pin 3)

.SUBCKT BSD214SN_L1 drain gate source PARAMS: dVth=0 dRdson=0 dgfs=0 dC=0 Ls=1n Ld=0.5n Lg=1n

.PARAM Rs=16.37m    Rg=11.3      Rd=240u      Rm=600u
.PARAM Inn=1.5      Unn=4.5      Rmax=140m    gmin=2.1
.PARAM act=0.122

X1  d1 g s Tj S3_20_s_var PARAMS: a={act} dVth={dVth} dR={dRdson} dgfs={dgfs} Inn={Inn} Unn={Unn} 
                                        +Rmax={Rmax} gmin={gmin} Rs={Rs} Rp={Rd} dC={dC} Rm={Rm}
Rg    g1     g    {Rg}   
Lg    gate   g1   {Lg*if(dgfs==99,0,1)}
Gs    s1     s    VALUE={V(s1,s)/(Rs*(1+(limit(V(Tj),-200,999)-25)*4m)-Rm)}
Rsa   s1     s    1Meg
Ls    source s1   {Ls*if(dgfs==99,0,1)}
Rda   d1     d2   {Rd}
Ld    drain  d2   {Ld*if(dgfs==99,0,1)}

E1    Tj     w      VALUE={TEMP}
R1    w      0      1u

.ENDS

When I try to simulate, the program simply crashes, no errors no reports… What is the strategy to simulate a NMOS? I would really like to use the model provided by the namufacturer.

What is the operating system, and the KiCad and ngspice versions you are using?

Please have a look at http://ngspice.sourceforge.net/ngspice-eeschema.html

To simulate this model, you will need the upgrade to ngspice-30 and to follow the procedures as described in the tutorial.

kicad version: 5.1.2 release build
Platform: Linux 5.1.14-arch1-1-ARCH x86_64 64 bit

I’ve checked that the ngspice version is 30. I’ll check the tutorial, but that the whole program crashes is a quite exaggerated response to a miss use of a model (In case I did something wrong, I haven’t check the tutorial yet)

Please post the ngspice netlist. And attach your eeschema *.sch file here.

The model BSD214SN_L1 is not supported by the eeschema/ngspice interface. Currently it is not possible to transfer parameters into a subcircuit. See bug report https://bugs.launchpad.net/kicad/+bug/1829618

For now use BSD214SN_L0 instead.

You may support the bug report by stating that this bug effects you as well.

Edit: This is probably not correct. BSD214SN_L1 is running well in discrete ngspice-30. So please attach your *.sch file here to allow me to check your case in detail.

Interesting. I’ve reported that I’m also affected.

I’ve also attached the project in the bug report:

I’ve tried with the BSD214SN_L0 model as well. Now it doesn’t crash, but the simulation fails:

Circuit: KiCad schematic
Background thread stopped with timeout = 0
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Initial Transient Solution
--------------------------
Node                                   Voltage
----                                   -------
net-_q1-pad2_                              3.3
xq1.g1                                     3.3
net-_q1-pad1_                               12
xq1.d1                                      12
net-_q1-pad3_                          1.86696
xq1.s1                                 1.86696
xq1.s2                                 1.86726
xq1.g2                                 3.30001
xq1.d2                                 11.9987
xq1.21                                      12
xq1.c                                  11.9987
xq1.a                                  3.30001
xq1.b                                  11.9987
xq1.d                                 -5.39871
l.xq1.ls#branch                     -0.0186696
l.xq1.ld#branch                      0.0186704
l.xq1.lg#branch                   -8.69889e-07
e.xq1.eaux2#branch                           0
e.xq1.eaux#branch                  5.68434e-14
v2#branch                          8.69889e-07
v1#branch                           -0.0186704
 Reference value :  0.00000e+00
doAnalyses: TRAN:  Timestep too small; time = 1e-19, timestep = 1.25e-20: trouble with xq1:dbt-instance d.xq1.dbd
run simulation(s) aborted

I’ve read from your reference that I need to switch the PSPICE model compatibility switch:
http://ngspice.sourceforge.net/ngspice-eeschema.html

I’ve created both .spiceinit and spice.rc and set that flag. Is there a way that check that ngspice is picking that correctly?

This is a model problem or ngspice problem, or both.

However BSD214SN_L1 is working well! No crash.

Yes, with L1 is not crashing, thank you for that! But it doesn’t converge, is it working for you? Are you able to simulate something? No matter what I try it just doesn’t converge to anything, it always ends the simulation with:

doAnalyses: TRAN:  Timestep too small; time = 1e-19, timestep = 1.25e-20: trouble with xq1:dbt-instance d.xq1.dbd
run simulation(s) aborted

There was a bug in ngspice, preventing convergence in special cases. A fix has been uploaded to the ngspice development branch pre-master. It will become effective in the next release (ngspice-31). A release date has not yet been fixed.

Do you think that bug applies to this case? Is the only option to wait until they release the new version? Thanks for the information @holger

Concerning ngspice, it’s not “they”, it’s me. But still no schedule. When ngspice-31 was available, it would be tested by the KiCad devs, and finally appear in KiCad 6.

Of course, as always, as you are on Linux, you may download the ngspice pre-master sources from https://sourceforge.net/p/ngspice/ngspice/ci/pre-master/tree/ (snapshot button on the top right), expand the tar.gz file and compile ngspice yourself. A short how-to is in file INSTALL, sections 1.1 and 1.2 or in the ngspice manual, chapt. 32.1.1 and 32.1.3.

Ngspice-31 is available as of Sept. 22, 2019.

See https://sourceforge.net/projects/ngspice/

2 Likes

Could @holger summarize what are the key benefits of v31 for KiCad Ngspice users?

Several bug fixes (like this one here).
Improved PSPICE device model compatibility.
VBIC bipolar model updated, it allows thermal simulation.

Other enhancements are not easily visible to KiCad users due to the limitations of the Eeschema-ngspice interface.

3 Likes