Installing and using ngspice - an opensource simulator

Member
Joined 2011
Paid Member
ngspice - an opensource circuit simulator - should have it's thread to discuss some basics from installing to simulate a complete amplifier.

Attached a picture with ngspice version 30 in action.

This first post will be updated from time to time.

BTW: ngspice V30 manual (v30 has been released 01.01.2019) contains Dave Zan's IXTH48P20P model as a VDMOS example - p146. :up:


BR, Toni
 

Attachments

  • Screenshot_20181225_230246.png
    Screenshot_20181225_230246.png
    265.7 KB · Views: 1,327
Last edited:
I am not familiar with ngspice. Has anyone here used it? How does it compare to LTspice? To what extent can its manual apply to some functions in LTspice? Does it have a VDMOS-like power MOSFET model that has a good approximation to modeling MOSFET capacitances?

How does it handle sub-threshold modeling of power MOSFETs, like KSUBTHRES in LTspice? I know, lot's of questions. Inquiring minds :).

Cheers and Merry Christmas,
Bob
 
Member
Joined 2011
Paid Member
Dear Bob,

LTSpice is a wonderful tool for us DIYers but

  • it doesn't run native under Linux (my preferred OS),
  • hasn't a powerful scripting language to automate different simulations and
  • isn't open source.
