1

This is my netlist

 .title KiCad schematic
 V1 Net-_R1-Pad1_ 0 5V
 R1 Net-_R1-Pad1_ Net-_R1-Pad2_ 100k
 X1 0 Net-_R1-Pad2_ LM385BZ-1.2



.SUBCKT LM385BZ-1.2 A K
*
* TWO-TERMINAL VOLTAGE REFERENCE
*
DFWD A K DF
GREV A K VALUE={LIMIT(20.00E-3*(EXP(V(A,K)/5.682E3)-1),-10M,0)}
RZ A 1 .102
GZ 2 1 VALUE={LIMIT(EXP(V(2,1)/198.0E-6),0,20.00E-3)}
EBV K 2 3 0 1
RBV 3 0 1.237E3 TC=1.139E-6 -346.8E-9
IBV 0 3 DC 1M 
*
.MODEL DF D(IS=39.12E-15 RS=12.18 IKF=0 N=.9983 XTI=3)
.ENDS LM385BZ-1.2


.OP
.END

Ltspice simulates this netlist very well. but when i launch ngspice -b it shows this strange results.

    Node                                  Voltage
    ----                                  -------
    ----    -------
    x1.3                             1.237000e+00
    x1.gz_int1                       0.000000e+00
    x1.2                             2.003763e+03  
    x1.1                             0.000000e+00
    x1.grev_int1                     2.000000e-02
    net-_r1-pad2_                    2.005000e+03
    net-_r1-pad1_                    5.000000e+00

1 Answers1

1

The LIMIT() is not defined in NGspice.
According to the NGspice manual:

16.13.2 Missing functions
You may add one or more function definitions to your input file, as listed below.

     .func LIMIT(x,a,b) {min(max(x, a), b)}
     .func PWR(x,a) {abs(x) ** a}
     .func PWRS(x,a) {sgn(x) * PWR(x,a)}
     .func stp(x) {u(x)}
Huisman
  • 10,694
  • 2
  • 20
  • 40
  • Isn't there a command to add so that I can run LTspice netlists in ngspice? I have a python script that automatically generates LTspice netlist and runs them; and since not all my friends are on Windows (most on Linux) I would like to share my script with them. Any workarounds? – Wallflower Feb 22 '21 at 19:36