Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gyrator.cpp
Go to the documentation of this file.
1 /*
2  * gyrator.cpp - gyrator class implementation
3  *
4  * Copyright (C) 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 "gyrator.h"
31 
32 using namespace qucs;
33 
34 gyrator::gyrator () : circuit (4) {
35  type = CIR_GYRATOR;
36 #if AUGMENTED
38 #endif
39 }
40 
41 void gyrator::initSP (void) {
42  nr_double_t R = getPropertyDouble ("R");
43  nr_double_t z = getPropertyDouble ("Zref");
44  nr_double_t r = R / z;
45  nr_double_t s1 = r * r / (r * r + 4.0);
46  nr_double_t s2 = 2.0 * r / (r * r + 4.0);
47  allocMatrixS ();
48  setS (NODE_1, NODE_1, s1); setS (NODE_2, NODE_2, s1);
49  setS (NODE_3, NODE_3, s1); setS (NODE_4, NODE_4, s1);
50  setS (NODE_1, NODE_4, 1.0 - s1);
51  setS (NODE_2, NODE_3, 1.0 - s1);
52  setS (NODE_3, NODE_2, 1.0 - s1);
53  setS (NODE_4, NODE_1, 1.0 - s1);
54  setS (NODE_1, NODE_2, +s2); setS (NODE_2, NODE_4, +s2);
55  setS (NODE_3, NODE_1, +s2); setS (NODE_4, NODE_3, +s2);
56  setS (NODE_1, NODE_3, -s2); setS (NODE_2, NODE_1, -s2);
57  setS (NODE_3, NODE_4, -s2); setS (NODE_4, NODE_2, -s2);
58 }
59 
60 void gyrator::initDC (void) {
61  nr_double_t r = getPropertyDouble ("R");
62  allocMatrixMNA ();
63 #if AUGMENTED
64  setB (NODE_1, VSRC_1, +1.0); setB (NODE_2, VSRC_1, +0.0);
65  setB (NODE_3, VSRC_1, +0.0); setB (NODE_4, VSRC_1, -1.0);
66  setB (NODE_2, VSRC_1, +0.0); setB (NODE_2, VSRC_2, +1.0);
67  setB (NODE_3, VSRC_2, -1.0); setB (NODE_4, VSRC_2, +0.0);
68  setC (VSRC_1, NODE_1, +0.0); setC (VSRC_1, NODE_2, +1/r);
69  setC (VSRC_1, NODE_3, -1/r); setC (VSRC_1, NODE_4, +0.0);
70  setC (VSRC_2, NODE_1, -1/r); setC (VSRC_2, NODE_2, +0.0);
71  setC (VSRC_2, NODE_3, +0.0); setC (VSRC_2, NODE_4, +1/r);
72  setD (VSRC_1, VSRC_1, -1.0); setD (VSRC_2, VSRC_2, -1.0);
73  setD (VSRC_1, VSRC_2, +0.0); setD (VSRC_2, VSRC_1, +0.0);
74  setE (VSRC_1, +0.0);
75  setE (VSRC_2, +0.0);
76 #else
77  setY (NODE_1, NODE_2, +1/r); setY (NODE_1, NODE_3, -1/r);
78  setY (NODE_2, NODE_1, -1/r); setY (NODE_2, NODE_4, +1/r);
79  setY (NODE_3, NODE_1, +1/r); setY (NODE_3, NODE_4, -1/r);
80  setY (NODE_4, NODE_2, -1/r); setY (NODE_4, NODE_3, +1/r);
81 #endif
82 }
83 
84 void gyrator::initAC (void) {
85  initDC ();
86 }
87 
88 void gyrator::initTR (void) {
89  initDC ();
90 }
91 
92 // properties
93 PROP_REQ [] = {
94  { "R", PROP_REAL, { 50, PROP_NO_STR }, PROP_NO_RANGE }, PROP_NO_PROP };
95 PROP_OPT [] = {
96  { "Zref", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
97  PROP_NO_PROP };
98 struct define_t gyrator::cirdef =
#define PROP_POS_RANGE
Definition: netdefs.h:129
#define NODE_2
Definition: circuit.h:35
#define PROP_DEF
Definition: netdefs.h:189
void initAC(void)
Definition: gyrator.cpp:84
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
void setD(int, int, nr_complex_t)
Definition: circuit.cpp:373
void initTR(void)
Definition: gyrator.cpp:88
#define PROP_REAL
Definition: netdefs.h:174
#define PROP_NO_PROP
Definition: netdefs.h:122
void setVoltageSources(int)
Definition: circuit.cpp:607
#define PROP_NO_RANGE
Definition: netdefs.h:126
#define PROP_NO_STR
Definition: netdefs.h:125
void setB(int, int, nr_complex_t)
Definition: circuit.cpp:349
void allocMatrixS(void)
Definition: circuit.cpp:251
#define PROP_LINEAR
Definition: netdefs.h:120
r
Definition: parse_mdl.y:515
#define NODE_4
Definition: circuit.h:37
#define R(con)
#define VSRC_1
Definition: circuit.h:40
void initDC(void)
Definition: gyrator.cpp:60
#define PROP_COMPONENT
Definition: netdefs.h:116
void setE(int, nr_complex_t)
Definition: circuit.cpp:385
#define NODE_3
Definition: circuit.h:36
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: gyrator.cpp:41
void setY(int, int, nr_complex_t)
Definition: circuit.cpp:452
PROP_NO_SUBSTRATE
Definition: gyrator.cpp:99
void allocMatrixMNA(void)
Definition: circuit.cpp:267
#define NODE_1
Definition: circuit.h:34
void setS(int, int, nr_complex_t)
Definition: circuit.cpp:587
PROP_REQ[]
Definition: gyrator.cpp:93
void setC(int, int, nr_complex_t)
Definition: circuit.cpp:361
#define VSRC_2
Definition: circuit.h:41
PROP_OPT[]
Definition: gyrator.cpp:95