My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
biastee.cpp
Go to the documentation of this file.
1 /*
2  * biastee.cpp - bias T class implementation
3  *
4  * Copyright (C) 2003, 2004, 2005, 2008 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This 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; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id: biastee.cpp 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #if HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 
29 #include "component.h"
30 #include "biastee.h"
31 
32 biastee::biastee () : circuit (3) {
33  type = CIR_BIASTEE;
34 }
35 
36 void biastee::initSP (void) {
37  allocMatrixS ();
38  setS (NODE_1, NODE_1, 0.0);
39  setS (NODE_1, NODE_2, 1.0);
40  setS (NODE_1, NODE_3, 0.0);
41  setS (NODE_2, NODE_1, 1.0);
42  setS (NODE_2, NODE_2, 0.0);
43  setS (NODE_2, NODE_3, 0.0);
44  setS (NODE_3, NODE_1, 0.0);
45  setS (NODE_3, NODE_2, 0.0);
46  setS (NODE_3, NODE_3, 1.0);
47 }
48 
49 void biastee::initDC (void) {
50  setISource (false);
52  allocMatrixMNA ();
53  clearB ();
54  clearC ();
56 }
57 
58 void biastee::initAC (void) {
59  setISource (false);
61  allocMatrixMNA ();
62  clearB ();
63  clearC ();
65 }
66 
67 #define fState 0 // flux state
68 #define vState 1 // voltage state
69 #define qState 2 // charge state
70 #define cState 3 // current state
71 
72 void biastee::initTR (void) {
73  initDC ();
74  setStates (4);
75  setISource (true);
76 }
77 
78 void biastee::calcTR (nr_double_t) {
79  nr_double_t l = getPropertyDouble ("L");
80  nr_double_t c = getPropertyDouble ("C");
81  nr_double_t g, r, v;
82  nr_double_t i = real (getJ (VSRC_1));
83 
84  setState (fState, i * l);
85  integrate (fState, l, r, v);
86  setD (VSRC_1, VSRC_1, -r);
87  setE (VSRC_1, v);
88 
89  v = real (getV (NODE_1) - getV (NODE_2));
90  setState (qState, c * v);
91  integrate (qState, c, g, i);
92  setY (NODE_1, NODE_1, +g); setY (NODE_2, NODE_2, +g);
93  setY (NODE_1, NODE_2, -g); setY (NODE_2, NODE_1, -g);
94  setI (NODE_1 , -i);
95  setI (NODE_2 , +i);
96 }
97 
98 // properties
99 PROP_REQ [] = {
100  PROP_NO_PROP };
101 PROP_OPT [] = {
102  { "C", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
103  { "L", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
104  PROP_NO_PROP };
105 struct define_t biastee::cirdef =