Inconsistent repeat noise analyses


To ng-spice mailing list <ng-spice@ieee.ing.uniroma1.it>
From Robert Penny <rob@network.ucsd.edu>
Date Sun, 7 Jan 2001 20:02:55 -0800 (PST)
Delivered-To mailing list ng-spice@ieee.ing.uniroma1.it
Mailing-List contact ng-spice-help@ieee.ing.uniroma1.it; run by ezmlm
Reply-To ng-spice@ieee.ing.uniroma1.it

A few days ago I posted a question regarding noise analysis in ng-spice.
In brief the problem was that I when I performed an integrated noise
analysis I would expect the ratio of the noise referred to the output to
the noise referred to the input to be the same for all noise sources in
the circuit.  It wasn't.

In testing the problem I discovered a more glaring error, namely that the
results of two identical noise analyses performed in succession do not
necessarily yield the same results.  This sounds like an error caused by
uninitialised variables or storage.  In fact I have just tried running the
same analysis three times in succession, all noises in the second analysis
are double those of the first, and in the third analysis are three times
the noise of the first.  This pattern pattern is, however, not in itself
consistent.

Whatever the problem, it is somewhat subtle.  The problem does not occur
with all circuits.  For example, when I run repeated noise analyses on a
circuit containing just a parallel pair of two ohm resistors I get the
same results repeatedly.

Specifically, if I run the circuit:

********************************************************************

* Measuring the Johnson noise of a resistor to calibrate the noise
* measurement. Two resistors are placed in parallel to duplicate a single
* resistor with a floating node.  SPICE often complains about floating
* nodes.

R1 1 0 2
R2 1 0 2

vnoiseref noiseout 1 ac 1
.end

********************************************************************

Then run the analysis

ngspice 3 -> noise v(noiseout) vnoiseref dec 10 1k 1meg 1
Warning: vnoiseref: has no value, DC 0 assumed
ngspice 4 -> print all
inoise_total = 1.655918e-14
inoise_total_r1 = 8.279590e-15
inoise_total_r2 = 8.279590e-15
onoise_total = 1.655918e-14
onoise_total_r1 = 8.279590e-15
onoise_total_r2 = 8.279590e-15

... then repeat the analysis

ngspice 5 -> noise v(noiseout) vnoiseref dec 10 1k 1meg 1
Warning: vnoiseref: has no value, DC 0 assumed
ngspice 6 -> print all
inoise_total = 1.655918e-14
inoise_total_r1 = 1.655918e-14
inoise_total_r2 = 1.655918e-14
onoise_total = 1.655918e-14
onoise_total_r1 = 8.279590e-15
onoise_total_r2 = 8.279590e-15

It can be seen that I get the same answer both times.  What's more the
answer is what you would expect by calculating

onoise_total = 4kTR * BW
             = 4 * 1.38062E-23 * 300.15 * (1e6 - 1e3)
             = 1.655914E-14 V^2

My more complicated circuit, however, does not give the same results on
repeat calculations. I wanted to find a minimum circuit demonstrating the
problem, however, my first attempts to find such a circuit have not been
successful.  In the meantime I'm posting the full circuit rads.sp, an two
include files j2sk152.sp and lm6171_ideal_noise.sp so anyone who is
interested in the problem can replicate it.

For example, try running

source rads.sp
noise v(outamp) vsig dec 10 1k 1meg 1
print all > noise1.txt
noise v(outamp) vsig dec 10 1k 1meg 1
print all > noise2.txt
quit

Then perform a diff on noise1.txt and noise2.txt

Both ngspice-rework-12 and ngspice-rework-13 exhibit the problem.
Ngspice-rework-13 has the added annoyance of quitting if I try to run a
script, terminating with error

"internal error -- segmentation violation"

Any advice would be welcome.

-Rob Penny (rob@ucsd.edu)
*/////////////////////////////////////////////////////////////////
* Ideal amplifier model of the LM6171 for noise modelling purposes.
* Written by RDP on 1/4/2001 from the LM6171 data sheet.
*/////////////////////////////////////////////////////////////////
*
* The subcircuit models:
*       - white noise voltage and current noise referred to the input
*       - open loop gain
*       - a dominant pole roll-off
*       - a second pole at 100MHz  (unity gain crossing around 100MHz)
*       - open loop output impedance
*
* The subcircuit does not model:
*       - power supply
*       - nonlinearities
*       - input offset or bias currents
*       - temperature effects (noise generators are calibrated correct for 
27C)
*       - 1/f noise components
*
*Connections         non-inverting input
*                    |   inverting input
*                    |   |   positive power supply
*                    |   |  |  negative power supply
*                    |   |  | |  output
*                    |   |  | | |
.SUBCKT LM6171A_NS ninv inv 4 5 outp 

