]> Creatis software - CreaPhase.git/blob - octave_packages/secs1d-0.0.8/Utilities/Udriftdiffusion.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / secs1d-0.0.8 / Utilities / Udriftdiffusion.m
1 function A=Udriftdiffusion(x,psi,coeff)  
2   
3 %A=Udriftdiffusion(x,psi,coeff)
4 %
5 % Builds the Scharfetter-Gummel approximation
6 % of the differential operator - (coeff (n' - n psi'))' 
7 %
8
9  ## This file is part of 
10   ##
11   ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
12   ## -------------------------------------------------------------------
13   ## Copyright (C) 2004-2007  Carlo de Falco
14   ##
15   ##
16   ##
17   ##  SECS1D is free software; you can redistribute it and/or modify
18   ##  it under the terms of the GNU General Public License as published by
19   ##  the Free Software Foundation; either version 2 of the License, or
20   ##  (at your option) any later version.
21   ##
22   ##  SECS1D is distributed in the hope that it will be useful,
23   ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
24   ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25   ##  GNU General Public License for more details.
26   ##
27   ##  You should have received a copy of the GNU General Public License
28   ##  along with SECS1D; If not, see <http://www.gnu.org/licenses/>.
29   
30   nodes        = x;
31   Nnodes     =length(nodes);
32   
33   elements   = [[1:Nnodes-1]' [2:Nnodes]'];
34   Nelements=size(elements,1);
35   
36   Bcnodes = [1;Nnodes];
37   
38   h=nodes(elements(:,2))-nodes(elements(:,1));
39   
40   c=coeff./h;
41   Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
42   Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
43   
44   
45   d0    = [c(1).*Bneg(1); c(1:end-1).*Bpos(1:end-1)+c(2:end).*Bneg(2:end); c(end)*Bpos(end)];
46   d1    = [1000;-c.* Bpos];
47   dm1   = [-c.* Bneg;1000];
48   
49   A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
50   
51   % Last Revision:
52   % $Author: adb014 $
53   % $Date: 2008-02-04 16:26:27 +0100 (man, 04 feb 2008) $
54