1 /**********
2 Copyright 1990 Regents of the University of California.  All rights reserved.
3 Author: 1985 Thomas L. Quarles
4 Modified: September 2003 Paolo Nenzi
5 **********/
6 
7 #ifndef CAP
8 #define CAP
9 
10 
11 #include "ngspice/ifsim.h"
12 #include "ngspice/complex.h"
13 #include "ngspice/gendefs.h"
14 #include "ngspice/cktdefs.h"
15 
16 /* structures used to describe capacitors */
17 
18 
19 /* information to describe each instance */
20 
21 typedef struct sCAPinstance {
22 
23     struct GENinstance gen;
24 
25 #define CAPmodPtr(inst) ((struct sCAPmodel *)((inst)->gen.GENmodPtr))
26 #define CAPnextInstance(inst) ((struct sCAPinstance *)((inst)->gen.GENnextInstance))
27 #define CAPname gen.GENname
28 #define CAPstate gen.GENstate
29 
30     const int CAPposNode; /* number of positive node of capacitor */
31     const int CAPnegNode; /* number of negative node of capacitor */
32 
33     double CAPtemp;     /* temperature at which this capacitor operates */
34     double CAPdtemp;    /* delta-temperature of this instance */
35     double CAPcapac;    /* capacitance */
36     double CAPinitCond; /* initial capacitor voltage if specified */
37     double CAPwidth;    /* width of the capacitor */
38     double CAPlength;   /* length of the capacitor */
39     double CAPscale;    /* scale factor */
40     double CAPm;        /* parallel multiplier */
41     double CAPtc1;      /* first temperature coefficient of capacitors */
42     double CAPtc2;      /* second temperature coefficient of capacitors */
43     double CAPbv_max;   /* Maximum capacitor voltage */
44 
45     double *CAPposPosPtr;    /* pointer to sparse matrix diagonal at
46                               * (positive,positive) */
47     double *CAPnegNegPtr;    /* pointer to sparse matrix diagonal at
48                               * (negative,negative) */
49     double *CAPposNegPtr;    /* pointer to sparse matrix offdiagonal at
50                               * (positive,negative) */
51     double *CAPnegPosPtr;    /* pointer to sparse matrix offdiagonal at
52                               * (negative,positive) */
53     unsigned CAPcapGiven    : 1;   /* flag to indicate capacitance was specified */
54     unsigned CAPicGiven     : 1;   /* flag to indicate init. cond. was specified */
55     unsigned CAPwidthGiven  : 1;   /* flag to indicate capacitor width given */
56     unsigned CAPlengthGiven : 1;   /* flag to indicate capacitor length given*/
57     unsigned CAPtempGiven   : 1;   /* flag to indicate operating temp given */
58     unsigned CAPdtempGiven  : 1;   /* flag to indicate delta temp given */
59     unsigned CAPscaleGiven  : 1;   /* flag to indicate scale factor given */
60     unsigned CAPmGiven      : 1;   /* flag to indicate parallel multiplier given */
61     unsigned CAPtc1Given    : 1;    /* flag indicates tc1 was specified */
62     unsigned CAPtc2Given    : 1;    /* flag indicates tc2 was specified */
63     unsigned CAPbv_maxGiven : 1;    /* flags indicates maximum voltage is given */
64     int    CAPsenParmNo;         /* parameter # for sensitivity use;
65                 set equal to  0 if not a design parameter*/
66 
67 } CAPinstance ;
68 
69 #define CAPqcap CAPstate    /* charge on the capacitor */
70 #define CAPccap CAPstate+1  /* current through the capacitor */
71 
72 #define CAPnumStates 2
73 
74 #define CAPsensxp CAPstate+2 /* charge sensitivities and their derivatives.
75                               * +3 for the derivatives - pointer to the
76                               * beginning of the array */
77 
78 #define CAPnumSenStates 2
79 
80 
81 /* data per model */
82 
83 typedef struct sCAPmodel {      /* model structure for a capacitor */
84 
85     struct GENmodel gen;
86 
87 #define CAPmodType gen.GENmodType
88 #define CAPnextModel(inst) ((struct sCAPmodel *)((inst)->gen.GENnextModel))
89 #define CAPinstances(inst) ((CAPinstance *)((inst)->gen.GENinstances))
90 #define CAPmodName gen.GENmodName
91 
92     double CAPtnom;       /* temperature at which capacitance measured */
93     double CAPtempCoeff1; /* linear temperature coefficient */
94     double CAPtempCoeff2; /* quadratic temperature coefficient */
95     double CAPmCap;       /* Model default capacitance */
96     double CAPcj;         /* Unit Area Capacitance ( F/ M**2 ) */
97     double CAPcjsw;       /* Unit Length Sidewall Capacitance ( F / M ) */
98     double CAPdefWidth;   /* the default width of a capacitor */
99     double CAPdefLength;  /* the default length of a capacitor */
100     double CAPnarrow;     /* amount by which width are less than drawn */
101     double CAPshort;      /* amount by which length are less than drawn */
102     double CAPdel;        /* amount by which length and width are less than drawn */
103     double CAPdi;         /* Relative dielectric constant */
104     double CAPthick;      /* Insulator thickness */
105     double CAPbv_max;     /* Maximum capacitor voltage */
106     unsigned CAPmCapGiven      : 1;    /* flag indicates default capacitance given */
107     unsigned CAPcjGiven        : 1;    /* Unit Area Capacitance ( F/ M**2 ) */
108     unsigned CAPcjswGiven      : 1;    /* Unit Length Sidewall Capacitance( F/M )*/
109     unsigned CAPdefWidthGiven  : 1;    /* flag indicates default width given*/
110     unsigned CAPdefLengthGiven : 1;    /* flag indicates deafult lenght given */
111     unsigned CAPnarrowGiven    : 1;    /* flag indicates narrowing factor given */
112     unsigned CAPshortGiven     : 1;    /* flag indicates shortening factor given */
113     unsigned CAPdelGiven       : 1;    /* flag indicates del factor given */
114     unsigned CAPtnomGiven      : 1;    /* flag indicates nominal temp. given */
115     unsigned CAPtc1Given       : 1;    /* flag indicates tc1 was specified */
116     unsigned CAPtc2Given       : 1;    /* flag indicates tc2 was specified */
117     unsigned CAPdiGiven        : 1;    /* flag indicates epsilon-ins given */
118     unsigned CAPthickGiven     : 1;    /* flags indicates insulator thickness given */
119     unsigned CAPbv_maxGiven    : 1;    /* flags indicates maximum voltage is given */
120 
121 } CAPmodel;
122 
123 /* device parameters */
124 enum {
125     CAP_CAP = 1,
126     CAP_IC,
127     CAP_WIDTH,
128     CAP_LENGTH,
129     CAP_CAP_SENS,
130     CAP_CURRENT,
131     CAP_POWER,
132     CAP_TEMP,
133     CAP_DTEMP,
134     CAP_SCALE,
135     CAP_M,
136     CAP_TC1,
137     CAP_TC2,
138     CAP_BV_MAX,
139 };
140 
141 /* model parameters */
142 enum {
143     CAP_MOD_CJ = 101,
144     CAP_MOD_CJSW,
145     CAP_MOD_DEFWIDTH,
146     CAP_MOD_C,
147     CAP_MOD_NARROW,
148     CAP_MOD_SHORT,
149     CAP_MOD_DEL,
150     CAP_MOD_TC1,
151     CAP_MOD_TC2,
152     CAP_MOD_TNOM,
153     CAP_MOD_DI,
154     CAP_MOD_THICK,
155     CAP_MOD_CAP,
156     CAP_MOD_DEFLENGTH,
157     CAP_MOD_BV_MAX,
158 };
159 
160 /* device questions */
161 enum {
162     CAP_QUEST_SENS_REAL = 201,
163     CAP_QUEST_SENS_IMAG,
164     CAP_QUEST_SENS_MAG,
165     CAP_QUEST_SENS_PH,
166     CAP_QUEST_SENS_CPLX,
167     CAP_QUEST_SENS_DC,
168 };
169 
170 #include "capext.h"
171 
172 #endif /*CAP*/
173