]> Creatis software - CreaPhase.git/blob - octave_packages/secs2d-0.0.8/DDGOX/DDGOXgummelmap.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / secs2d-0.0.8 / DDGOX / DDGOXgummelmap.m
1 function [odata,it,res] = DDGOXgummelmap (imesh,Dsides,...
2 Simesh,Sinodes,Sielements,SiDsides,...
3 idata,toll,maxit,ptoll,pmaxit,verbose)
4
5 % [odata,it,res] = DDGOXgummelmap (imesh,Dsides,...
6 %                           Simesh,Sinodes,Sielements,SiDsides,...
7 %                           idata,toll,maxit,ptoll,pmaxit,verbose) 
8 %
9
10 % This file is part of 
11 %
12 %            SECS2D - A 2-D Drift--Diffusion Semiconductor Device Simulator
13 %         -------------------------------------------------------------------
14 %            Copyright (C) 2004-2006  Carlo de Falco
15 %
16 %
17 %
18 %  SECS2D is free software; you can redistribute it and/or modify
19 %  it under the terms of the GNU General Public License as published by
20 %  the Free Software Foundation; either version 2 of the License, or
21 %  (at your option) any later version.
22 %
23 %  SECS2D is distributed in the hope that it will be useful,
24 %  but WITHOUT ANY WARRANTY; without even the implied warranty of
25 %  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26 %  GNU General Public License for more details.
27 %
28 %  You should have received a copy of the GNU General Public License
29 %  along with SECS2D; If not, see <http://www.gnu.org/licenses/>.
30
31 clear DDGOXNLPOISSON_LAP DDGOXNLPOISSON_MASS DDGOXNLPOISSON_RHS DDG_RHS DDG_MASS
32 global DDGOXNLPOISSON_LAP DDGOXNLPOISSON_MASS DDGOXNLPOISSON_RHS DDG_RHS DDG_MASS
33
34 %%%%%%%%%%%%%%%
35 %% RRE param %%
36 RREnnit      = [1,0];
37 RRErank      = 5;
38 RREpattern   = URREcyclingpattern(RREnnit,RRErank,maxit);
39 %%%%%%%%%%%%%%%
40
41 Nnodes     = max(size(imesh.p));
42 Nelements  = max(size(imesh.t));
43 SiNnodes     = max(size(Simesh.p));
44 SiNelements  = max(size(Simesh.t));
45
46 V (:,1) = idata.V;
47
48 p (:,1) = idata.p;
49
50 n (:,1) = idata.n;
51
52 Fn(:,1) = idata.Fn;
53 Fp(:,1) = idata.Fp;
54
55 D       = idata.D;
56
57 % Set list of nodes with Dirichelet BCs
58 Dnodes = Unodesonside(imesh,Dsides);
59
60 % Set list of nodes with Dirichelet BCs
61 SiDnodes = Unodesonside(Simesh,SiDsides);
62
63 nrm = 1;
64
65 for i=1:1:maxit
66     if (verbose>=1)
67         fprintf(1,'*****************************************************************\n');  
68         fprintf(1,'****    start of gummel iteration number: %d\n',i);
69         fprintf(1,'*****************************************************************\n');  
70         
71     end
72
73     if (verbose>=1)
74         fprintf(1,'solving non linear poisson equation\n');
75         if ((i>1)&(verbose>1))
76             DDGOXplotresults(imesh,Simesh,n(:,1)*idata.ns,p(:,1)*idata.ns,V(:,1)*idata.Vs,...
77             Fn(:,1)*idata.Vs,Fp(:,1)*idata.Vs,i,nrm(end),'poisson');
78         end
79     end
80     
81     
82     
83     [V(:,2),n(:,2),p(:,2)] =...
84         DDGOXnlpoisson (imesh,Dsides,Sinodes,SiDnodes,Sielements,...
85                         V(:,1),n(:,1),p(:,1),Fn(:,1),Fp(:,1),D,...
86                         idata.l2,idata.l2ox,ptoll,pmaxit,verbose-1);
87     V(Dnodes,2) = idata.V(Dnodes);
88     
89     if (verbose>=1)
90         fprintf (1,'***\nupdating electron qfl\n');
91         if ((i>1)&(verbose>1))
92             DDGOXplotresults(imesh,Simesh,n(:,2)*idata.ns,p(:,2)*idata.ns,...
93             V(:,2)*idata.Vs,Fn(:,1)*idata.Vs,Fp(:,1)*idata.Vs,i,nrm(end),'e- continuity');
94         end
95     end
96
97     mob = Ufielddepmob(Simesh,idata.un,Fn(:,1),idata.vsatn,idata.mubn);
98         
99     n(:,3) =DDGOXelectron_driftdiffusion(Simesh,SiDsides,n(:,2),p(:,2),...
100     V(Sinodes,2),mob,...
101     idata.tn,idata.tp,idata.ni,idata.ni);               
102     Fn(:,2)=V(Sinodes,2) - log(n(:,3));
103     n(SiDnodes,3) = idata.n(SiDnodes);
104     Fn(SiDnodes,2) = idata.Fn(SiDnodes);
105     
106     %%%% store result for RRE
107         if RREpattern(i)>0
108             Fnstore(:,RREpattern(i)) = Fn(:,2);
109             if RREpattern(i+1)==0 % Apply RRE extrapolation
110               if (verbose>=1)           
111                 fprintf(1,'\n**********\nRRE EXTRAPOLATION STEP\n**********\n');
112               end
113                 Fn(:,2) = Urrextrapolation(Fnstore);
114             end
115         end
116     
117     if (verbose>=1)
118         fprintf(1,'***\nupdating hole qfl\n');
119         if ((i>1)&(verbose>1))          
120             DDGOXplotresults(imesh,Simesh,n(:,3)*idata.ns,p(:,2)*idata.ns,V(:,2)*idata.Vs,...
121             Fn(:,2)*idata.Vs,Fp(:,1)*idata.Vs,i,nrm(end),'h+ continuity');
122         end
123     end
124     
125         mob = Ufielddepmob(Simesh,idata.up,Fp(:,1),idata.vsatp,idata.mubp);
126         p(:,3) =DDGOXhole_driftdiffusion(Simesh,SiDsides,n(:,3),p(:,2),...
127         V(Sinodes,2),mob,...
128         idata.tn,idata.tp,idata.ni,idata.ni);
129         Fp(:,2)= V(Sinodes,2) + log(p(:,3));
130         p(SiDnodes,3) = idata.p(SiDnodes);
131         Fp(SiDnodes,2) = idata.Fp(SiDnodes);
132
133     if (verbose>=1)
134         fprintf(1,'checking for convergence\n');
135     end
136
137     nrfn= norm(Fn(:,2)-Fn(:,1),inf);
138     nrfp= norm (Fp(:,2)-Fp(:,1),inf);
139     nrv = norm (V(:,2)-V(:,1),inf);
140     nrm(i) = max([nrfn;nrfp;nrv]);
141     
142     if (verbose>1)
143     figure(2);
144     semilogy(nrm)
145     pause(.1)
146     end
147     
148     if (verbose>=1)
149         fprintf (1,' max(|phin_(k+1)-phinn_(k)| ,...\n |phip_(k+1)-phip_(k)| ,...\n |v_(k+1)- v_(k)| )= %g\n',nrm(i));
150     end
151     if (nrm(i)<toll)
152         break
153     end
154
155     V(:,1) = V(:,end);
156     n(:,1) = n(:,end);
157     p(:,1) = p(:,end);
158     Fn(:,1)= Fn(:,end);
159     Fp(:,1)= Fp(:,end);
160     
161     
162 end
163
164 it = i;
165 res = nrm;
166
167 if (verbose>0)
168     fprintf(1,'\n***********\nDD simulation over:\n # of Gummel iterations = %d\n\n',it);
169 end
170
171 odata = idata;
172
173 odata.n  = n(:,end);
174 odata.p  = p(:,end);
175 odata.V  = V(:,end);
176 odata.Fn = Fn(:,end);
177 odata.Fp = Fp(:,end);