1 ## Copyright (C) 2006,2007,2008 Carlo de Falco
3 ## This file is part of:
4 ## OCS - A Circuit Simulator for Octave
6 ## OCS is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation.
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program (see the file LICENSE); if not,
17 ## see <http://www.gnu.org/licenses/>.
19 ## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
23 ## @deftypefn{Function File} @
24 ## {[@var{a},@var{b},@var{c}]=} Mcapacitors(@var{string},@var{parameters},@
25 ## @var{parameternames},@var{extvar},@var{intvar},@var{t})
27 ## SBN file implementing models for capacitors.
29 ## @var{string} is used to select among models. Parameters are listed
30 ## as inner items. Possible models are:
33 ## @item @var{string} = "LIN" (Linear Capacitor)
35 ## @item C -> capacitance value
37 ## @item @var{string} = "MULTICAP" (Multipole Capacitor)
39 ## @item C -> capacitance values
41 ## @item @var{string} = "PDE_NMOS" (Drift-Diffusion PDE NMOS capacitor)
43 ## @item tbulk -> bulk thickness
44 ## @item tox -> oxide thickness
45 ## @item Nnodes -> number of nodes of 1D grid
46 ## @item Na -> bulk doping
47 ## @item toll -> absolute tolerance
48 ## @item maxit -> max iterations number
49 ## @item Area -> device area
53 ## See the @cite{IFF file format specifications} for details about
54 ## the output structures.
56 ## @seealso{prs_iff,asm_initialize_system,asm_build_system}
59 function [a,b,c] = Mcapacitors(string,parameters,parameternames,extvar,intvar,t)
68 for ii=1:length(parameternames)
69 eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])
72 a = [0 0 1; 0 0 -1; 0 0 0];
73 b = [0 0 0;0 0 0;-C C 1];
80 C = reshape(parameters,n,n);
82 a = [zeros(n) eye(n); zeros(n) zeros(n)];
83 b = [zeros(n) zeros(n); -C eye(n)];
102 for ii=1:length(parameternames)
103 eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])
106 Vg = extvar(1) - extvar(2);
109 [Q,C]=Mnmoscap(tbulk,tox,Area,Vg,Na,Nnodes,toll,maxit);
111 a = [0 0 1; 0 0 -1; 0 0 0];
112 b = [0 0 0;0 0 0;C -C -1];
117 error (["unknown section:" string])
121 ## Non-linear 1D MOS structure.
122 ## FIXME: requires SECS1D!!!
123 function [Q,C]=Mnmoscap(tbulk,tox,Area,Vg,Na,Nnodes,toll,maxit);
127 Nelements = Nnodes - 1;
129 x = linspace(0,len,Nnodes)';
130 sinodes = find(x<=tbulk);
131 Nsinodes = length(sinodes);
132 NelementsSi = Nsinodes-1;
133 D = - Na* ones(Nsinodes,1);
135 p = pp* ones(Nsinodes,1);
140 V = -Phims + Vg * ones(Nnodes,1);
141 V(sinodes) = Fn + Vth*log(n/ni);
152 Fnin = (Fn - Vs * log(ni/ns))/Vs;
153 Fpin = (Fp + Vs * log(ni/ns))/Vs;
155 l2 = (Vs*esio2)/(q*ns*xs^2)* ones(Nelements,1);
156 l2(1:NelementsSi) = (Vs*esi)/(q*ns*xs^2);
158 ## Solution of Nonlinear Poisson equation
159 [V,nout,pout,res,niter] = DDGnlpoisson (xin,sinodes,Vin,nin,...
160 pin,Fnin,Fpin,Din,l2,...
163 L = Ucomplap(xin,Nnodes,[],Nelements,l2);
165 C12 = L(2:end-1,end);
166 C11 = L(2:end-1,2:end-1);
168 drdv = zeros(Nnodes,1); drdv(sinodes) = nout + pout;
169 coeff = zeros(Nelements,1); coeff(1:NelementsSi) = 1;
170 M = Ucompmass(xin,Nnodes,[],[],drdv,coeff);
171 C = C22 - C12'*((C11+M(2:end-1,2:end-1))\C12);
172 Q =(C12'*V(2:end-1)+C22*V(end));
175 C = Area*C*(q*ns*xs/Vs);
176 Q = Area*Q*(q*ns*xs);