1 function c=Udriftdiffusion(mesh,Dsides,guess,M,U,V,u)
4 % c=Udriftdiffusion(mesh,Dsides,guess,M,U,V,u)
5 % solves the drift diffusion equation
6 % $ -div ( u ( \nabla n - n \nabla V)) + M = U $
11 % SECS2D - A 2-D Drift--Diffusion Semiconductor Device Simulator
12 % -------------------------------------------------------------------
13 % Copyright (C) 2004-2006 Carlo de Falco
17 % SECS2D 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 % SECS2D 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 SECS2D; If not, see <http://www.gnu.org/licenses/>.
30 global DDG_RHS DDG_MASS %DEBUG_SGM
33 if (Ucolumns(guess)>Urows(guess))
37 if (Ucolumns(V)>Urows(V))
41 if (Ucolumns(U)>Urows(U))
44 Nnodes = max(size(mesh.p));
45 Nelements = max(size(mesh.t));
48 % Set list of nodes with Dirichelet BCs
49 Dnodes=Unodesonside(mesh,Dsides);
51 % Set values of Dirichelet BCs
53 % Set list of nodes without Dirichelet BCs
54 Varnodes = setdiff([1:Nnodes],Dnodes);
57 % Build LHS matrix and RHS
58 A = Uscharfettergummel(mesh,V,u);
59 if (isempty(DDG_MASS))
60 DDG_MASS=Ucompmass2(mesh,ones(Nnodes,1),ones(Nelements,1));
62 A = A + DDG_MASS.*spdiag(M,0);
65 DDG_RHS=Ucompconst(mesh,ones(Nnodes,1),ones(Nelements,1));
71 %%%%%%%%DEBUG%%%%%%%%%%%
74 %% Apply boundary conditions
77 b = b - A (:,Dnodes) * Bc;
86 % edA= abs(sum(triu(A,1)+tril(A,-1),1));
87 % nondominant = find(dA < edA');
88 % for ii=1:length(nondominant)
89 % A(nondominant(ii),nondominant(ii)) = edA(ii);