My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
hybrid.cpp
Go to the documentation of this file.
1 /*
2  * hybrid.cpp - hybrid class implementation
3  *
4  * Copyright (C) 2011 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
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: hybrid.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 "hybrid.h"
31 
32 hybrid::hybrid () : circuit (4) {
33  type = CIR_HYBRID;
34 }
35 
36 void hybrid::initSP (void) {
37  nr_complex_t p = polar (1.0, rad (getPropertyDouble ("phi")));
38  nr_double_t k = M_SQRT2;
39 
40  allocMatrixS ();
41  setS (NODE_1, NODE_1, 0.0); setS (NODE_2, NODE_2, 0.0);
42  setS (NODE_3, NODE_3, 0.0); setS (NODE_4, NODE_4, 0.0);
43 
44  setS (NODE_1, NODE_2, 0.0); setS (NODE_2, NODE_1, 0.0);
45  setS (NODE_3, NODE_4, 0.0); setS (NODE_4, NODE_3, 0.0);
46 
47  setS (NODE_1, NODE_3, k); setS (NODE_3, NODE_1, k);
48  setS (NODE_1, NODE_4, k); setS (NODE_4, NODE_1, k);
49  setS (NODE_2, NODE_3, k); setS (NODE_3, NODE_2, k);
50 
51  setS (NODE_2, NODE_4, k * p);
52  setS (NODE_4, NODE_2, k * p);
53 }
54 
55 void hybrid::initDC (void) {
58  allocMatrixMNA ();
61 }
62 
63 void hybrid::initAC (void) {
64  nr_double_t k = 2.0 * M_SQRT2;
65  nr_complex_t p = polar (1.0, rad (getPropertyDouble ("phi")));
66  nr_complex_t d = 2.0 * p * (p - 4.0) - 1.0;
67  nr_complex_t y;
68 
70  allocMatrixMNA ();
71  d *= getPropertyDouble ("Zref");
72 
73  y = (-6.0*p*p + 8.0*p - 1.0) / d;
74  setY (NODE_1, NODE_1, y); setY (NODE_3, NODE_3, y);
75 
76  y = (-2.0*p*p + 8.0*p - 5.0) / d;
77  setY (NODE_2, NODE_2, y); setY (NODE_4, NODE_4, y);
78 
79  y = 2.0*k * (p * (p - 1.0) - 0.5) / d;
80  setY (NODE_1, NODE_3, y); setY (NODE_3, NODE_1, y);
81 
82  y = k * (p - 2.0) / d;
83  setY (NODE_2, NODE_4, y); setY (NODE_4, NODE_2, y);
84 
85  y = k * (-2.0*p + 1.0) / d;
86  setY (NODE_1, NODE_4, y); setY (NODE_4, NODE_1, y);
87  setY (NODE_2, NODE_3, y); setY (NODE_3, NODE_2, y);
88 
89  y = (4.0*p + 4.0) / d;
90  setY (NODE_1, NODE_2, y); setY (NODE_2, NODE_1, y);
91  setY (NODE_3, NODE_4, y); setY (NODE_4, NODE_3, y);
92 }
93 
94 void hybrid::initTR (void) {
95  initDC ();
96 }
97 
98 // properties
99 PROP_REQ [] = {
100  { "phi", PROP_REAL, { 0, PROP_NO_STR }, PROP_RNGII (-180, +180) },
101  PROP_NO_PROP };
102 PROP_OPT [] = {
103  { "Zref", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
104  PROP_NO_PROP };
105 struct define_t hybrid::cirdef =