]> Creatis software - CreaPhase.git/blob - octave_packages/secs2d-0.0.8/Utilities/Ufvsgcurrent2.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / secs2d-0.0.8 / Utilities / Ufvsgcurrent2.m
1 function [jx,jy]=Ufvsgcurrent2(omesh,n,psi,psith,coeffe);
2
3   %% [jx,jy]=Udrawcurrent2(omesh,n,psi,psith,coeffe);
4   
5   %% This file is part of 
6   %%
7   %%            SECS2D - A 2-D Drift--Diffusion Semiconductor Device Simulator
8   %%         -------------------------------------------------------------------
9   %%            Copyright (C) 2004-2006  Carlo de Falco
10   %%
11   %%
12   %%
13   %%  SECS2D is free software; you can redistribute it and/or modify
14   %%  it under the terms of the GNU General Public License as published by
15   %%  the Free Software Foundation; either version 2 of the License, or
16   %%  (at your option) any later version.
17   %%
18   %%  SECS2D is distributed in the hope that it will be useful,
19   %%  but WITHOUT ANY WARRANTY; without even the implied warranty of
20   %%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21   %%  GNU General Public License for more details.
22   %%
23   %%  Youx should have received a copy of the GNU General Public License
24   %%  along with SECS2D; If not, see <http://www.gnu.org/licenses/>.
25   
26   Nelem = size(omesh.t,2);
27   jx = NaN*ones(Nelem,1);
28   jy = jx;
29   coeffe = coeffe';
30   %%for iel=1:Nelem
31   
32   
33   dpsi1 = (psi(omesh.t(3,:))-psi(omesh.t(2,:)))';
34   dvth1 = (psith(omesh.t(3,:))-psith(omesh.t(2,:)))';
35   vthm1 = Utemplogm(psith(omesh.t(3,:)),psith(omesh.t(2,:)))';
36   [bp,bn] = Ubern((dpsi1-dvth1)./vthm1);
37   t1x    = omesh.p(1,omesh.t(3,:))-omesh.p(1,omesh.t(2,:));
38   t1y    = omesh.p(2,omesh.t(3,:))-omesh.p(2,omesh.t(2,:));
39   l1     = sqrt(t1x.^2+t1y.^2);
40   t1x    = t1x./l1;
41   t1y    = t1y./l1;
42
43   j1x    = vthm1.*(coeffe./l1) .* ( n(omesh.t(3,:))' .* bp - ...
44                                    n(omesh.t(2,:))' .* bn) .* t1x;
45   j1y    = vthm1.*(coeffe./l1) .* ( n(omesh.t(3,:))' .* bp - ...
46                                    n(omesh.t(2,:))' .* bn) .* t1y;
47   gg1= -reshape(omesh.shg(1,2,:).*omesh.shg(1,3,:)+...
48                 omesh.shg(2,2,:).*omesh.shg(2,3,:),1,[]).*l1.^2;
49   
50   dpsi2 = (psi(omesh.t(1,:))-psi(omesh.t(3,:)))';
51   dvth2 = (psith(omesh.t(1,:))-psith(omesh.t(3,:)))';
52   vthm2 = Utemplogm(psith(omesh.t(1,:)),psith(omesh.t(3,:)))';
53   [bp,bn] = Ubern((dpsi2-dvth2)./vthm2);
54   t2x = omesh.p(1,omesh.t(1,:))-omesh.p(1,omesh.t(3,:));
55   t2y = omesh.p(2,omesh.t(1,:))-omesh.p(2,omesh.t(3,:));
56   l2 = sqrt(t2x.^2+t2y.^2);
57   t2x = t2x./l2;
58   t2y = t2y./l2;
59   j2x = vthm2.*(coeffe./l2) .* ( n(omesh.t(1,:))' .* bp - ...
60                                 n(omesh.t(3,:))' .* bn) .* t2x;
61   j2y = vthm2.*(coeffe./l2) .* ( n(omesh.t(1,:))' .* bp - ...
62                                 n(omesh.t(3,:))' .* bn) .* t2y;
63   gg2= -reshape(omesh.shg(1,1,:).*omesh.shg(1,3,:)+...
64                 omesh.shg(2,1,:).*omesh.shg(2,3,:),1,[]).*l2.^2;
65   
66   dpsi3 = (psi(omesh.t(2,:))-psi(omesh.t(1,:)))';
67   dvth3 = (psith(omesh.t(2,:))-psith(omesh.t(1,:)))';
68   vthm3 = Utemplogm(psith(omesh.t(2,:)),psith(omesh.t(1,:)))';
69   [bp,bn] = Ubern((dpsi3-dvth3)./vthm3);
70   t3x = omesh.p(1,omesh.t(2,:))-omesh.p(1,omesh.t(1,:));
71   t3y = omesh.p(2,omesh.t(2,:))-omesh.p(2,omesh.t(1,:));
72   l3  = sqrt(t3x.^2+t3y.^2);
73   t3x = t3x./l3;
74   t3y = t3y./l3;
75   j3x = vthm3.*(coeffe./l3) .* ( n(omesh.t(2,:))' .* bp - ...
76                                 n(omesh.t(1,:))' .* bn) .* t3x;
77   j3y = vthm3.*(coeffe./l3) .* ( n(omesh.t(2,:))' .* bp - ...
78                                 n(omesh.t(1,:))' .* bn) .* t3y;
79   gg3= -reshape(omesh.shg(1,2,:).*omesh.shg(1,1,:)+...
80                 omesh.shg(2,2,:).*omesh.shg(2,1,:),1,[]).*l3.^2;
81   
82   jx = j1x.*gg1+j2x.*gg2+j3x.*gg3;
83   jy = j1y.*gg1+j2y.*gg2+j3y.*gg3;
84   
85   %%end
86