]> Creatis software - CreaPhase.git/blob - octave_packages/secs1d-0.0.8/DDG/DDGhole_driftdiffusion.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / secs1d-0.0.8 / DDG / DDGhole_driftdiffusion.m
1 function p=DDGhole_driftdiffusion(psi,x,pg,n,ni,tn,tp,up)
2
3 % p=DDGhole_driftdiffusion(psi,x,pg,n)
4 %     Solves the continuity equation for holes
5 %     input:  psi     electric potential
6 %             x       spatial grid
7 %             pg      initial guess and BCs for hole density
8 %             n       electron density (to compute SRH recombination)
9 %     output: p       updated hole density
10
11
12 ## This file is part of 
13 ##
14 ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
15 ## -------------------------------------------------------------------
16 ## Copyright (C) 2004-2007  Carlo de Falco
17 ##
18 ##
19 ##
20 ##  SECS1D is free software; you can redistribute it and/or modify
21 ##  it under the terms of the GNU General Public License as published by
22 ##  the Free Software Foundation; either version 2 of the License, or
23 ##  (at your option) any later version.
24 ##
25 ##  SECS1D is distributed in the hope that it will be useful,
26 ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
27 ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28 ##  GNU General Public License for more details.
29 ##
30 ##  You should have received a copy of the GNU General Public License
31 ##  along with SECS1D; If not, see <http://www.gnu.org/licenses/>.
32
33
34 nodes        = x;
35 Nnodes     =length(nodes);
36
37 elements   = [[1:Nnodes-1]' [2:Nnodes]'];
38 Nelements=size(elements,1);
39
40 Bcnodes = [1;Nnodes];
41
42 pl = pg(1);
43 pr = pg(Nnodes);
44
45 h=nodes(elements(:,2))-nodes(elements(:,1));
46
47 c=up./h;
48 Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
49 Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
50
51
52 d0    = [c(1).*Bpos(1); c(1:end-1).*Bneg(1:end-1)+c(2:end).*Bpos(2:end); c(end)*Bneg(end)];
53 d1    = [1000;-c.* Bneg];
54 dm1   = [-c.* Bpos;1000];
55
56 A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
57 b = zeros(Nnodes,1);% - A * pg;
58
59 % SRH Recombination term
60 SRHD = tp * (n + ni) + tn * (pg + ni);
61 SRHL = n ./ SRHD;
62 SRHR = ni.^2 ./ SRHD;
63
64 ASRH = Ucompmass (nodes,Nnodes,elements,Nelements,SRHL,ones(Nelements,1));
65 bSRH = Ucompconst (nodes,Nnodes,elements,Nelements,SRHR,ones(Nelements,1));
66
67 A = A + ASRH;
68 b = b + bSRH;
69
70 % Boundary conditions
71 b(Bcnodes)   = [];
72 b(1)         = - A(2,1) * pl;
73 b(end)       = - A(end-1,end) * pr;
74 A(Bcnodes,:) = [];
75 A(:,Bcnodes) = [];
76
77 p = [pl; A\b ;pr];
78
79 % Last Revision:
80 % $Author: adb014 $
81 % $Date: 2008-02-04 16:26:27 +0100 (man, 04 feb 2008) $
82
83