Jspice3
noiinteg.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1987 Gary W. Ng
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  * Nintegrate.c (noizDens, lnNdens, lnNlstDens, data)
10  *
11  * This subroutine evaluates the integral of the function
12  *
13  * EXPONENT
14  * NOISE = a * (FREQUENCY)
15  *
16  * given two points from the curve. If EXPONENT is relatively close
17  * to 0, the noise is simply multiplied by the change in frequency.
18  * If it isn't, a more complicated expression must be used. Note that
19  * EXPONENT = -1 gives a different equation than EXPONENT <> -1.
20  * Hence, the reason for the constant 'N_INTUSELOG'.
21  */
22 
23 #include "spice.h"
24 #include <stdio.h>
25 #include <math.h>
26 #include "cktdefs.h"
27 #include "noisedef.h"
28 #include "util.h"
29 
30 
31 double
32 Nintegrate(noizDens, lnNdens, lnNlstDens, dataptr)
33 
34 double noizDens;
35 double lnNdens;
36 double lnNlstDens;
37 GENERIC *dataptr;
38 {
39  Ndata *data = (Ndata*)dataptr;
40  double exponent;
41  double a;
42 
43  exponent = (lnNdens - lnNlstDens) / data->delLnFreq;
44 
45  if ( FABS(exponent) < N_INTFTHRESH ) {
46  return (noizDens * data->delFreq);
47  }
48  else {
49  a = exp(lnNdens - exponent*data->lnFreq);
50  exponent += 1.0;
51 
52  if (FABS(exponent) < N_INTUSELOG) {
53  return (a * (data->lnFreq - data->lnLastFreq));
54  }
55  else {
56  return (a * ((exp(exponent * data->lnFreq) -
57  exp(exponent * data->lnLastFreq)) / exponent));
58  }
59  }
60 }
double delLnFreq
Definition: noisedef.h:28
#define N_INTFTHRESH
Definition: noisedef.h:105
if(TDesc==NULL)
Definition: cd.c:1326
double lnLastFreq
Definition: noisedef.h:27
#define N_INTUSELOG
Definition: noisedef.h:112
double lnFreq
Definition: noisedef.h:26
Definition: sced.h:120
double Nintegrate(double noizDens, double lnNdens, double lnNlstDens, GENERIC *dataptr)
Definition: noiinteg.c:32
#define FABS(a)
Definition: util.h:41
double delFreq
Definition: noisedef.h:21
char GENERIC
Definition: ifsim.h:27
Definition: noisedef.h:18