Qucs-core
0.0.19
|
00001 /* 00002 * coaxline.cpp - coaxial cable class implementation 00003 * 00004 * Copyright (C) 2006, 2008, 2009, 2011 Stefan Jahn <stefan@lkcc.org> 00005 * 00006 * This is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2, or (at your option) 00009 * any later version. 00010 * 00011 * This software is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this package; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 * $Id$ 00022 * 00023 */ 00024 00025 #if HAVE_CONFIG_H 00026 # include <config.h> 00027 #endif 00028 00029 #include "component.h" 00030 #include "coaxline.h" 00031 00032 using namespace qucs; 00033 00034 coaxline::coaxline () : circuit (2) { 00035 alpha = beta = zl = fc = 0; 00036 type = CIR_COAXLINE; 00037 } 00038 00039 void coaxline::calcPropagation (nr_double_t frequency) { 00040 nr_double_t er = getPropertyDouble ("er"); 00041 nr_double_t mur = getPropertyDouble ("mur"); 00042 nr_double_t rho = getPropertyDouble ("rho"); 00043 nr_double_t tand = getPropertyDouble ("tand"); 00044 nr_double_t d = getPropertyDouble ("d"); 00045 nr_double_t D = getPropertyDouble ("D"); 00046 nr_double_t ad, ac, rs; 00047 00048 // check cutoff frequency 00049 if (frequency > fc) { 00050 logprint (LOG_ERROR, "WARNING: Operating frequency (%g) beyond " 00051 "cutoff frequency (%g).\n", frequency, fc); 00052 } 00053 00054 // calculate losses 00055 ad = pi / C0 * frequency * std::sqrt (er) * tand; 00056 rs = std::sqrt (pi * frequency * mur * MU0 * rho); 00057 ac = std::sqrt (er) * (1 / d + 1 / D) / std::log (D / d) * rs / Z0; 00058 00059 // calculate propagation constants and reference impedance 00060 alpha = ac + ad; 00061 beta = std::sqrt (er * mur) * 2 * pi * frequency / C0; 00062 zl = Z0 / 2 / pi / std::sqrt (er) * std::log (D / d); 00063 } 00064 00065 void coaxline::calcNoiseSP (nr_double_t) { 00066 nr_double_t l = getPropertyDouble ("L"); 00067 if (l < 0) return; 00068 // calculate noise using Bosma's theorem 00069 nr_double_t T = getPropertyDouble ("Temp"); 00070 matrix s = getMatrixS (); 00071 matrix e = eye (getSize ()); 00072 setMatrixN (celsius2kelvin (T) / T0 * (e - s * transpose (conj (s)))); 00073 } 00074 00075 void coaxline::initCheck (void) { 00076 nr_double_t d = getPropertyDouble ("d"); 00077 nr_double_t D = getPropertyDouble ("D"); 00078 nr_double_t er = getPropertyDouble ("er"); 00079 nr_double_t mur = getPropertyDouble ("mur"); 00080 00081 // check validity 00082 if (d >= D) { 00083 logprint (LOG_ERROR, 00084 "ERROR: Inner diameter larger than outer diameter.\n"); 00085 } 00086 nr_double_t f1, f2, cl; 00087 cl = C0 / std::sqrt (mur * er); 00088 f1 = cl / (pi_over_2 * (D + d)); // TE_11 00089 f2 = cl / (1 * (D - d)); // TM_N1 00090 fc = std::min (f1, f2); 00091 } 00092 00093 void coaxline::saveCharacteristics (nr_double_t) { 00094 setCharacteristic ("Zl", zl); 00095 } 00096 00097 void coaxline::initSP (void) { 00098 // allocate S-parameter matrix 00099 allocMatrixS (); 00100 initCheck (); 00101 } 00102 00103 void coaxline::calcSP (nr_double_t frequency) { 00104 nr_double_t l = getPropertyDouble ("L"); 00105 00106 // calculate propagation constants 00107 calcPropagation (frequency); 00108 00109 // calculate S-parameters 00110 nr_double_t z = zl / z0; 00111 nr_double_t y = 1 / z; 00112 nr_complex_t g = nr_complex_t (alpha, beta); 00113 nr_complex_t n = 2.0 * cosh (g * l) + (z + y) * sinh (g * l); 00114 nr_complex_t s11 = (z - y) * sinh (g * l) / n; 00115 nr_complex_t s21 = 2.0 / n; 00116 setS (NODE_1, NODE_1, s11); setS (NODE_2, NODE_2, s11); 00117 setS (NODE_1, NODE_2, s21); setS (NODE_2, NODE_1, s21); 00118 } 00119 00120 void coaxline::initDC (void) { 00121 nr_double_t l = getPropertyDouble ("L"); 00122 nr_double_t d = getPropertyDouble ("d"); 00123 nr_double_t rho = getPropertyDouble ("rho"); 00124 00125 if (d != 0.0 && rho != 0.0 && l != 0.0) { 00126 // a tiny resistance 00127 nr_double_t g = pi * sqr (d / 2) / rho / l; 00128 setVoltageSources (0); 00129 allocMatrixMNA (); 00130 setY (NODE_1, NODE_1, +g); setY (NODE_2, NODE_2, +g); 00131 setY (NODE_1, NODE_2, -g); setY (NODE_2, NODE_1, -g); 00132 } 00133 else { 00134 // a DC short 00135 setVoltageSources (1); 00136 setInternalVoltageSource (1); 00137 allocMatrixMNA (); 00138 voltageSource (VSRC_1, NODE_1, NODE_2); 00139 } 00140 } 00141 00142 void coaxline::initAC (void) { 00143 setVoltageSources (0); 00144 allocMatrixMNA (); 00145 initCheck (); 00146 } 00147 00148 void coaxline::calcAC (nr_double_t frequency) { 00149 nr_double_t l = getPropertyDouble ("L"); 00150 00151 // calculate propagation constants 00152 calcPropagation (frequency); 00153 00154 // calculate Y-parameters 00155 nr_complex_t g = nr_complex_t (alpha, beta); 00156 nr_complex_t y11 = coth (g * l) / zl; 00157 nr_complex_t y21 = -cosech (g * l) / zl; 00158 setY (NODE_1, NODE_1, y11); setY (NODE_2, NODE_2, y11); 00159 setY (NODE_1, NODE_2, y21); setY (NODE_2, NODE_1, y21); 00160 } 00161 00162 void coaxline::calcNoiseAC (nr_double_t) { 00163 nr_double_t l = getPropertyDouble ("L"); 00164 if (l < 0) return; 00165 // calculate noise using Bosma's theorem 00166 nr_double_t T = getPropertyDouble ("Temp"); 00167 setMatrixN (4 * celsius2kelvin (T) / T0 * real (getMatrixY ())); 00168 } 00169 00170 // properties 00171 PROP_REQ [] = { 00172 { "D", PROP_REAL, { 2.95e-3, PROP_NO_STR }, PROP_POS_RANGEX }, 00173 { "d", PROP_REAL, { 0.9e-3, PROP_NO_STR }, PROP_POS_RANGEX }, 00174 { "L", PROP_REAL, { 1500e-3, PROP_NO_STR }, PROP_NO_RANGE }, 00175 { "er", PROP_REAL, { 2.29, PROP_NO_STR }, PROP_RNGII (1, 100) }, 00176 { "mur", PROP_REAL, { 1, PROP_NO_STR }, PROP_RNGII (1, 100) }, 00177 { "tand", PROP_REAL, { 4e-4, PROP_NO_STR }, PROP_POS_RANGE }, 00178 { "rho", PROP_REAL, { 0.022e-6, PROP_NO_STR }, PROP_POS_RANGE }, 00179 PROP_NO_PROP }; 00180 PROP_OPT [] = { 00181 { "Temp", PROP_REAL, { 26.85, PROP_NO_STR }, PROP_MIN_VAL (K) }, 00182 PROP_NO_PROP }; 00183 struct define_t coaxline::cirdef = 00184 { "COAX", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };