Qucs-core
0.0.19
|
00001 /* 00002 * strafo.cpp - symmetrical trafo class implementation 00003 * 00004 * Copyright (C) 2003, 2004, 2005, 2008, 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 "strafo.h" 00031 00032 using namespace qucs; 00033 00034 strafo::strafo () : circuit (6) { 00035 type = CIR_STRAFO; 00036 } 00037 00038 void strafo::initSP (void) { 00039 00040 nr_double_t t1 = getPropertyDouble ("T1"); 00041 nr_double_t t2 = getPropertyDouble ("T2"); 00042 00043 nr_double_t d = t1 * t1 + t2 * t2 + 1.0; 00044 nr_double_t z1 = t1 * t1 / d; 00045 nr_double_t z2 = t2 * t2 / d; 00046 nr_double_t z3 = 1.0 / d; 00047 nr_double_t z4 = t1 / d; 00048 nr_double_t z5 = t2 / d; 00049 nr_double_t z6 = t1 * t2 / d; 00050 00051 allocMatrixS (); 00052 00053 setS (NODE_1, NODE_1, z1); setS (NODE_1, NODE_2, z4); 00054 setS (NODE_1, NODE_3, -z4); setS (NODE_1, NODE_4, -z6); 00055 setS (NODE_1, NODE_5, z6); setS (NODE_1, NODE_6, 1 - z1); 00056 setS (NODE_2, NODE_1, z4); setS (NODE_2, NODE_2, z3); 00057 setS (NODE_2, NODE_3, 1 - z3); setS (NODE_2, NODE_4, -z5); 00058 setS (NODE_2, NODE_5, z5); setS (NODE_2, NODE_6, -z4); 00059 setS (NODE_3, NODE_1, -z4); setS (NODE_3, NODE_2, 1 - z3); 00060 setS (NODE_3, NODE_3, z3); setS (NODE_3, NODE_4, z5); 00061 setS (NODE_3, NODE_5, -z5); setS (NODE_3, NODE_6, z4); 00062 setS (NODE_4, NODE_1, -z6); setS (NODE_4, NODE_2, -z5); 00063 setS (NODE_4, NODE_3, z5); setS (NODE_4, NODE_4, z2); 00064 setS (NODE_4, NODE_5, 1 - z2); setS (NODE_4, NODE_6, z6); 00065 setS (NODE_5, NODE_1, z6); setS (NODE_5, NODE_2, z5); 00066 setS (NODE_5, NODE_3, -z5); setS (NODE_5, NODE_4, 1 - z2); 00067 setS (NODE_5, NODE_5, z2); setS (NODE_5, NODE_6, -z6); 00068 setS (NODE_6, NODE_1, 1 - z1); setS (NODE_6, NODE_2, -z4); 00069 setS (NODE_6, NODE_3, z4); setS (NODE_6, NODE_4, z6); 00070 setS (NODE_6, NODE_5, -z6); setS (NODE_6, NODE_6, z1); 00071 } 00072 00073 void strafo::initDC (void) { 00074 setVoltageSources (3); 00075 allocMatrixMNA (); 00076 voltageSource (VSRC_1, NODE_1, NODE_6); 00077 voltageSource (VSRC_2, NODE_5, NODE_4); 00078 voltageSource (VSRC_3, NODE_2, NODE_3); 00079 } 00080 00081 void strafo::initAC (void) { 00082 nr_double_t t1 = getPropertyDouble ("T1"); 00083 nr_double_t t2 = getPropertyDouble ("T2"); 00084 00085 setVoltageSources (2); 00086 allocMatrixMNA (); 00087 00088 setB (NODE_1, VSRC_1, -1.0); setB (NODE_2, VSRC_1, + t1); 00089 setB (NODE_3, VSRC_1, - t1); setB (NODE_4, VSRC_1, +0.0); 00090 setB (NODE_5, VSRC_1, +0.0); setB (NODE_6, VSRC_1, +1.0); 00091 setB (NODE_1, VSRC_2, +0.0); setB (NODE_2, VSRC_2, + t2); 00092 setB (NODE_3, VSRC_2, - t2); setB (NODE_4, VSRC_2, +1.0); 00093 setB (NODE_5, VSRC_2, -1.0); setB (NODE_6, VSRC_2, +0.0); 00094 00095 setC (VSRC_1, NODE_1, +1.0); setC (VSRC_1, NODE_2, - t1); 00096 setC (VSRC_1, NODE_3, + t1); setC (VSRC_1, NODE_4, +0.0); 00097 setC (VSRC_1, NODE_5, +0.0); setC (VSRC_1, NODE_6, -1.0); 00098 setC (VSRC_2, NODE_1, +0.0); setC (VSRC_2, NODE_2, - t2); 00099 setC (VSRC_2, NODE_3, + t2); setC (VSRC_2, NODE_4, -1.0); 00100 setC (VSRC_2, NODE_5, +1.0); setC (VSRC_2, NODE_6, +0.0); 00101 00102 setD (VSRC_1, VSRC_1, 0); setD (VSRC_2, VSRC_2, 0); 00103 setD (VSRC_1, VSRC_2, 0); setD (VSRC_2, VSRC_1, 0); 00104 setE (VSRC_1, 0.0); 00105 setE (VSRC_2, 0.0); 00106 } 00107 00108 void strafo::initTR (void) { 00109 initAC (); 00110 } 00111 00112 // properties 00113 PROP_REQ [] = { 00114 { "T1", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE }, 00115 { "T2", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE }, 00116 PROP_NO_PROP }; 00117 PROP_OPT [] = { 00118 PROP_NO_PROP }; 00119 struct define_t strafo::cirdef = 00120 { "sTr", 6, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };