]> Creatis software - CreaPhase.git/blob - octave_packages/secs1d-0.0.8/DDG/DDGelectron_driftdiffusion.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / secs1d-0.0.8 / DDG / DDGelectron_driftdiffusion.m
1 function n=DDGelectron_driftdiffusion(psi,x,ng,p,ni,tn,tp,un)
2   
3 % n=DDGelectron_driftdiffusion(psi,x,ng,p)
4 %     Solves the continuity equation for electrons
5 %     input:  psi   electric potential
6 %               x     integration domain
7 %             ng    initial guess and BCs for electron density
8 %             p     hole density (for SRH recombination)
9 %     output: n     updated electron density
10   
11 ## This file is part of 
12 ##
13 ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
14 ## -------------------------------------------------------------------
15 ## Copyright (C) 2004-2007  Carlo de Falco
16 ##
17 ##
18 ##
19 ##  SECS1D 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 ##  SECS1D 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 SECS1D; If not, see <http://www.gnu.org/licenses/>.
31
32
33 nodes        = x;
34 Nnodes     =length(nodes);
35
36 elements   = [[1:Nnodes-1]' [2:Nnodes]'];
37 Nelements=size(elements,1);
38
39 Bcnodes = [1;Nnodes];
40
41 nl = ng(1);
42 nr = ng(Nnodes);
43
44 h=nodes(elements(:,2))-nodes(elements(:,1));
45
46 c=1./h;
47 Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
48 Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
49
50
51 d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
52 d1    = [1000;-c.* Bpos];
53 dm1   = [-c.* Bneg;1000];
54
55 A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
56 b = zeros(Nnodes,1);%- A * ng;
57
58 % SRH Recombination term
59 SRHD = tp * (ng + ni) + tn * (p + ni);
60 SRHL = p ./ SRHD;
61 SRHR = ni.^2 ./ SRHD;
62
63 ASRH = Ucompmass (nodes,Nnodes,elements,Nelements,SRHL,ones(Nelements,1));
64 bSRH = Ucompconst (nodes,Nnodes,elements,Nelements,SRHR,ones(Nelements,1));
65
66 A = A + ASRH;
67 b = b + bSRH;
68
69 % Boundary conditions
70 b(Bcnodes)   = [];
71 b(1)         = - A(2,1) * nl;
72 b(end)       = - A(end-1,end) * nr;
73 A(Bcnodes,:) = [];
74 A(:,Bcnodes) = [];
75
76 n = [nl; A\b ;nr];
77
78
79 % Last Revision:
80 % $Author: adb014 $
81 % $Date: 2008-02-04 16:26:27 +0100 (man, 04 feb 2008) $
82