rsup 4 5 10k

rinput ninv inv 4Meg

* A 60.32907025 ohm resistor is calibrated to give 1nV/Sqrt(Hz) 
* noise voltage at 27C (300.15K)

* 11nV/Sqrt(Hz) input voltage noise generator (white)
rnv 1 0 60.32907025
rnvret 1 0 100G
env ninv fe_ninv 1 0 11

* 1pA/Sqrt(Hz) input current noise generator (white)
rni 2 0 60.32907025
rniret 2 0 100G
gni ninv inv 2 0 1E-3

* Ideal front end amplification (90dB open loop gain)

eideal fe_out 0 fe_ninv inv 3.162278312E4

* Dominant pole to give unity gain crossing at 100MHz in conjunction with the
* obvious second pole that appears around 100MHz.  Assume 1/Sqrt(2) 
attenuation
* from the second pole at 100MHz.  The dominant pole should give an 
attenuation
* of 90dB at 100MHz.
*
* Sqrt(1+w^2 R^2 C^2) = attenuation => RC = Sqrt(attenuation^2 - 1)/omega
*

rdp fe_out dp 1
cdp dp 0 4.232165401E-5
edp dp_out 0 dp 0 1

rp2 dp_out p2_in 1
cp2 p2_in 0 1.591549431E-9
ep2 p2_out 0 p2_in 0 1

rout outp p2_out 14

.ends

.model J2sk152  NJF (Beta=22.6m Rs=9.028 Rd=9.028 Betatce=-.5 Lambda=33.33m
+ Vto=-1.067 Vtotc=-2.5m Cgd=3.634p M=.3333 Pb=1 Fc=.5 Cgs=5.892p

+ Isr=51.93p Nr=864.6 Is=5.193p N=1 Xti=3 Alpha=435.7u Vk=81.6

+ Kf=2.599E-18 Af=.7991)


* Simulation of the photosensor input circuit


* The following is a current source injecting over 1us a charge of
* 1.6nA * 1us = 1.6E-15 coulomb = 10,000electrons

* Isig photod 0 pwl(0 0 10u 0 10.001u 1.6n 11u 1.6n 11.001u 0 20u 0)
* Csensor photod 0 55p

* The following is a voltage source introducing a voltage step representing
* 10,000 electrons also.  Although this is equivalent electrically to the
* current source approach, it shows the scale factor correspondence between 
* charge and voltage.
*
* I = C dV/dt so we want 
* dV/dt = I/C = 1.6E-9/55E-12 = 29.0909 V/s = 29.0909 uV/us

* .options itl1=10001
* .options itl2=10002
* .options itl3=10003
* .options itl4=10004
* .options itl5=10005
* .options itl6=10006

Vsig sensecap gate pwl(0 0 10u 0 11u 29.0909u) ac 1 dc 0
Csensor 0 sensecap 55p

* We'll set for 10mA bias and Vds = 5V.  This is the point where the 
* 2SK152 data sheet calculates its noise from.

Rd drain vpfet 500
Vfetsup vpfet 0 10

* A JFET is intrinsically a depletion mode device.
* The gate must not go more than 0.5V +ve w.r.t. either
* source or drain.

*MXXXX ND NG NS NB MNAME
J1 drain gate 0 J2sk152

*/////////////////////////////////////////
*LM6171A Operational Amplifier Macro-Model
*/////////////////////////////////////////
*
*Connections       non-inverting input
*                  | inverting input
*                  | |  positive power supply
*                  | | |  negative power supply
*                  | | | |  output
*                  | | | | |
*SUBCKT LM6171A/NS 3 2 4 5 6

Xopamp drain biasref vpamp vnamp outamp LM6171A_NS

Vopampp vpamp 0 10
vopampn vnamp 0 -10

Rbiasref1 vpamp biasref 10k
Rbiasref2 biasref 0 10k

rload outamp 0 1k

* rgatefb outamp gate 219meg
rgatefb outamp gate 250meg
* rgatefb outamp gate 50Gig
* vgfbsig vg gate ac 0 dc 0

cgatefb outamp gate 1p

.include j2sk152.sp
* .include LM6171.sp
.include lm6171_ideal_noise.sp
.end

Partial thread listing: