]> Creatis software - CreaPhase.git/blob - octave_packages/secs1d-0.0.8/DDG/DDGgummelmap.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / secs1d-0.0.8 / DDG / DDGgummelmap.m
1 function [odata,it,res] =...
2       DDGgummelmap (x,idata,toll,maxit,ptoll,pmaxit,verbose)
3
4  
5 %
6 % [odata,it,res] =...
7 %            DDGgummelmap (x,idata,toll,maxit,ptoll,pmaxit,verbose)
8 %
9 % Solves the scaled stationary bipolar DD equation system
10 %     using Gummel algorithm
11 %
12 %     input: x          spatial grid
13 %            idata.D    doping profile
14 %            idata.p    initial guess for hole concentration
15 %            idata.n    initial guess for electron concentration
16 %            idata.V    initial guess for electrostatic potential
17 %            idata.Fn   initial guess for electron Fermi potential
18 %            idata.Fp   initial guess for hole Fermi potential
19 %            idata.l2   scaled electric permittivity (diffusion coefficient in Poisson equation)
20 %            idata.un   scaled electron mobility
21 %            idata.up   scaled electron mobility
22 %            idata.nis  scaled intrinsic carrier density
23 %            idata.tn   scaled electron lifetime
24 %            idata.tp   scaled hole lifetime
25 %            toll       tolerance for Gummel iterarion convergence test
26 %            maxit      maximum number of Gummel iterarions
27 %            ptoll      tolerance for Newton iterarion convergence test for non linear Poisson
28 %            pmaxit     maximum number of Newton iterarions
29 %            verbose    verbosity level: 0,1,2
30 %
31 %     output: odata.n     electron concentration
32 %             odata.p     hole concentration
33 %             odata.V     electrostatic potential
34 %             odata.Fn    electron Fermi potential
35 %             odata.Fp    hole Fermi potential
36 %             it          number of Gummel iterations performed
37 %             res         total potential increment at each step
38
39 ## This file is part of 
40 ##
41 ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
42 ## -------------------------------------------------------------------
43 ## Copyright (C) 2004-2007  Carlo de Falco
44 ##
45 ##
46 ##
47 ##  SECS1D is free software; you can redistribute it and/or modify
48 ##  it under the terms of the GNU General Public License as published by
49 ##  the Free Software Foundation; either version 2 of the License, or
50 ##  (at your option) any later version.
51 ##
52 ##  SECS1D is distributed in the hope that it will be useful,
53 ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
54 ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55 ##  GNU General Public License for more details.
56 ##
57 ##  You should have received a copy of the GNU General Public License
58 ##  along with SECS1D; If not, see <http://www.gnu.org/licenses/>.
59
60
61 odata = idata;
62
63 Nnodes=rows(x);
64
65 D         = idata.D;
66 vout(:,1) = idata.V;
67 hole_density (:,1) = idata.p;
68 electron_density (:,1)= idata.n;
69 fermin (:,1)=idata.Fn;
70 fermip (:,1)=idata.Fp;
71
72 for i=1:1:maxit
73         if (verbose>1)
74                 fprintf(1,'*****************************************************************\n');  
75                 fprintf(1,'****    start of gummel iteration number: %d\n',i);
76                 fprintf(1,'*****************************************************************\n');  
77     end
78
79         if (verbose>1)
80                 fprintf(1,'solving non linear poisson equation\n\n');
81     end
82         [vout(:,2),electron_density(:,2),hole_density(:,2)] =...
83         DDGnlpoisson (x,[1:Nnodes],vout (:,1),electron_density(:,1),hole_density(:,1),...
84         fermin(:,1),fermip(:,1),D,idata.l2,ptoll,pmaxit,verbose);
85         
86         if (verbose>1)
87                 fprintf (1,'\n\nupdating electron qfl\n\n');
88     end
89         electron_density(:,3)=...
90         DDGelectron_driftdiffusion(vout(:,2), x, electron_density(:,2),hole_density(:,2),idata.nis,idata.tn,idata.tp,idata.un);
91     
92     fermin(:,2) = DDGn2phin(vout(:,2),electron_density(:,3));
93     fermin(1,2)   = idata.Fn(1);
94     fermin(end:2) = idata.Fn(end);
95     
96         if (verbose>1)
97                 fprintf(1,'updating hole qfl\n\n');
98     end
99
100         hole_density(:,3)=...
101     DDGhole_driftdiffusion(vout(:,2), x, hole_density(:,2),electron_density(:,2),idata.nis,idata.tn,idata.tp,idata.up);
102     fermip(:,2) = DDGp2phip(vout(:,2),hole_density(:,3));
103     fermip(1,2)   = idata.Fp(1);
104     fermip(end,2) = idata.Fp(end);
105     
106     if (verbose>1)
107                 fprintf(1,'checking for convergence\n\n');
108     end
109         nrfn= norm(fermin(:,2)-fermin(:,1),inf);
110         nrfp= norm (fermip(:,2)-fermip(:,1),inf);
111         nrv = norm (vout(:,2)-vout(:,1),inf);
112         nrm(i) = max([nrfn;nrfp;nrv]);
113         
114         if (verbose>1)
115                 fprintf (1,' max(|phin_(k+1)-phinn_(k)| , |phip_(k+1)-phip_(k)| , |v_(k+1)- v_(k)| )= %d\n',nrm(i));
116     end
117         if (nrm(i)<toll)
118                 break
119     end
120
121         vout(:,1) = vout(:,end);
122         hole_density (:,1) = hole_density (:,end) ;
123         electron_density (:,1)= electron_density (:,end);
124         fermin (:,1)= fermin (:,end);
125         fermip (:,1)= fermip (:,end);
126         
127         
128         if(verbose)
129                 DDGplotresults(x,electron_density,hole_density,vout,fermin,fermip);             
130     end
131 end
132
133 it = i;
134 res = nrm;
135
136 if (verbose>0)
137         fprintf(1,'\n\nInitial guess computed by DD: # of Gummel iterations = %d\n\n',it);
138 end
139
140 odata.n     = electron_density(:,end);
141 odata.p     = hole_density(:,end);
142 odata.V     = vout(:,end);
143 odata.Fn    = fermin(:,end);
144 odata.Fp    = fermip(:,end);
145
146
147