I've found a TRIAC model on the net (attached below), which I'm using in a
flyback converter simulation. This works as expected in LTSpice, running at
about 4.5s per ms.
The model doesn't work directly in ngspice, since B1 requires the current
through the diode connected between pins 1 and 2:
D1 1 2 DL
B1 ctrl1 4 I=500*I(D1)*3m/Itrig
To handle this, I've changed the D1 and B1 cards, and added a zerovalued
voltage source:
D1 1 2X DL
Vdummy 2X 2 DC 0Volts
B1 ctrl1 4 I=500*I(Vdummy)*3m/Itrig
The ngspice sim gives up after a few minutes, before it reaches 0.4ms, and
reports:
doAnalyses: TRAN: Timestep too small; time = 0.000477091, timestep =
6.25e20: trouble with node "e.xu2.e1#branch"
The opto TRIAC component is 'e.xu2'. I'm running with a .tran 50e9 20e3.
Am I doing something dumb?
Thanks.

* OPTO TRIAC
* Helmut Sennewald 8/10/2004
* MOC3022 I_trig=5mA
* D+ D MT2 MT1
.SUBCKT MOC3022 1 2 3 4
.PARAM Itrig=5m
.PARAM RH1=20k
.PARAM RH2=20k
.PARAM RH3=16.7k
Q2 vb1 vb1p vd1 0 PNP1
Q1 vb1p vb1 4 0 NPN1
R3 vb1 4 {RH2}
D1 1 2 DL
R1 ctrl1 4 1
C1 ctrl1 4 10µ
R2 ctrl1 vb1 {RH1}
R4 vd1 vb1p {RH3}
B1 ctrl1 4 I=500*I(D1)*3m/Itrig
R6 vd2 vb2 {RH2}
D3 vd2 3 D1
Q3 vb2 vb2p 4 0 PNP1
Q4 vb2p vb2 vd2 0 NPN1
E1 vd2 N001 ctrl1 4 1
R5 N001 vb2 {RH1}
R7 vb2p 4 {RH3}
D2 3 vd1 D1
R34 3 4 100MEG
.MODEL PNP1 PNP(Is=1e15 BF=10 Cjc=10p Cje=20p Tf=0.1u Ise=1e12)
.MODEL NPN1 NPN(Is=1e15 BF=10 Cjc=10p Cje=20p Tf=0.1u Ise=1e12)
.MODEL D1 D(Is=0.1u Rs=2 Cj0=50p)
.MODEL DL D(Is=1e20 Rs=5)
.ENDS
