From 434930e9be06210d5ce599bb28774e8a6f62e8c0 Mon Sep 17 00:00:00 2001 From: ivandi Date: Sat, 4 Jan 2025 08:14:52 -0500 Subject: [PATCH] Power amplifier THD vs. output voltage RMS ngspice template --- examples/templates_ngspice/PwrAmpTHD.sch | 194 +++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 examples/templates_ngspice/PwrAmpTHD.sch diff --git a/examples/templates_ngspice/PwrAmpTHD.sch b/examples/templates_ngspice/PwrAmpTHD.sch new file mode 100644 index 00000000..7ce4ca3e --- /dev/null +++ b/examples/templates_ngspice/PwrAmpTHD.sch @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + <_BJT Q2N3905_2 1 550 470 -74 -26 0 2 "pnp" 0 "1.05e-15" 0 "1" 0 "1" 0 "0.1" 0 "0" 0 "240" 0 "0" 0 "1.003e-09" 0 "4" 0 "1.003e-09" 0 "4" 0 "220" 0 "1" 0 "0" 0 "0" 0 "0.2" 0 "0.5" 0 "3" 0 "5.7e-12" 0 "0.75" 0 "0.33" 0 "4.32e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "3.35e-10" 0 "0" 0 "0" 0 "0" 0 "1.7e-07" 0 "26.85" 0 "4e-15" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "0" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + <_BJT Q2N3904_1 1 370 170 8 -26 0 0 "npn" 0 "1.4e-14" 0 "1" 0 "1" 0 "0.025" 0 "0" 0 "100" 0 "0" 0 "3e-13" 0 "1.5" 0 "0" 0 "2" 0 "300" 0 "7.5" 0 "0" 0 "0" 0 "2.4" 0 "0" 0 "0" 0 "4.5e-12" 0 "0.75" 0 "0.33" 0 "3.5e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "4e-10" 0 "0" 0 "0" 0 "0" 0 "2.1e-08" 0 "26.85" 0 "9e-16" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.5" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + <_BJT Q2N3904_2 1 550 170 -74 -26 1 2 "npn" 0 "1.4e-14" 0 "1" 0 "1" 0 "0.025" 0 "0" 0 "100" 0 "0" 0 "3e-13" 0 "1.5" 0 "0" 0 "2" 0 "300" 0 "7.5" 0 "0" 0 "0" 0 "2.4" 0 "0" 0 "0" 0 "4.5e-12" 0 "0.75" 0 "0.33" 0 "3.5e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "4e-10" 0 "0" 0 "0" 0 "0" 0 "2.1e-08" 0 "26.85" 0 "9e-16" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.5" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + + + + + <_BJT Q2N3905_1 1 370 470 8 -26 1 0 "pnp" 0 "1.05e-15" 0 "1" 0 "1" 0 "0.1" 0 "0" 0 "240" 0 "0" 0 "1.003e-09" 0 "4" 0 "1.003e-09" 0 "4" 0 "220" 0 "1" 0 "0" 0 "0" 0 "0.2" 0 "0.5" 0 "3" 0 "5.7e-12" 0 "0.75" 0 "0.33" 0 "4.32e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "3.35e-10" 0 "0" 0 "0" 0 "0" 0 "1.7e-07" 0 "26.85" 0 "4e-15" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "0" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + + + + + + + + + + + + <_BJT Q2N3904_3 1 710 10 8 -26 0 0 "npn" 0 "1.4e-14" 0 "1" 0 "1" 0 "0.025" 0 "0" 0 "100" 0 "0" 0 "3e-13" 0 "1.5" 0 "0" 0 "2" 0 "300" 0 "7.5" 0 "0" 0 "0" 0 "2.4" 0 "0" 0 "0" 0 "4.5e-12" 0 "0.75" 0 "0.33" 0 "3.5e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "4e-10" 0 "0" 0 "0" 0 "0" 0 "2.1e-08" 0 "26.85" 0 "9e-16" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.5" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_BJT Q2N2955_1 1 1030 10 8 -26 1 0 "pnp" 0 "4.66e-12" 0 "1" 0 "1" 0 "0.25" 0 "0" 0 "100" 0 "0" 0 "3.339e-11" 0 "1.5" 0 "5e-09" 0 "2" 0 "360" 0 "2" 0 "0.4" 0 "0.001" 0 "0.04" 0 "0" 0 "3" 0 "5.802e-10" 0 "1.2" 0 "0.45" 0 "2.121e-10" 0 "0.75" 0 "0.4" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "8e-08" 0 "1" 0 "0" 0 "3" 0 "2.55e-06" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "120" 0 "1" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + <_BJT Q2N3055_1 1 1030 630 8 -26 0 0 "npn" 0 "4.66e-12" 0 "1" 0 "1" 0 "0.25" 0 "0" 0 "100" 0 "0" 0 "3.339e-11" 0 "1.5" 0 "5e-09" 0 "2" 0 "360" 0 "2" 0 "0.4" 0 "0.001" 0 "0.04" 0 "0" 0 "3" 0 "5.802e-10" 0 "1.2" 0 "0.45" 0 "2.121e-10" 0 "0.75" 0 "0.4" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "8e-08" 0 "1" 0 "0" 0 "3" 0 "2.55e-06" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "120" 0 "1" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + <_BJT BD136_138_140_1 1 820 40 8 -26 1 0 "pnp" 0 "2.9537e-13" 0 "1" 0 "1.021" 0 "1.0993" 0 "0.1" 0 "137" 0 "8.41" 0 "1.8002e-13" 0 "1.5" 0 "7.0433e-12" 0 "1.38" 0 "201.4" 0 "23.765" 0 "0.01" 0 "0.011" 0 "0.01" 0 "0.1109" 0 "1.98" 0 "2.1982e-10" 0 "0.7211" 0 "0.3685" 0 "6.8291e-11" 0 "0.5499" 0 "0.3668" 0 "0.5287" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "0" 0 "0" 0 "0" 0 "0" 0 "0" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.4883" 0 "3" 0 "1.2343" 0 "26.85" 0 "1" 0 "yes" 0> + + + + + + + + + + + + + + + <_BJT Q2N3905_3 1 710 630 8 -26 1 0 "pnp" 0 "1.05e-15" 0 "1" 0 "1" 0 "0.1" 0 "0" 0 "240" 0 "0" 0 "1.003e-09" 0 "4" 0 "1.003e-09" 0 "4" 0 "220" 0 "1" 0 "0" 0 "0" 0 "0.2" 0 "0.5" 0 "3" 0 "5.7e-12" 0 "0.75" 0 "0.33" 0 "4.32e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "3.35e-10" 0 "0" 0 "0" 0 "0" 0 "1.7e-07" 0 "26.85" 0 "4e-15" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "0" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0> + + + + <_BJT BD135_137_139_1 1 820 600 8 -26 0 0 "npn" 0 "2.3985e-13" 0 "1" 0 "1.007" 0 "1.1863" 0 "0.1445" 0 "98.5" 0 "7.46" 0 "1.0471e-14" 0 "1.2" 0 "1.9314e-11" 0 "1.45" 0 "244.9" 0 "78.11" 0 "0.001" 0 "0.031" 0 "0.01" 0 "0.0832" 0 "2.14" 0 "2.92702e-10" 0 "0.67412" 0 "0.33" 0 "4.8831e-11" 0 "0.5258" 0 "0.3928" 0 "0.5287" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "0" 0 "0" 0 "0" 0 "0" 0 "0" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.1398" 0 "3" 0 "1.2105" 0 "26.85" 0 "1" 0 "yes" 0> + + + + + + <.CUSTOMSIM CUSTOM1 1 1230 30 0 40 0 0 "\ncompose vin start=100m stop=1 step=100m\nlet n=length(vin)\nlet thd=vector(n)\nlet out_rms=vector(n)\n\nset nfreqs=20\n\nlet i=0\nrepeat $&n\n let vin_i=vin[i]\n alterparam vin=$&vin_i\n reset\n\n tran 10u 10m\n fourier 1k v(out)\n meas tran orms_i rms out\n let out_rms[i]=orms_i\n\n let j=2\n let sum_i=0\n let f=i+1\n while j < $nfreqs\n let sum_i=sum_i+fourier{$&f}1[1][j]^2\n let j=j+1\n end\n let thd_i=100*sqrt(sum_i)/fourier{$&f}1[1][1]\n let thd[i]=thd_i\n\n destroy $curplot\n let i=i+1\nend\n\nsetscale out_rms\n\ndestroy all\nreset" 0 "thd;vin" 0 "" 0> + + + + <370 440 550 440 "" 0 0 0 ""> + <370 200 550 200 "" 0 0 0 ""> + <580 170 580 200 "" 0 0 0 ""> + <370 260 470 260 "" 0 0 0 ""> + <370 380 460 380 "" 0 0 0 ""> + <580 440 580 470 "" 0 0 0 ""> + <580 470 620 470 "" 0 0 0 ""> + <580 170 620 170 "" 0 0 0 ""> + <370 500 370 630 "" 0 0 0 ""> + <250 690 310 690 "" 0 0 0 ""> + <190 690 250 690 "" 0 0 0 ""> + <370 690 620 690 "" 0 0 0 ""> + <370 630 620 630 "" 0 0 0 ""> + <710 -50 710 -20 "" 0 0 0 ""> + <710 -50 820 -50 "" 0 0 0 ""> + <710 40 790 40 "" 0 0 0 ""> + <710 40 710 70 "" 0 0 0 ""> + <820 10 940 10 "" 0 0 0 ""> + <820 -50 1030 -50 "" 0 0 0 ""> + <1030 -50 1030 -20 "" 0 0 0 ""> + <370 10 370 140 "" 0 0 0 ""> + <250 -50 310 -50 "" 0 0 0 ""> + <190 -50 250 -50 "" 0 0 0 ""> + <370 -50 620 -50 "" 0 0 0 ""> + <370 10 620 10 "" 0 0 0 ""> + <620 10 680 10 "" 0 0 0 ""> + <620 -50 710 -50 "" 0 0 0 ""> + <470 260 580 260 "" 0 0 0 ""> + <470 260 470 510 "" 0 0 0 ""> + <620 470 940 470 "" 0 0 0 ""> + <1030 660 1030 690 "" 0 0 0 ""> + <1030 470 1030 600 "" 0 0 0 ""> + <1030 440 1030 470 "" 0 0 0 ""> + <620 170 940 170 "" 0 0 0 ""> + <1030 40 1030 170 "" 0 0 0 ""> + <1030 170 1030 200 "" 0 0 0 ""> + <1030 300 1030 320 "" 0 0 0 ""> + <1030 200 1030 240 "" 0 0 0 ""> + <1030 400 1030 440 "" 0 0 0 ""> + <940 300 940 340 "" 0 0 0 ""> + <940 200 970 200 "" 0 0 0 ""> + <940 200 940 240 "" 0 0 0 ""> + <940 170 970 170 "" 0 0 0 ""> + <940 170 940 200 "" 0 0 0 ""> + <940 440 970 440 "" 0 0 0 ""> + <940 400 940 440 "" 0 0 0 ""> + <940 470 970 470 "" 0 0 0 ""> + <940 440 940 470 "" 0 0 0 ""> + <460 380 580 380 "" 0 0 0 ""> + <1030 320 1030 340 "" 0 0 0 ""> + <1030 320 1110 320 "" 0 0 0 ""> + <1030 690 1140 690 "" 0 0 0 ""> + <1030 -50 1140 -50 "" 0 0 0 ""> + <160 320 250 320 "" 0 0 0 ""> + <250 260 310 260 "" 0 0 0 ""> + <310 170 310 200 "" 0 0 0 ""> + <310 170 340 170 "" 0 0 0 ""> + <250 380 310 380 "" 0 0 0 ""> + <310 440 310 470 "" 0 0 0 ""> + <310 470 340 470 "" 0 0 0 ""> + <620 690 710 690 "" 0 0 0 ""> + <820 630 940 630 "" 0 0 0 ""> + <820 690 1030 690 "" 0 0 0 ""> + <620 630 680 630 "" 0 0 0 ""> + <710 660 710 690 "" 0 0 0 ""> + <710 600 790 600 "" 0 0 0 ""> + <710 690 820 690 "" 0 0 0 ""> + <710 570 710 600 "" 0 0 0 ""> + <460 130 460 380 "" 0 0 0 ""> + <310 130 460 130 "" 0 0 0 ""> + <310 -50 310 130 "" 0 0 0 ""> + <550 130 550 140 "" 0 0 0 ""> + <460 130 550 130 "" 0 0 0 ""> + <310 510 310 690 "" 0 0 0 ""> + <310 510 470 510 "" 0 0 0 ""> + <550 500 550 510 "" 0 0 0 ""> + <470 510 550 510 "" 0 0 0 ""> + <1110 260 1110 320 "" 0 0 0 ""> + <100 260 100 320 "" 0 0 0 ""> + <1110 320 1110 320 "out" 1070 290 0 ""> + <100 320 100 320 "in" 70 300 0 ""> + + + + <"ngspice/thd" #0000ff 2 3 0 0 0> + + + <"ngspice/thd" #0000ff 0 3 1 0 0> + <"ngspice/vin" #0000ff 0 3 1 0 0> + + + + +