Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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$
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 using namespace qucs;
33 
34 biastee::biastee () : circuit (3) {
35  type = CIR_BIASTEE;
36 }
37 
38 void biastee::initSP (void) {
39  allocMatrixS ();
40  setS (NODE_1, NODE_1, 0.0);
41  setS (NODE_1, NODE_2, 1.0);
42  setS (NODE_1, NODE_3, 0.0);
43  setS (NODE_2, NODE_1, 1.0);
44  setS (NODE_2, NODE_2, 0.0);
45  setS (NODE_2, NODE_3, 0.0);
46  setS (NODE_3, NODE_1, 0.0);
47  setS (NODE_3, NODE_2, 0.0);
48  setS (NODE_3, NODE_3, 1.0);
49 }
50 
51 void biastee::initDC (void) {
52  setISource (false);
54  allocMatrixMNA ();
55  clearB ();
56  clearC ();
58 }
59 
60 void biastee::initAC (void) {
61  setISource (false);
63  allocMatrixMNA ();
64  clearB ();
65  clearC ();
67 }
68 
69 #define fState 0 // flux state
70 #define vState 1 // voltage state
71 #define qState 2 // charge state
72 #define cState 3 // current state
73 
74 void biastee::initTR (void) {
75  initDC ();
76  setStates (4);
77  setISource (true);
78 }
79 
80 void biastee::calcTR (nr_double_t) {
81  nr_double_t l = getPropertyDouble ("L");
82  nr_double_t c = getPropertyDouble ("C");
83  nr_double_t g, r, v;
84  nr_double_t i = real (getJ (VSRC_1));
85 
86  setState (fState, i * l);
87  integrate (fState, l, r, v);
88  setD (VSRC_1, VSRC_1, -r);
89  setE (VSRC_1, v);
90 
91  v = real (getV (NODE_1) - getV (NODE_2));
92  setState (qState, c * v);
93  integrate (qState, c, g, i);
94  setY (NODE_1, NODE_1, +g); setY (NODE_2, NODE_2, +g);
95  setY (NODE_1, NODE_2, -g); setY (NODE_2, NODE_1, -g);
96  setI (NODE_1 , -i);
97  setI (NODE_2 , +i);
98 }
99 
100 // properties
101 PROP_REQ [] = {
102  PROP_NO_PROP };
103 PROP_OPT [] = {
104  { "C", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
105  { "L", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
106  PROP_NO_PROP };
107 struct define_t biastee::cirdef =
#define PROP_POS_RANGE
Definition: netdefs.h:129
l
Definition: parse_vcd.y:213
#define NODE_2
Definition: circuit.h:35
matrix real(matrix a)
Real part matrix.
Definition: matrix.cpp:568
void setISource(bool i)
Definition: circuit.h:194
#define PROP_DEF
Definition: netdefs.h:189
void integrate(int, nr_double_t, nr_double_t &, nr_double_t &)
Definition: integrator.cpp:67
void clearC(void)
Definition: circuit.cpp:710
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
void setD(int, int, nr_complex_t)
Definition: circuit.cpp:373
#define PROP_REAL
Definition: netdefs.h:174
void setStates(int n)
Definition: states.h:52
#define PROP_NO_PROP
Definition: netdefs.h:122
void setVoltageSources(int)
Definition: circuit.cpp:607
#define PROP_NO_STR
Definition: netdefs.h:125
void allocMatrixS(void)
Definition: circuit.cpp:251
#define PROP_LINEAR
Definition: netdefs.h:120
r
Definition: parse_mdl.y:515
PROP_NO_SUBSTRATE
Definition: biastee.cpp:108
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: biastee.cpp:38
#define VSRC_1
Definition: circuit.h:40
i
Definition: parse_mdl.y:516
PROP_REQ[]
Definition: biastee.cpp:101
void initTR(void)
Definition: biastee.cpp:74
void clearB(void)
Definition: circuit.cpp:705
nr_double_t getJ(int, nr_double_t)
Definition: circuit.cpp:951
#define PROP_COMPONENT
Definition: netdefs.h:116
void initAC(void)
Definition: biastee.cpp:60
#define qState
Definition: biastee.cpp:71
void setE(int, nr_complex_t)
Definition: circuit.cpp:385
void initDC(void)
Definition: biastee.cpp:51
#define NODE_3
Definition: circuit.h:36
void setI(int, nr_complex_t)
Definition: circuit.cpp:397
void setY(int, int, nr_complex_t)
Definition: circuit.cpp:452
v
Definition: parse_zvr.y:141
void allocMatrixMNA(void)
Definition: circuit.cpp:267
#define fState
Definition: biastee.cpp:69
void calcTR(nr_double_t)
Definition: biastee.cpp:80
nr_double_t getV(int, nr_double_t)
Definition: circuit.cpp:941
#define NODE_1
Definition: circuit.h:34
void voltageSource(int, int, int, nr_double_t value=0.0)
Definition: circuit.cpp:748
PROP_OPT[]
Definition: biastee.cpp:103
void setS(int, int, nr_complex_t)
Definition: circuit.cpp:587
void setState(int, state_type_t, int n=0)
Definition: states.cpp:109