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