Qucs-core
0.0.19
|
00001 /* 00002 * isolator.cpp - isolator class implementation 00003 * 00004 * Copyright (C) 2003, 2004, 2005, 2008 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 "isolator.h" 00031 00032 using namespace qucs; 00033 00034 isolator::isolator () : circuit (2) { 00035 type = CIR_ISOLATOR; 00036 } 00037 00038 void isolator::initSP (void) { 00039 nr_double_t z1 = getPropertyDouble ("Z1"); 00040 nr_double_t z2 = getPropertyDouble ("Z2"); 00041 nr_double_t s1 = (z1 - z0) / (z1 + z0); 00042 nr_double_t s2 = (z2 - z0) / (z2 + z0); 00043 allocMatrixS (); 00044 setS (NODE_1, NODE_1, s1); 00045 setS (NODE_2, NODE_2, s2); 00046 setS (NODE_1, NODE_2, 0); 00047 setS (NODE_2, NODE_1, std::sqrt (1 - s1 * s1) * std::sqrt (1 - s2 * s2)); 00048 } 00049 00050 void isolator::calcNoiseSP (nr_double_t) { 00051 nr_double_t T = getPropertyDouble ("Temp"); 00052 nr_double_t z1 = getPropertyDouble ("Z1"); 00053 nr_double_t z2 = getPropertyDouble ("Z2"); 00054 nr_double_t r = (z0 - z1) / (z0 + z2); 00055 nr_double_t f = 4 * z0 / sqr (z1 + z0) * celsius2kelvin (T) / T0; 00056 setN (NODE_1, NODE_1, f * z1); 00057 setN (NODE_1, NODE_2, f * std::sqrt (z1 * z2) * r); 00058 setN (NODE_2, NODE_1, f * std::sqrt (z1 * z2) * r); 00059 setN (NODE_2, NODE_2, f * z2 * r * r); 00060 } 00061 00062 void isolator::calcNoiseAC (nr_double_t) { 00063 nr_double_t T = getPropertyDouble ("Temp"); 00064 nr_double_t z1 = getPropertyDouble ("Z1"); 00065 nr_double_t z2 = getPropertyDouble ("Z2"); 00066 nr_double_t f = 4 * celsius2kelvin (T) / T0; 00067 setN (NODE_1, NODE_1, +f / z1); 00068 setN (NODE_1, NODE_2, 0); 00069 setN (NODE_2, NODE_1, -f * 2 / std::sqrt (z1 * z2)); 00070 setN (NODE_2, NODE_2, +f / z2); 00071 } 00072 00073 void isolator::initDC (void) { 00074 nr_double_t z1 = getPropertyDouble ("Z1"); 00075 nr_double_t z2 = getPropertyDouble ("Z2"); 00076 #if AUGMENTED 00077 nr_double_t z21 = 2 * std::sqrt (z1 * z2); 00078 setVoltageSources (2); 00079 allocMatrixMNA (); 00080 setB (NODE_1, VSRC_1, +1.0); setB (NODE_1, VSRC_2, +0.0); 00081 setB (NODE_2, VSRC_1, +0.0); setB (NODE_2, VSRC_2, +1.0); 00082 setC (VSRC_1, NODE_1, -1.0); setC (VSRC_1, NODE_2, +0.0); 00083 setC (VSRC_2, NODE_1, +0.0); setC (VSRC_2, NODE_2, -1.0); 00084 setD (VSRC_1, VSRC_1, +z1); setD (VSRC_2, VSRC_2, +z2); 00085 setD (VSRC_1, VSRC_2, +0.0); setD (VSRC_2, VSRC_1, +z21); 00086 setE (VSRC_1, +0.0); setE (VSRC_2, +0.0); 00087 #else 00088 setVoltageSources (0); 00089 allocMatrixMNA (); 00090 setY (NODE_1, NODE_1, 1 / z1); 00091 setY (NODE_1, NODE_2, 0); 00092 setY (NODE_2, NODE_1, -2 / std::sqrt (z1 * z2)); 00093 setY (NODE_2, NODE_2, 1 / z2); 00094 #endif 00095 } 00096 00097 void isolator::initAC (void) { 00098 initDC (); 00099 } 00100 00101 void isolator::initTR (void) { 00102 initDC (); 00103 } 00104 00105 // properties 00106 PROP_REQ [] = { 00107 PROP_NO_PROP }; 00108 PROP_OPT [] = { 00109 { "Temp", PROP_REAL, { 26.85, PROP_NO_STR }, PROP_MIN_VAL (K) }, 00110 { "Z1", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE }, 00111 { "Z2", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE }, 00112 PROP_NO_PROP }; 00113 struct define_t isolator::cirdef = 00114 { "Isolator", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };