1 /**********
2 Copyright 1991 Regents of the University of California. All rights reserved.
3 Authors: 1987 Karti Mayaram, 1991 David Gates
4 **********/
5 
6 /* Member of CIDER device simulator
7  * Version: 1b1
8  */
9 
10 /*
11  * Two-Dimensional Element-based Simulation-Mesh Data Structures
12  */
13 
14 #ifndef ngspice_TWOMESH_H
15 #define ngspice_TWOMESH_H
16 
17 #include "ngspice/material.h"
18 
19 typedef struct sTWOelem
20 {
21     struct sTWOelem *pElems[4];     /* array to store the element neighbors */
22     struct sTWOnode *pNodes[4];     /* array to store the element nodes */
23     struct sTWOedge *pEdges[4];     /* array to store the edges */
24     double dx;                      /* the x length */
25     double dy;                      /* the y length */
26     double dxOverDy;                /* dX / dY */
27     double dyOverDx;                /* dY / dX */
28     int domain;                     /* device domain owning element */
29     int elemType;                   /* material type of element */
30     TWOmaterial *matlInfo;          /* material information */
31     double epsRel;                  /* relative epsilon */
32 /* Values needed to calc. mobility and its derivatives at element center */
33     double mun0, mup0;              /* temp. and doping-dep. mobilities */
34     double mun, mup;                /* field and carrier-dep. mobilities */
35     double dMunDEs, dMupDEs;        /* Mob Deriv surf EFIELD Comp */
36     double dMunDEx, dMupDEx;        /* Mob Deriv x EFIELD Comp */
37     double dMunDEy, dMupDEy;        /* Mob Deriv y EFIELD Comp */
38     double dMunDWx, dMupDWx;        /* Mob Deriv x WDF Comp */
39     double dMunDWy, dMupDWy;        /* Mob Deriv y WDF Comp */
40     double dMunDN,  dMupDN;	    /* Mob Deriv nConc Comp */
41     double dMunDP,  dMupDP;	    /* Mob Deriv pConc Comp */
42     unsigned surface : 1;           /* flag to indicate surface elem */
43     int channel;	            /* id of channel elem is in, 0 is none */
44     int direction;		    /* direction of flow for channels */
45     int evalNodes[4];               /* nodes to be evaluated in elem */
46     int evalEdges[4];               /* edges to be evaluated in elem */
47 } TWOelem;
48 
49 #define pTopElem   pElems[0]
50 #define pRightElem pElems[1]
51 #define pBotElem   pElems[2]
52 #define pLeftElem  pElems[3]
53 
54 #define pTLNode pNodes[0]
55 #define pTRNode pNodes[1]
56 #define pBRNode pNodes[2]
57 #define pBLNode pNodes[3]
58 
59 #define pTopEdge   pEdges[0]
60 #define pRightEdge pEdges[1]
61 #define pBotEdge   pEdges[2]
62 #define pLeftEdge  pEdges[3]
63 
64 typedef struct sTWOedge
65 {
66     int edgeType;                    /* boundary type of edge */
67     double dPsi;                     /* deltaPsi */
68     double jn;                       /* electron current */
69     double jp;                       /* hole current */
70     double jd;                       /* displacement current */
71     double dJnDpsiP1;                /* dJn/dPsi(+1) */
72     double dJnDn;                    /* dJnx/dN */
73     double dJnDnP1;                  /* dJn/dN(+1) */
74     double dJpDpsiP1;                /* dJpx/dPsi(+1) */
75     double dJpDp;                    /* dJpx/dP */
76     double dJpDpP1;                  /* dJpxDp(+1) */
77     double dCBand;                   /* effective delta conduction band */
78     double dVBand;                   /* effective delta valence band */
79     double qf;                       /* fixed charge density */
80   /* Terms to find weighted carrier driving force and its derivatives */
81     double wdfn;                     /* N weighted driving force */
82     double wdfp;                     /* P weighted driving force */
83     double dWnDpsiP1;                /* dWn/dPsi(+1) */
84     double dWnDn;                    /* dWn/dN */
85     double dWnDnP1;                  /* dWn/dN(+1) */
86     double dWpDpsiP1;                /* dWp/dPsi(+1) */
87     double dWpDp;                    /* dWp/dP */
88     double dWpDpP1;                  /* dWp/dP(+1) */
89   /* Coefficients for weighting mobility on sides of edges */
90     double kNeg;		     /* Spline for negative side of edge */
91     double kPos;		     /* Spline for positive side of edge */
92 
93     int edgeState;                   /* pointer to state vector */
94     unsigned evaluated : 1;          /* flag to indicated evaluated */
95 } TWOedge;
96 
97 typedef struct sTWOnode {
98     int nodeType;                    /* type of node */
99     int nodeI;                       /* node x-index */
100     int nodeJ;                       /* node y-index */
101     int poiEqn;			     /* equation number for equilib poisson */
102     int psiEqn;			     /* equation number for bias poisson */
103     int nEqn;			     /* equation number for n continuity */
104     int pEqn;			     /* equation number for p continuity */
105     struct sTWOelem *pElems[4];      /* array of elements */
106     double psi0;                     /* equilibrium potential */
107     double psi;                      /* electrostatic potential */
108     double nConc;                    /* electron conc. */
109     double pConc;                    /* hole conc. */
110     double nie;                      /* effective intrinsic carrier conc. */
111     double eg;                       /* energy gap */
112     double eaff;                     /* electron affinity; work phi for metal*/
113     double tn;                       /* electron lifetime */
114     double tp;                       /* hole lifetime */
115     double netConc;                  /* net doping conc. */
116     double totalConc;                /* total doping conc. */
117     double na;                       /* acceptor conc. */
118     double nd;                       /* donor conc. */
119     double nPred;                    /* predicted electron conc. */
120     double pPred;                    /* predicted hole conc. */
121     double uNet;                     /* net recombination rate */
122     double dUdN;                     /* dU / dN */
123     double dUdP;                     /* dU / dP */
124     double dNdT;                     /* dN / dT */
125     double dPdT;                     /* dP / dT */
126     int nodeState;                   /* pointer to the state vector */
127     unsigned evaluated : 1;          /* flag to indicated evaluated */
128     /* sparse matrix pointers. pointers to doubles */
129     /* DAG: diagonal pointers fXXiX1jX1 */
130     double *fPsiPsiiM1;
131     double *fPsiPsi;
132     double *fPsiPsiiP1;
133     double *fPsiPsijM1;
134     double *fPsiPsijP1;
135     double *fPsiN;
136     double *fPsiP;
137     double *fNPsiiM1;
138     double *fNPsi;
139     double *fNPsiiP1;
140     double *fNPsijM1;
141     double *fNPsijP1;
142     double *fNPsiiM1jM1;
143     double *fNPsiiM1jP1;
144     double *fNPsiiP1jM1;
145     double *fNPsiiP1jP1;
146     double *fNNiM1;
147     double *fNN;
148     double *fNNiP1;
149     double *fNNjM1;
150     double *fNNjP1;
151     double *fNNiM1jM1;
152     double *fNNiM1jP1;
153     double *fNNiP1jM1;
154     double *fNNiP1jP1;
155     double *fNP;
156     double *fPPsiiM1;
157     double *fPPsi;
158     double *fPPsiiP1;
159     double *fPPsijM1;
160     double *fPPsijP1;
161     double *fPPsiiM1jM1;
162     double *fPPsiiM1jP1;
163     double *fPPsiiP1jM1;
164     double *fPPsiiP1jP1;
165     double *fPPiM1;
166     double *fPP;
167     double *fPPiP1;
168     double *fPPjM1;
169     double *fPPjP1;
170     double *fPPiM1jM1;
171     double *fPPiM1jP1;
172     double *fPPiP1jM1;
173     double *fPPiP1jP1;
174     double *fPN;
175     /* DAG: Pointers for Surface-Field-Dependent Terms */
176     /* For Oxide/Insulator on Silicon/Semiconductor:
177                    Ox
178       OxM1 + ----- + ----- + OxP1		OXIDE
179            |       |       |
180            |       |       |
181     - InM1 + ----- + ----- + InP1 ---		INTERFACE
182                    In
183     */
184     double *fNPsiInM1;
185     double *fNPsiIn;
186     double *fNPsiInP1;
187     double *fNPsiOxM1;
188     double *fNPsiOx;
189     double *fNPsiOxP1;
190     double *fPPsiInM1;
191     double *fPPsiIn;
192     double *fPPsiInP1;
193     double *fPPsiOxM1;
194     double *fPPsiOx;
195     double *fPPsiOxP1;
196 } TWOnode;
197 
198 #define pTLElem pElems[0]
199 #define pTRElem pElems[1]
200 #define pBRElem pElems[2]
201 #define pBLElem pElems[3]
202 
203 #define nodePsi   nodeState
204 #define nodeN     nodeState+1
205 #define nodeP     nodeState+3
206 
207 #define edgeDpsi  edgeState
208 
209 #define TWOnumNodeStates 5
210 #define TWOnumEdgeStates 2
211 
212 #endif
213