1 function A=Udriftdiffusion(x,psi,coeff)
3 %A=Udriftdiffusion(x,psi,coeff)
5 % Builds the Scharfetter-Gummel approximation
6 % of the differential operator - (coeff (n' - n psi'))'
9 ## This file is part of
11 ## SECS1D - A 1-D Drift--Diffusion Semiconductor Device Simulator
12 ## -------------------------------------------------------------------
13 ## Copyright (C) 2004-2007 Carlo de Falco
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.
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.
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/>.
31 Nnodes =length(nodes);
33 elements = [[1:Nnodes-1]' [2:Nnodes]'];
34 Nelements=size(elements,1);
38 h=nodes(elements(:,2))-nodes(elements(:,1));
41 Bneg=Ubernoulli(-(psi(2:Nnodes)-psi(1:Nnodes-1)),1);
42 Bpos=Ubernoulli( (psi(2:Nnodes)-psi(1:Nnodes-1)),1);
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];
49 A = spdiags([dm1 d0 d1],-1:1,Nnodes,Nnodes);
53 % $Date: 2008-02-04 16:26:27 +0100 (man, 04 feb 2008) $