With the newest release ngspice supports VDMOS with KSUBTHRES as well as BJT model level 4 (=advanced VBIC model). The gEDA tool "gschem" (my preferred tool to draw my schematics and my pcbs using gEDA's "pcb") supports netlist output which is compatible with ngspice so I have started to experiment with it.

Have found this link with some examples about open loop simulation where Middlebrook and Tian is discussed. The example shows also the powerful integrated scripting language in action.
Maybe we should open a thread discussing ngspice.

BR, Toni
 
Last edited:
Some input from people who have used it would be good. I'd like to hear about the drawbacks, not just the advantages compared to LTspice.

LTspice does run on Linux via WINE, which is how I've used it for probably over 10 years. But native support would be nice.

BTW, pcb-rnd is a fork of pcb which is more capable more actively developed. pcb has stagnated.
 
Last edited:
Member
Joined 2011
Paid Member
Attached a test result using ngspice 29plus from 23.12.2018.
Have tried to simulate my IXYS based amplifier where Dave Zan has designed the power mosfet models incl. ksubthres.

Was a bit work to replace the schematic components to spice compatible ones but the simulation runs. The scripting language let me do a DC, TRAN and AC (and hopefully later a loop gain checks using multiple tian probes) analysis in one automatic step including the plot output (the output can go directly to postscript too instead of screen).


...
BTW, pcb-rnd is a fork of pcb which is more capable more actively developed. pcb has stagnated.
Thx for bringing the pcb-fork into my mind. Have to test it!


Have fun, Toni
 

Attachments

  • Screenshot_20181225_230246.png
    Screenshot_20181225_230246.png
    265.7 KB · Views: 1,030
Last edited:
I installed 2 ngspice frontends. One immediately crashed and the other would throw an error at every attempt to do something. I've tried Gschem before, nothing really comes close to the efficiency of the LTspice schematic editor. I would never get anything done if I had to fight with all these terrible programs constantly.
 
Member
Joined 2011
Paid Member
Of course will do, but need some hours for cleaning up.
BTW: Tianprobe works. ...
ngspice has only limited support using multiple processors in parallel, but you can fork many ngspice instances to work parallel on the same circuit. That automates and speeds up standard tasks for me I can never reach using the mouse and switching between TRAN, AC, DC or whatever. You are right in criticizing the available schematic editors but this is not the fault of ngspice.


Here the sample ngspice commands to automate the tianprobe task (reused parts from the above link in post #3)



Code:
.control

set TEMP=28
set color0="white"
set color1="black"
set color2="steelblue"
set color3="darkolivegreen"

* set bias resistor for this run
alter @r41[resistance]=170

* run tianprobe simulation
alter @Vprobe1[acmag]=1
alter @iprobe1[acmag]=0

ac dec 240 1 100Meg

alter @Vprobe1[acmag]=0
alter @iprobe1[acmag]=1

ac dec 240 1 100Meg

echo "ac loops end"
setplot

let ip11 = ac1.i(vprobe1)
let ip21 = ac2.i(vprobe1)
let vprb1 = ac1.probe
let vprb2 = ac2.probe

let av = 1/(1/(2*(ip11*vprb2-vprb1*ip21)+vprb1+ip21)-1)

let phase=180/PI*vp(av)
plot phase
plot vdb(av)
plot vdb(av) phase

meas ac gm_db find vdb(av) when vp(av)=0
meas ac pm_deg find phase when vdb(av)=0
meas ac m3db_f when phase=135
meas ac m0db_f when vdb(av)=0
meas ac dc_gain find vdb(av) at=1
meas ac m6dB when vdB(av)=-6

.endc
Measurement results:

Code:
gm_db               =  -2.445813e+01
pm_deg              =  -1.155745e+02
m3db_f              =  2.368553e+07
m0db_f              =  2.620117e+06
dc_gain             =  1.160717e+02
m6db                =  5.117572e+06

BR, Toni
 

Attachments

  • Screenshot_20181226_123139.png
    Screenshot_20181226_123139.png
    191.1 KB · Views: 1,064
Last edited:
Member
Joined 2011
Paid Member
In only one run I can get those results:
Loop gain stability, output, fft of 20kHz full power, gain/frequency - see picture.


Note: a major difference is, that under LTSpice I have had always troubles with capacitor attached at input and nfb capacitor and needed to short circuit them. ngspice has no problem to find the operating point.


This is the command script:
Code:
.control

set TEMP=28
set color0="white"
set color1="black"
set color2="steelblue"
set color3="darkolivegreen"

* set bias resistor for this run
alter @r41[resistance]=170

* run tianprobe simulation
alter @Vprobe1[acmag]=1
alter @iprobe1[acmag]=0

ac dec 240 1 100Meg

alter @Vprobe1[acmag]=0
alter @iprobe1[acmag]=1

ac dec 240 1 100Meg

echo "ac loops end"
setplot

let ip11 = ac1.i(vprobe1)
let ip21 = ac2.i(vprobe1)
let vprb1 = ac1.probe
let vprb2 = ac2.probe

let av = 1/(1/(2*(ip11*vprb2-vprb1*ip21)+vprb1+ip21)-1)

let phase=180/PI*vp(av)
plot phase
plot vdb(av)
plot vdb(av) phase

meas ac gm_db find vdb(av) when vp(av)=0
meas ac pm_deg find phase when vdb(av)=0
meas ac m3db_f when phase=135
meas ac m0db_f when vdb(av)=0
meas ac dc_gain find vdb(av) at=1
meas ac m6dB when vdB(av)=-6

* set input signal before 'tran' run
alter @v1[sin] [ 0 0.95 20k ]
alter @r41[resistance]=170
tran 50n 1m

* plot options
*  plot exprs [ylimit ylo yhi] [xlimit xlo xhi] [xindices xilo xihi]
*  [xcompress comp] [xdelta xdel] [ydelta ydel]
*  [xlog] [ylog] [loglog] [nogrid] [vs xname_expr]
*  [linplot] [combplot] [pointplot] [nointerp] [noretraceplot]
*  [xlabel word] [ylabel word] [title word] [samep] [linear]

plot v(input) v(output) v(railpos) v(railneg)

setplot tran1
linearize v(output)
set specwindow=blackman
fft v(output)
* plot xlimit 20 5Meg ylog mag(v(output))
plot xlimit 20 500k ylimit -150 35 db(v(output))

* run a ac simulation
alter @v1[ac] [ 1 ]
ac oct 32 1 100Meg
plot xlimit 20 100Meg ylimit 0 35 db(v(output))

.endc
That makes fun! :)
BR, Toni
 

Attachments

  • Screenshot_20181226_130635.png
    Screenshot_20181226_130635.png
    110.2 KB · Views: 973
Last edited:
Member
Joined 2011
Paid Member
ASTX LABS - SA2017 VMOS IXYS ngspice simulation test

... attached the combined test of a complete amplifier. Note: you need the developer version of ngspice 29plus (= upcoming v30 release).

See NEWS info in source code:
Ngspice-30, Jan 1st, 2019
============

- New features:
+ VDMOS device model has been overhauled extensively

To edit the schematic you need gschem and gnetlist from gEDA suite version 1.8.x as well as the symbol from link post #3.
The "runme.sh" is reduced to sim the already generated netlist including all needed libs.
Only for educational usage because many included models are 3rd party (c).



Have fun, Toni
 

Attachments

  • Screenshot_20181226_154558.png
    Screenshot_20181226_154558.png
    208 KB · Views: 978
  • ngspice_simtest.zip
    338.9 KB · Views: 110
  • sa2015_v_mosfet_ixys_single_schematic.pdf
    66.6 KB · Views: 152
  • sa2015_v_mosfet_ixys_single_schematic.png
    sa2015_v_mosfet_ixys_single_schematic.png
    270.8 KB · Views: 304
Last edited:
Member
Joined 2011
Paid Member
ASTX LABS - powersupply with transformer - ngspice simulation test

... my powersupply simulation works too...
here the ngspice script:
Code:
* (c) astx (at) aws-it.at, 2018

* ---------------------------------------------------------------------
* add some spice parameters for our simple transformer
* ---------------------------------------------------------------------
K3 L3 L1 0.99998
K2 L2 L3 0.99998
K1 L1 L2 0.99998

* ---------------------------------------------------------------------
* add some ngspice options
* ---------------------------------------------------------------------
* save also currents too so we can plot it
.options savecurrents
* ---------------------------------------------------------------------
* ngspice control language
* ---------------------------------------------------------------------
.control
set TEMP=28
set color0="white"
set color1="black"
set color2="steelblue"
set color3="darkolivegreen"


echo "#---------------------------------------------------------------------"
echo "# run powersupply simulation"
echo "#---------------------------------------------------------------------"

* alter @r401[resistance] [ 10k ]
* alter @r402[resistance] [ 10k ]

op
display

echo "#---------------------------------------------------------------------"
echo "# run TRAN analysis"
echo "#---------------------------------------------------------------------"

* set input signal before 'tran' run
alter @v1[sin] [ 0 324 50 ]
tran 10u 0.5s

* plot options
*  plot exprs [ylimit ylo yhi] [xlimit xlo xhi] [xindices xilo xihi]
*  [xcompress comp] [xdelta xdel] [ydelta ydel]
*  [xlog] [ylog] [loglog] [nogrid] [vs xname_expr]
*  [linplot] [combplot] [pointplot] [nointerp] [noretraceplot]
*  [xlabel word] [ylabel word] [title word] [samep] [linear]

plot v(vacn,vacl)
plot v(railpos) v(railneg) v(railp1) v(railn1)
plot @r19[i]
plot @r13[i]+@r14[i] @r15[i]+@r16[i]

echo "#---------------------------------------------------------------------"
echo "# Show vectors from tran1 run"
echo "#---------------------------------------------------------------------"
display

.endc
using right mouse button you can zoom into the graph. Shown is a ringing detail of R19.
The output values are the same as the LTSpice simulation!



Have fun, Toni
 

Attachments

  • Screenshot_20181227_140913.png
    Screenshot_20181227_140913.png
    260.1 KB · Views: 289
Last edited:
Member
Joined 2011
Paid Member
SA2015 IXYS model amp: fourier analysis
Protection and VAS Diode in situ.

Code:
 No. of Data Rows : 20017
Fourier analysis for output:
  No. Harmonics: 10, THD: 0.00131015 %, Gridsize: 200, Interpolation Degree: 1

Harmonic Frequency   Magnitude   Phase       Norm. Mag   Norm. Phase
-------- ---------   ---------   -----       ---------   -----------
 0       0           -0.006186   0           0           0          
 1       20000       28.1122     -2.1002     1           0          
 2       40000       0.000354625 168.688     1.26146e-05 170.788    
 3       60000       6.98016e-05 97.5791     2.48296e-06 99.6793    
 4       80000       3.50413e-05 9.30218     1.24648e-06 11.4024    
 5       100000      7.21726e-06 -155.88     2.56731e-07 -153.78    
 6       120000      2.52163e-06 -95.054     8.96987e-08 -92.954    
 7       140000      3.73049e-05 169.511     1.327e-06   171.611    
 8       160000      8.84643e-06 77.4395     3.14683e-07 79.5397    
 9       180000      4.7611e-05  -164.21     1.6936e-06  -162.11
... also nice to have ...


BTW: all simulation tests are very close to the LTSPice XVII version ...
 
Last edited:
Member
Joined 2011
Paid Member
ASTX LABS - SA2017 VMOS IXYS ngspice simulation test

E.g.: Input signal 1V - output power on 8R ~ 81W

Calculate all power dissipation values for all devices - automatically!


ngspice OUTPUT:

Code:
 #---------------------------------------------------------------------
# Show RMS power dissipation of all devices
#---------------------------------------------------------------------
pwr_rms_c1          =  4.57875e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c2          =  1.06253e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c3          =  4.00613e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c4          =  4.00613e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c5          =  2.81557e-08 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c6          =  3.23378e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c7          =  2.21146e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c8          =  4.87424e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c9          =  1.32332e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c10         =  5.74080e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c11         =  1.30789e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c12         =  9.07029e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c13         =  8.99479e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c14         =  1.53410e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c15         =  2.05131e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c16         =  3.91894e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c17         =  3.26405e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c18         =  4.36449e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c19         =  2.69808e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c20         =  6.95764e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c21         =  1.71406e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c22         =  1.18800e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c23         =  7.68336e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c24         =  7.27256e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c31         =  0.00000e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c32         =  0.00000e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c33         =  2.21173e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c34         =  0.00000e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c35         =  5.29594e-12 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c36         =  5.34514e-12 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c37         =  0.00000e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c106        =  1.46990e-09 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_c111        =  5.94497e-08 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d1          =  7.74829e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d2          =  4.10149e-10 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d3          =  1.52585e-10 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d4          =  1.63809e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d5          =  5.40480e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d6          =  4.34699e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d7          =  4.34588e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d8          =  1.56285e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d9          =  2.37730e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d10         =  2.29772e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d11         =  2.01604e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d12         =  4.01572e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d13         =  5.16444e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d14         =  2.49410e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d15         =  5.47725e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d16         =  4.15666e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d17         =  2.35362e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_d18         =  3.88734e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_l1          =  5.90237e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_mq21        =  2.13203e+01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_mq22        =  2.11023e+01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q1          =  5.15488e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q2          =  9.55137e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q3          =  2.60692e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q4          =  3.79250e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q5          =  9.36698e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q6          =  9.49020e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q7          =  3.80325e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q8          =  5.06644e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q9          =  0.00000e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q10         =  1.58623e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q12         =  5.14813e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q14         =  5.13194e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q15         =  7.53370e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q17         =  1.56227e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q18         =  5.84281e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q19         =  1.34938e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_q20         =  1.34669e+00 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r1          =  4.87193e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r2          =  4.61490e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r3          =  1.57653e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r4          =  8.15491e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r5          =  3.79644e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r6          =  8.04473e-10 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r7          =  8.62810e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r8          =  9.66475e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r9          =  2.09852e-10 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r10         =  2.11306e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r11         =  4.34147e-10 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r12         =  1.06202e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r13         =  8.11293e+01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r14         =  5.14165e-08 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r15         =  4.32126e-10 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r16         =  6.63013e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r17         =  9.72107e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r18         =  2.11275e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r19         =  9.13512e-15 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r20         =  1.65731e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r21         =  8.08780e-10 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r22         =  1.65777e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r23         =  2.45346e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r24         =  3.37947e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r25         =  4.05536e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r26         =  9.11118e-15 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r29         =  6.76235e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r30         =  6.76235e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r31         =  8.00535e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r32         =  1.77264e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r34         =  9.78543e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r35         =  2.25367e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r36         =  1.05171e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r37         =  1.50393e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r38         =  3.09128e-08 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r39         =  9.50066e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r40         =  2.96615e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r41         =  3.29572e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r42         =  2.60634e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r43         =  6.29795e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r44         =  5.25746e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r45         =  6.17749e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r46         =  6.29788e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r47         =  5.25577e-03 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r48         =  6.20675e-07 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r49         =  4.13350e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r50         =  1.33720e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r51         =  9.42487e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r52         =  4.37918e-06 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r53         =  1.30201e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r54         =  4.20042e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r55         =  9.42487e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r56         =  1.76235e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r58         =  9.93955e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r59         =  9.20761e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r61         =  2.59914e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r62         =  1.30707e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r65         =  1.10692e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r66         =  1.63762e-04 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r67         =  6.48511e-05 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r68         =  7.28070e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r69         =  7.28827e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r78         =  1.06234e-01 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r79         =  4.66983e-02 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r80         =  4.21421e-27 from=  0.00000e+00 to=  1.00000e-03
pwr_rms_r81         =  4.77671e-27 from=  0.00000e+00 to=  1.00000e-03
#---------------------------------------------------------------------
# Show vectors from ac2 run
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Show loopgain results again
#---------------------------------------------------------------------
GM : -19.2597
PM : -121.966
3db : 1.43818E+07
0db : 2.89793E+06
dc gain : 115.986
6db : 5.5177E+06
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Show distortion
#---------------------------------------------------------------------
Fourier analysis for output:
  No. Harmonics: 10, THD: 0.00177092 %, Gridsize: 200, Interpolation Degree: 1

Harmonic Frequency   Magnitude   Phase       Norm. Mag   Norm. Phase
-------- ---------   ---------   -----       ---------   -----------
 0       0           -0.0072925  0           0           0          
 1       20000       32.5574     -1.6695     1           0          
 2       40000       0.000540727 170.832     1.66084e-05 172.501    
 3       60000       0.000126137 79.4802     3.87428e-06 81.1497    
 4       80000       0.000115378 -5.9044     3.54382e-06 -4.2349    
 5       100000      6.09718e-05 -13.326     1.87275e-06 -11.657    
 6       120000      5.72512e-05 164.235     1.75847e-06 165.904    
 7       140000      2.5112e-05  37.0531     7.71312e-07 38.7226    
 8       160000      4.82495e-05 -7.6143     1.48198e-06 -5.9448    
 9       180000      2.94355e-05 162.831     9.04111e-07 164.501
I like it, I love it, a simple perl script generates me a huge "meas" script where I can calculate and plot all power dissipation values for a review - WOW.


Part of generated "meas" script

Code:
.control
let p_c1 = abs(v(1,input)*@c1[i])
meas tran pwr_rms_c1 RMS p_c1
let p_c2 = abs(v(inppos)*@c2[i])
meas tran pwr_rms_c2 RMS p_c2
let p_c3 = abs(v(ipscasc1,ipscasc2)*@c3[i])
meas tran pwr_rms_c3 RMS p_c3
let p_c4 = abs(v(ipscasc2,ipscasc1)*@c4[i])
meas tran pwr_rms_c4 RMS p_c4
...
.endc
Attached the perl example which extracts all devices from netlist and generates a sorted meas script to be automatically included in the ngspice run...

BR, Toni
 
Last edited:
Member
Joined 2011
Paid Member
There is nothing attached.


that was a test, if someone finds the error :D - you are winner! See attached zip file.


In fact I have been disturbed by good friends - wanted to discuss the day when we should view the newest blockbuster in my home cinema ... the 30 minutes thread news edit time went unused away ...


BR, Toni
 

Attachments

  • ngspice_simtest_v2.zip
    345.3 KB · Views: 81
Member
Joined 2011
Paid Member
The title of this thread is: Installing and using ngspice - an opensource simulator

So what about an installation guide?

The download site is just a mess.


Haven't posted any download information because ngspice v30 hasn't been released yet. Stay tuned! Installing on Windows is out of my focus - I prefer Linux/opensource (maybe one will write a windows howto - I am willing to update the index at post #1 if this happens;)). The bash scripts and perl based utility programs I present here require Linux/Unix system or a Windows 10 enabled Linux system and/or cygwin.


Have fun, Toni


P.S.: time to move to Linux :D
 
Member
Joined 2011
Paid Member
ASTX LABS - SA2017 VMOS IXYS ngspice soa simulation test

A bit tricky to get extra lines on the plot. To print the SOA data lines of the output power MOSFET I have used "compose":

Code:
* SOA data points of IXTH80N20L
* compose soa_a values 20 20 14 10 7.5 6.2 5.1 4.3 3.7 3.1 2.4 0.74 20 16 13 10.2 8.5 7.4 6.5 5 4.2 1.2
* compose soa_v values 1 14 20 30 40 50 60 70 80 90 100 200 24 30 40 50 60 70 80 90 100 200

compose soa_a values 20 20 14 10 7.5 6.2 5.1 4.3 3.7 3.1 2.4 0.74
compose soa_v values 1 14 20 30 40 50 60 70 80 90 100 200
compose soa_a2 values 20 16 13 10.2 8.5 7.4 6.5 5 4.2 1.2
compose soa_v2 values 24 30 40 50 60 70 80 90 100 200

* linear scale
plot @mq21[id] vs v_mq21 soa_a vs soa_v soa_a2 vs soa_v2 xlimit 1 200 ylimit 0.1 20
* log scale
plot @mq21[id] vs v_mq21 soa_a vs soa_v soa_a2 vs soa_v2 xlog ylog xlimit 1 200 ylimit 0.1 20
One can good see the over current protection in action.
Attached also an excerpt of the IXTH80N20L datasheet.

BR, Toni
 

Attachments

  • Screenshot_20181230_150004.png
    Screenshot_20181230_150004.png
    222.6 KB · Views: 275
  • ngspice_simtest_soa.zip
    15.9 KB · Views: 71
  • ixth80n20l_soa.png
    ixth80n20l_soa.png
    60.9 KB · Views: 274
Last edited: