Function File: S = Uscharfettergummel3 (mesh, alpha, gamma, eta, beta)
Builds the Scharfetter-Gummel matrix for the discretization of the LHS of the equation:
where:
- alpha is an element-wise constant scalar function
- eta, gamma are piecewise linear conforming scalar functions
- beta is an element-wise constant vector function
Instead of passing the vector field beta directly one can pass a piecewise linear conforming scalar function phi as the last input. In such case beta = grad phi is assumed. If phi is a single scalar value beta is assumed to be 0 in the whole domain.
Example:
[mesh.p,mesh.e,mesh.t] = Ustructmesh([0:1/3:1],[0:1/3:1],1,1:4); mesh = Umeshproperties(mesh); x = mesh.p(1,:)'; Dnodes = Unodesonside(mesh,[2,4]); Nnodes = columns(mesh.p); Nelements = columns(mesh.t); Varnodes = setdiff(1:Nnodes,Dnodes); alpha = ones(Nelements,1); eta = .1*ones(Nnodes,1); beta = [ones(1,Nelements);zeros(1,Nelements)]; gamma = ones(Nnodes,1); f = Ucompconst(mesh,ones(Nnodes,1),ones(Nelements,1)); S = Uscharfettergummel3(mesh,alpha,gamma,eta,beta); u = zeros(Nnodes,1); u(Varnodes) = S(Varnodes,Varnodes)\f(Varnodes); uex = x - (exp(10*x)-1)/(exp(10)-1); assert(u,uex,1e-7)