1 ## Copyright (C) 2006,2007,2008 Carlo de Falco, Culpo Massimiliano
3 ## This file is part of:
4 ## OCS - A Circuit Simulator for Octave
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.
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.
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/>.
19 ## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
20 ## author: culpo@math.uni-wuppertal.de
24 ## @deftypefn{Function File} @
25 ## {[@var{a},@var{b},@var{c}]=}Mresistors(@var{string},@var{parameters},@
26 ## @var{parameternames},@var{extvar},@var{intvar},@var{t})
28 ## SBN file implementing models for resistors.
30 ## @var{string} is used to select among models. Parameters are listed
31 ## as inner items. Possible models are:
34 ## @item @var{string} = "LIN" (Linear resistor)
36 ## @item R -> resistance value
38 ## @item @var{string} = "THERMAL" (Linear resistor with termal pin)
40 ## @item R0 -> reference resistance value at temperature @code{TNOM}
41 ## @item TC1 -> coefficient for first order Taylor expansion
42 ## @item TC2 -> coefficient for second order Taylor expansion
43 ## @item TNOM -> reference temperature
45 ## @item @var{string} = "THERMAL1D" (1D Thermal resistor)
47 ## @item L -> length of 1D domain
48 ## @item N -> number of discretized elements
49 ## @item cv -> PDE coefficient for dynamic part
50 ## @item k -> PDE coefficient for diffusion part
54 ## See the @cite{IFF file format specifications} for details about
55 ## the output structures.
57 ## @seealso{prs_iff,asm_initialize_system,asm_build_system}
61 function [a,b,c] =Mresistors(string,parameters,parameternames,extvar,intvar,t)
66 for ii=1:length(parameternames)
67 eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])
81 for ii=1:length(parameternames)
82 eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])
89 RT = R0*(1 + TC1*(T-TNOM) + TC2*(T - TNOM)^2);
90 dRdT = R0*(TC1 + 2*TC2*(T-TNOM));
97 b = [ 1/RT -1/RT (v2-v1)*dRdT/RT^2;...
98 -1/RT 1/RT (v1-v2)*dRdT/RT^2;...
99 -2*(v1-v2)/RT -2*(v2-v1)/RT (v1-v2)^2*dRdT/RT^2];
106 for ii=1:length(parameternames)
107 eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])
112 A = (cv*S*h)*speye(N+1);
114 B = spdiags([ -ones(N+1,1) 2*ones(N+1,1) -ones(N+1,1)],-1:1,N+1,N+1);
121 a = [A(ext,ext), A(ext,int); A(int,ext), A(int,int)];
122 b = k*(S/h)*[B(ext,ext), B(ext,int); B(int,ext), B(int,int)];
128 error (["unknown section:" string])