1 function [odata,it,res] = DDNnewtonmap (x,idata,toll,maxit,verbose)
4 % [odata,it,res] = DDNnewtonmap (x,idata,toll,maxit,verbose)
6 % Solves the scaled stationary bipolar DD equation system
7 % using a coupled Newton algorithm
9 % input: x spatial grid
10 % idata.D doping profile
11 % idata.p initial guess for hole concentration
12 % idata.n initial guess for electron concentration
13 % idata.V initial guess for electrostatic potential
14 % idata.Fn initial guess for electron Fermi potential
15 % idata.Fp initial guess for hole Fermi potential
16 % idata.l2 scaled electric permittivity (diffusion coefficient in Poisson equation)
17 % idata.un scaled electron mobility
18 % idata.up scaled electron mobility
19 % idata.nis scaled intrinsic carrier density
20 % idata.tn scaled electron lifetime
21 % idata.tp scaled hole lifetime
22 % toll tolerance for Newton iterarion convergence test
23 % maxit maximum number of Newton iterarions
24 % verbose verbosity level: 0,1,2
26 % output: odata.n electron concentration
27 % odata.p hole concentration
28 % odata.V electrostatic potential
29 % odata.Fn electron Fermi potential
30 % odata.Fp hole Fermi potential
31 % it number of Newton iterations performed
32 % res residual at each step
34 ## This file is part of
36 ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
37 ## -------------------------------------------------------------------
38 ## Copyright (C) 2004-2007 Carlo de Falco
42 ## SECS1D is free software; you can redistribute it and/or modify
43 ## it under the terms of the GNU General Public License as published by
44 ## the Free Software Foundation; either version 2 of the License, or
45 ## (at your option) any later version.
47 ## SECS1D is distributed in the hope that it will be useful,
48 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
49 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 ## GNU General Public License for more details.
52 ## You should have received a copy of the GNU General Public License
53 ## along with SECS1D; If not, see <http://www.gnu.org/licenses/>.
60 elements=[1:Nnodes-1;2:Nnodes]';
61 BCnodesp = [1,Nnodes];
62 BCnodes = [BCnodesp,BCnodesp+Nnodes,BCnodesp+2*Nnodes];
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 %% create the complete unknown vector
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 L = Ucomplap (x,Nnodes,elements,Nelements,idata.l2*ones(Nelements,1));
82 M = Ucompmass (x,Nnodes,elements,Nelements,ones(Nnodes,1),ones(Nelements,1));
83 DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,V);
84 DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-V);
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 r1 = L * V + M * (n - p - D);
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 %%%%%%%%%%%%%%%%%%%%%%%
108 %% Begin Newton Cycle
109 %%%%%%%%%%%%%%%%%%%%%%%
112 fprintf (1,'\n\n\nNewton Iteration Number:%d\n',count);
114 Ln = Ucomplap (x,Nnodes,elements,Nelements,Umediaarmonica(idata.un*n));
115 Lp = Ucomplap (x,Nnodes,elements,Nelements,Umediaarmonica(idata.up*p));
116 Z = sparse(zeros(Nnodes));
117 DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,V);
118 DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-V);
130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143 %%%%%%%%%%%%%%%%%%%%%%%
144 % Solve the linearised system
145 %%%%%%%%%%%%%%%%%%%%%%%
146 dutmp = (LHS) \ (RHS);
147 dv = dutmp(1:totaldofs);
148 dn = dutmp(totaldofs+1:2*totaldofs);
149 dp = dutmp(2*totaldofs+1:3*totaldofs);
150 du = [0;dv;0;0;dn;0;0;dp;0];
152 %%%%%%%%%%%%%%%%%%%%%%%
154 %%%%%%%%%%%%%%%%%%%%%%%
158 nrm_du = norm(du,inf);
160 ratio = nrm_du/nrm_u;
162 fprintf (1,'ratio = %e\n', ratio);
167 n = u(Nnodes+1:2*Nnodes);
168 p = u(2*Nnodes+1:end);
174 %%%%%%%%%%%%%%%%%%%%%%
175 %% begin damping cycle
176 %%%%%%%%%%%%%%%%%%%%%%
182 fprintf (1,'\ndamping iteration number:%d\n',cc);
183 fprintf (1,'reference residual norm:%e\n',nrm);
185 %%%%%%%%%%%%%%%%%%%%%%%%%
186 % Update the unknown vector
187 %%%%%%%%%%%%%%%%%%%%%%%%%
189 Vnew = utmp(1:Nnodes);
190 nnew = utmp(Nnodes+1:2*Nnodes);
191 pnew = utmp(2*Nnodes+1:end);
196 DDn = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.un,1,Vnew);
197 DDp = Uscharfettergummel(x,Nnodes,elements,Nelements,idata.up,1,-Vnew);
199 r1 = L * V + M * (nnew - pnew - D);
209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214 nrmtmp=norm(RHS,inf);
216 %%%%%%%%%%%%%%%%%%%%%%%%%
217 %% Update the damping coefficient
218 %%%%%%%%%%%%%%%%%%%%%%%%
220 fprintf(1,'residual norm:%e\n\n', nrmtmp);
224 tj = tj/(dampcoef*cc);
226 fprintf (1,'\ndamping coefficients = %e',tj);
233 nrm_du = norm(tj*du,inf);
238 ratio = nrm_du/nrm_du_old;
241 n = u(Nnodes+1:2*Nnodes);
242 p = u(2*Nnodes+1:end);
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252 %% convert result vector into distinct output vectors
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 n = u(Nnodes+1:2*Nnodes);
257 p = u(2*Nnodes+1:end);