My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ctline.cpp
Go to the documentation of this file.
1 /*
2  * ctline.cpp - ideal coupled transmission line 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: ctline.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 "ctline.h"
31 
32 ctline::ctline () : circuit (4) {
33  type = CIR_CTLINE;
34 }
35 
36 void ctline::calcSP (nr_double_t frequency) {
37  nr_double_t l = getPropertyDouble ("L");
38  nr_double_t ze = getPropertyDouble ("Ze");
39  nr_double_t zo = getPropertyDouble ("Zo");
40  nr_double_t ere = getPropertyDouble ("Ere");
41  nr_double_t ero = getPropertyDouble ("Ero");
42  nr_double_t ae = getPropertyDouble ("Ae");
43  nr_double_t ao = getPropertyDouble ("Ao");
44  nr_double_t o = 2.0 * M_PI * frequency;
45 
46  nr_complex_t ge = rect (log (ae) / 2, o / C0 * sqrt (ere)) * l;
47  nr_complex_t go = rect (log (ao) / 2, o / C0 * sqrt (ero)) * l;
48  nr_complex_t xe = 2.0 * ze * z0 * cosh (ge) + (ze*ze + z0+z0) * sinh (ge);
49  nr_complex_t xo = 2.0 * zo * z0 * cosh (go) + (zo*zo + z0+z0) * sinh (go);
50  nr_complex_t ye = ze * z0 / xe;
51  nr_complex_t yo = zo * z0 / xo;
52  xe = (ze*ze - z0*z0) * sinh (ge) / 2.0 / xe;
53  xo = (zo*zo - z0*z0) * sinh (go) / 2.0 / xo;
54 
55  setS (NODE_1, NODE_1, xe+xo); setS (NODE_2, NODE_2, xe+xo);
56  setS (NODE_3, NODE_3, xe+xo); setS (NODE_4, NODE_4, xe+xo);
57  setS (NODE_1, NODE_4, xe-xo); setS (NODE_4, NODE_1, xe-xo);
58  setS (NODE_2, NODE_3, xe-xo); setS (NODE_3, NODE_2, xe-xo);
59  setS (NODE_1, NODE_2, ye+yo); setS (NODE_2, NODE_1, ye+yo);
60  setS (NODE_3, NODE_4, ye+yo); setS (NODE_4, NODE_3, ye+yo);
61  setS (NODE_1, NODE_3, ye-yo); setS (NODE_3, NODE_1, ye-yo);
62  setS (NODE_2, NODE_4, ye-yo); setS (NODE_4, NODE_2, ye-yo);
63 }
64 
65 void ctline::calcNoiseSP (nr_double_t) {
66  nr_double_t l = getPropertyDouble ("L");
67  if (l < 0) return;
68  // calculate noise using Bosma's theorem
69  nr_double_t T = getPropertyDouble ("Temp");
70  matrix s = getMatrixS ();
71  matrix e = eye (getSize ());
72  setMatrixN (kelvin (T) / T0 * (e - s * transpose (conj (s))));
73 }
74 
75 void ctline::calcNoiseAC (nr_double_t) {
76  nr_double_t l = getPropertyDouble ("L");
77  if (l < 0) return;
78  // calculate noise using Bosma's theorem
79  nr_double_t T = getPropertyDouble ("Temp");
80  setMatrixN (4 * kelvin (T) / T0 * real (getMatrixY ()));
81 }
82 
83 void ctline::initDC (void) {
85  allocMatrixMNA ();
88 }
89 
90 void ctline::initAC (void) {
91  nr_double_t l = getPropertyDouble ("L");
92  if (l != 0.0) {
94  allocMatrixMNA ();
95  } else {
97  allocMatrixMNA ();
100  }
101 }
102 
103 void ctline::calcAC (nr_double_t frequency) {
104  nr_double_t l = getPropertyDouble ("L");
105  nr_double_t ze = getPropertyDouble ("Ze");
106  nr_double_t zo = getPropertyDouble ("Zo");
107  nr_double_t ere = getPropertyDouble ("Ere");
108  nr_double_t ero = getPropertyDouble ("Ero");
109  nr_double_t ae = getPropertyDouble ("Ae");
110  nr_double_t ao = getPropertyDouble ("Ao");
111  nr_double_t o = 2.0 * M_PI * frequency;
112 
113  if (l != 0.0) {
114  nr_complex_t y11, y12, y13, y14;
115  nr_complex_t arg_e = rect (log (ae) / 2.0, o / C0 * sqrt (ere)) * l;
116  nr_complex_t arg_o = rect (log (ao) / 2.0, o / C0 * sqrt (ero)) * l;
117 
118  y12 = 0.5 / sinh (arg_e) / ze;
119  y13 = -0.5 / sinh (arg_o) / zo;
120  arg_e = cosh (arg_e) * y12;
121  arg_o = cosh (arg_o) * y13;
122  y11 = arg_e - arg_o;
123  y14 = arg_e + arg_o;
124  arg_e = y12;
125  y12 = y13 - y12;
126  y13 = -y13 - arg_e;
127 
128  setY (NODE_1, NODE_1, +y11); setY (NODE_2, NODE_2, +y11);
129  setY (NODE_3, NODE_3, +y11); setY (NODE_4, NODE_4, +y11);
130  setY (NODE_1, NODE_2, +y12); setY (NODE_2, NODE_1, +y12);
131  setY (NODE_3, NODE_4, +y12); setY (NODE_4, NODE_3, +y12);
132  setY (NODE_1, NODE_3, +y13); setY (NODE_3, NODE_1, +y13);
133  setY (NODE_2, NODE_4, +y13); setY (NODE_4, NODE_2, +y13);
134  setY (NODE_1, NODE_4, +y14); setY (NODE_4, NODE_1, +y14);
135  setY (NODE_2, NODE_3, +y14); setY (NODE_3, NODE_2, +y14);
136  }
137 }
138 
139 // properties
140 PROP_REQ [] = {
141  { "Ze", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
142  { "Zo", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
143  { "L", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_NO_RANGE },
144  PROP_NO_PROP };
145 PROP_OPT [] = {
146  { "Ere", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
147  { "Ero", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
148  { "Ae", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGEX },
149  { "Ao", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGEX },
150  { "Temp", PROP_REAL, { 26.85, PROP_NO_STR }, PROP_MIN_VAL (K) },
151  PROP_NO_PROP };
152 struct define_t ctline::cirdef =