]> Creatis software - CreaPhase.git/blob - octave_packages/ocs-0.1.3/sbn/Mdiode.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / ocs-0.1.3 / sbn / Mdiode.m
1 ## Copyright (C) 2006,2007,2008  Massimiliano Culpo, Carlo de Falco            
2 ##
3 ## This file is part of:
4 ## OCS - A Circuit Simulator for Octave
5 ##
6 ## OCS is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program (see the file LICENSE); if not,
17 ## see <http://www.gnu.org/licenses/>.
18 ##
19 ## author: culpo@math.uni-wuppertal.de, Carlo de Falco <cdf _AT_ users.sourceforge.net> 
20
21 ## -*- texinfo -*-
22 ##
23 ## @deftypefn{Function File} @
24 ## {[@var{a},@var{b},@var{c}]=}Mdiode(@var{string},@var{parameters},@
25 ## @var{parameternames},@var{extvar},@var{intvar},@var{t})
26 ##
27 ## SBN file implementing models for diodes.
28 ##
29 ## @var{string} is used to select among models. Parameters are listed
30 ## as inner items. Possible models are:
31 ##
32 ## @itemize @minus
33 ## @item @var{string} = "simple" (Usual exponential diode model)
34 ## @itemize @minus
35 ## @item Is   -> reverse current
36 ## @item Vth  -> thermal voltage
37 ## @item Rpar -> parasitic resistance
38 ## @end itemize
39 ## @item @var{string} = "PDEsymmetric" (Drift-Diffusion PDE model)
40 ## @itemize @minus
41 ## @item len    -> diode length
42 ## @item Nnodes -> number of nodes of 1D grid
43 ## @item Dope   -> doping (abrupt and symmetric)
44 ## @item toll   -> absolute tolerance
45 ## @item maxit  -> max iterations number
46 ## @item Area   -> device area
47 ## @end itemize
48 ## @end itemize
49 ##
50 ## See the @cite{IFF file format specifications} for details about 
51 ## the output structures.
52 ##
53 ## @seealso{prs_iff,asm_initialize_system,asm_build_system}
54 ## @end deftypefn
55
56 function [a,b,c] = Mdiode (string,parameters,parameternames,extvar,intvar,t)
57
58   switch string 
59       
60     case "simple"
61       Is = 1e-14;
62       Vth = 2.5e-2;
63       Rpar = 1e12;
64       for ii=1:length(parameternames)
65         eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])      
66       endfor
67       
68       vp = extvar(1);
69       vm = extvar(2);
70
71       I = Is*(exp((vp - vm)/Vth) -1 ) + (vp - vm)/Rpar;
72       geq = Is*exp((vp - vm)/Vth)/Vth + 1/Rpar;
73
74       a = zeros(2);
75       b = [geq -geq; -geq geq];
76       c = [I ; -I] ;
77       break
78
79     case "PDEsymmetric"
80
81       len = 1e-6;
82       Nnodes = 100;
83       Dope=1e23;
84       
85       toll  = 1e-5;
86       maxit = 100;
87       ptoll  = 1e-10;
88       pmaxit = 100;
89
90       Area   = 1e-10;
91
92       for ii=1:length(parameternames)
93         eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])      
94       endfor
95
96       vp = extvar(1);
97       vm = extvar(2);
98       
99       [I,g] = Mpdesympnjunct (len,Dope,vp-vm,Area,Nnodes,toll,maxit,ptoll,pmaxit);
100       
101       a = zeros(2);
102       b = [g -g; -g g];
103       c = [I ; -I] ;
104       
105       break
106
107     otherwise
108       error(["unknown section:" string])
109   endswitch
110
111 endfunction