Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
isolator.cpp
Go to the documentation of this file.
1 /*
2  * isolator.cpp - isolator 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 "isolator.h"
31 
32 using namespace qucs;
33 
34 isolator::isolator () : circuit (2) {
35  type = CIR_ISOLATOR;
36 }
37 
38 void isolator::initSP (void) {
39  nr_double_t z1 = getPropertyDouble ("Z1");
40  nr_double_t z2 = getPropertyDouble ("Z2");
41  nr_double_t s1 = (z1 - z0) / (z1 + z0);
42  nr_double_t s2 = (z2 - z0) / (z2 + z0);
43  allocMatrixS ();
44  setS (NODE_1, NODE_1, s1);
45  setS (NODE_2, NODE_2, s2);
46  setS (NODE_1, NODE_2, 0);
47  setS (NODE_2, NODE_1, std::sqrt (1 - s1 * s1) * std::sqrt (1 - s2 * s2));
48 }
49 
50 void isolator::calcNoiseSP (nr_double_t) {
51  nr_double_t T = getPropertyDouble ("Temp");
52  nr_double_t z1 = getPropertyDouble ("Z1");
53  nr_double_t z2 = getPropertyDouble ("Z2");
54  nr_double_t r = (z0 - z1) / (z0 + z2);
55  nr_double_t f = 4 * z0 / sqr (z1 + z0) * kelvin (T) / T0;
56  setN (NODE_1, NODE_1, f * z1);
57  setN (NODE_1, NODE_2, f * std::sqrt (z1 * z2) * r);
58  setN (NODE_2, NODE_1, f * std::sqrt (z1 * z2) * r);
59  setN (NODE_2, NODE_2, f * z2 * r * r);
60 }
61 
62 void isolator::calcNoiseAC (nr_double_t) {
63  nr_double_t T = getPropertyDouble ("Temp");
64  nr_double_t z1 = getPropertyDouble ("Z1");
65  nr_double_t z2 = getPropertyDouble ("Z2");
66  nr_double_t f = 4 * kelvin (T) / T0;
67  setN (NODE_1, NODE_1, +f / z1);
68  setN (NODE_1, NODE_2, 0);
69  setN (NODE_2, NODE_1, -f * 2 / std::sqrt (z1 * z2));
70  setN (NODE_2, NODE_2, +f / z2);
71 }
72 
73 void isolator::initDC (void) {
74  nr_double_t z1 = getPropertyDouble ("Z1");
75  nr_double_t z2 = getPropertyDouble ("Z2");
76 #if AUGMENTED
77  nr_double_t z21 = 2 * std::sqrt (z1 * z2);
79  allocMatrixMNA ();
80  setB (NODE_1, VSRC_1, +1.0); setB (NODE_1, VSRC_2, +0.0);
81  setB (NODE_2, VSRC_1, +0.0); setB (NODE_2, VSRC_2, +1.0);
82  setC (VSRC_1, NODE_1, -1.0); setC (VSRC_1, NODE_2, +0.0);
83  setC (VSRC_2, NODE_1, +0.0); setC (VSRC_2, NODE_2, -1.0);
84  setD (VSRC_1, VSRC_1, +z1); setD (VSRC_2, VSRC_2, +z2);
85  setD (VSRC_1, VSRC_2, +0.0); setD (VSRC_2, VSRC_1, +z21);
86  setE (VSRC_1, +0.0); setE (VSRC_2, +0.0);
87 #else
89  allocMatrixMNA ();
90  setY (NODE_1, NODE_1, 1 / z1);
91  setY (NODE_1, NODE_2, 0);
92  setY (NODE_2, NODE_1, -2 / std::sqrt (z1 * z2));
93  setY (NODE_2, NODE_2, 1 / z2);
94 #endif
95 }
96 
97 void isolator::initAC (void) {
98  initDC ();
99 }
100 
101 void isolator::initTR (void) {
102  initDC ();
103 }
104 
105 // properties
106 PROP_REQ [] = {
107  PROP_NO_PROP };
108 PROP_OPT [] = {
109  { "Temp", PROP_REAL, { 26.85, PROP_NO_STR }, PROP_MIN_VAL (K) },
110  { "Z1", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
111  { "Z2", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
112  PROP_NO_PROP };
113 struct define_t isolator::cirdef =
PROP_OPT[]
Definition: isolator.cpp:108
#define PROP_POS_RANGE
Definition: netdefs.h:129
void initTR(void)
Definition: isolator.cpp:101
#define NODE_2
Definition: circuit.h:35
#define T0
standard temperature
Definition: constants.h:61
#define kelvin(x)
Definition: constants.h:108
#define PROP_DEF
Definition: netdefs.h:189
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 calcNoiseAC(nr_double_t)
Definition: isolator.cpp:62
#define PROP_NO_PROP
Definition: netdefs.h:122
void setVoltageSources(int)
Definition: circuit.cpp:607
#define K
Absolute 0 in centigrade.
Definition: constants.h:59
#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
static const nr_double_t z0
Definition: circuit.h:320
r
Definition: parse_mdl.y:515
void initDC(void)
Definition: isolator.cpp:73
#define VSRC_1
Definition: circuit.h:40
nr_complex_t sqr(const nr_complex_t z)
Square of complex number.
Definition: complex.cpp:673
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: isolator.cpp:38
nr_complex_t sqrt(const nr_complex_t z)
Compute principal value of square root.
Definition: complex.cpp:271
#define PROP_COMPONENT
Definition: netdefs.h:116
void calcNoiseSP(nr_double_t)
Definition: isolator.cpp:50
void setE(int, nr_complex_t)
Definition: circuit.cpp:385
void initAC(void)
Definition: isolator.cpp:97
void setY(int, int, nr_complex_t)
Definition: circuit.cpp:452
#define PROP_MIN_VAL(k)
Definition: netdefs.h:133
PROP_REQ[]
Definition: isolator.cpp:106
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
void setN(int, int, nr_complex_t)
Definition: circuit.cpp:597
void setC(int, int, nr_complex_t)
Definition: circuit.cpp:361
#define VSRC_2
Definition: circuit.h:41
PROP_NO_SUBSTRATE
Definition: isolator.cpp:114