Qucs-core
0.0.19
|
00001 /* 00002 * amplifier.cpp - amplifier class implementation 00003 * 00004 * Copyright (C) 2004, 2008, 2010 Stefan Jahn <stefan@lkcc.org> 00005 * Copyright (C) 2008 Michael Margraf <Michael.Margraf@alumni.TU-Berlin.DE> 00006 * 00007 * This is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2, or (at your option) 00010 * any later version. 00011 * 00012 * This software is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this package; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 00020 * Boston, MA 02110-1301, USA. 00021 * 00022 * $Id$ 00023 * 00024 */ 00025 00033 #if HAVE_CONFIG_H 00034 # include <config.h> 00035 #endif 00036 00037 #include "component.h" 00038 #include "amplifier.h" 00039 00040 using namespace qucs; 00041 00043 amplifier::amplifier () : circuit (2) { 00044 type = CIR_AMPLIFIER; 00045 } 00046 00060 void amplifier::initSP (void) { 00061 nr_double_t g = getPropertyDouble ("G"); 00062 nr_double_t z1 = getPropertyDouble ("Z1"); 00063 nr_double_t z2 = getPropertyDouble ("Z2"); 00064 00065 allocMatrixS (); 00066 00067 setS (NODE_1, NODE_1, (z1 - z0) / (z1 + z0)); 00068 setS (NODE_1, NODE_2, 0); 00069 setS (NODE_2, NODE_2, (z2 - z0) / (z2 + z0)); 00070 setS (NODE_2, NODE_1, 4 * z0 * std::sqrt (z1 * z2) * g / (z1 + z0) / (z2 + z0)); 00071 } 00072 00073 void amplifier::calcNoiseSP (nr_double_t) { 00074 nr_double_t g = getPropertyDouble ("G"); 00075 nr_double_t z2 = getPropertyDouble ("Z2"); 00076 nr_double_t NF = getPropertyDouble ("NF"); 00077 setN (NODE_1, NODE_1, 0); 00078 setN (NODE_2, NODE_2, 4 * z0 * z2 * sqr (g) * (NF - 1) / sqr (z2 + z0)); 00079 setN (NODE_1, NODE_2, 0); 00080 setN (NODE_2, NODE_1, 0); 00081 } 00082 00095 void amplifier::initDC (void) { 00096 nr_double_t g = getPropertyDouble ("G"); 00097 nr_double_t z1 = getPropertyDouble ("Z1"); 00098 nr_double_t z2 = getPropertyDouble ("Z2"); 00099 00100 allocMatrixMNA (); 00101 00102 setY (NODE_1, NODE_1, 1 / z1); 00103 setY (NODE_1, NODE_2, 0); 00104 setY (NODE_2, NODE_1, -2 * g / std::sqrt (z1 * z2)); 00105 setY (NODE_2, NODE_2, 1 / z2); 00106 } 00107 00112 void amplifier::initAC (void) { 00113 initDC (); 00114 } 00115 00116 void amplifier::calcNoiseAC (nr_double_t) { 00117 nr_double_t g = getPropertyDouble ("G"); 00118 nr_double_t z2 = getPropertyDouble ("Z2"); 00119 nr_double_t NF = getPropertyDouble ("NF"); 00120 setN (NODE_1, NODE_1, 0); 00121 setN (NODE_2, NODE_2, 4 * sqr (g) * (NF - 1) / z2); 00122 setN (NODE_1, NODE_2, 0); 00123 setN (NODE_2, NODE_1, 0); 00124 } 00125 00130 void amplifier::initTR (void) { 00131 initDC (); 00132 } 00133 00134 // properties 00135 PROP_REQ [] = { 00136 { "G", PROP_REAL, { 10, PROP_NO_STR }, PROP_MIN_VAL (1) }, 00137 PROP_NO_PROP }; 00138 PROP_OPT [] = { 00139 { "Z1", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE }, 00140 { "Z2", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE }, 00141 { "NF", PROP_REAL, { 1, PROP_NO_STR }, PROP_MIN_VAL (1) }, 00142 PROP_NO_PROP }; 00143 struct define_t amplifier::cirdef = 00144 { "Amp", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };