Qucs-core
0.0.19
|
00001 /* 00002 * ivnoise.cpp - correlated noise sources class implementation 00003 * 00004 * Copyright (C) 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 "ivnoise.h" 00031 00032 #define NODE_I1P 0 00033 #define NODE_I1N 3 00034 #define NODE_V2P 1 00035 #define NODE_V2N 2 00036 00037 using namespace qucs; 00038 00039 ivnoise::ivnoise () : circuit (4) { 00040 type = CIR_IVNOISE; 00041 setVoltageSources (1); 00042 } 00043 00044 void ivnoise::initSP (void) { 00045 allocMatrixS (); 00046 setS (NODE_I1P, NODE_I1P, 1.0); 00047 setS (NODE_I1N, NODE_I1N, 1.0); 00048 setS (NODE_V2P, NODE_V2N, 1.0); 00049 setS (NODE_V2N, NODE_V2P, 1.0); 00050 } 00051 00052 void ivnoise::calcNoiseSP (nr_double_t frequency) { 00053 nr_double_t C = getPropertyDouble ("C"); 00054 nr_double_t e = getPropertyDouble ("e"); 00055 nr_double_t c = getPropertyDouble ("c"); 00056 nr_double_t a = getPropertyDouble ("a"); 00057 nr_double_t k = a + c * qucs::pow (frequency, e); 00058 nr_double_t i1 = getPropertyDouble ("i1") / k / kB / T0; 00059 nr_double_t u2 = getPropertyDouble ("v2") / k / kB / T0; 00060 nr_double_t ci = C * std::sqrt (i1 * u2) / 2; 00061 00062 // entries of source 1 00063 setN (NODE_I1P, NODE_I1P, +i1 * z0); setN (NODE_I1N, NODE_I1N, +i1 * z0); 00064 setN (NODE_I1P, NODE_I1N, -i1 * z0); setN (NODE_I1N, NODE_I1P, -i1 * z0); 00065 // entries of source 2 00066 setN (NODE_V2P, NODE_V2P, +u2 /4/z0); setN (NODE_V2N, NODE_V2N, +u2 /4/z0); 00067 setN (NODE_V2P, NODE_V2N, -u2 /4/z0); setN (NODE_V2N, NODE_V2P, -u2 /4/z0); 00068 // correlation entries 00069 setN (NODE_I1P, NODE_V2P, +ci); setN (NODE_I1N, NODE_V2N, +ci); 00070 setN (NODE_I1P, NODE_V2N, -ci); setN (NODE_I1N, NODE_V2P, -ci); 00071 setN (NODE_V2P, NODE_I1P, +ci); setN (NODE_V2N, NODE_I1N, +ci); 00072 setN (NODE_V2P, NODE_I1N, -ci); setN (NODE_V2N, NODE_I1P, -ci); 00073 } 00074 00075 void ivnoise::initDC (void) { 00076 allocMatrixMNA (); 00077 voltageSource (VSRC_1, NODE_V2P, NODE_V2N); 00078 } 00079 00080 void ivnoise::initAC (void) { 00081 initDC (); 00082 } 00083 00084 void ivnoise::initTR (void) { 00085 initDC (); 00086 } 00087 00088 void ivnoise::calcNoiseAC (nr_double_t frequency) { 00089 nr_double_t C = getPropertyDouble ("C"); 00090 nr_double_t e = getPropertyDouble ("e"); 00091 nr_double_t c = getPropertyDouble ("c"); 00092 nr_double_t a = getPropertyDouble ("a"); 00093 nr_double_t k = a + c * qucs::pow (frequency, e); 00094 nr_double_t i1 = getPropertyDouble ("i1") / k / kB / T0; 00095 nr_double_t u2 = getPropertyDouble ("v2") / k / kB / T0; 00096 nr_double_t ci = C * std::sqrt (i1 * u2); 00097 setN (NODE_I1P, NODE_I1P, +i1); setN (NODE_I1N, NODE_I1N, +i1); 00098 setN (NODE_I1P, NODE_I1N, -i1); setN (NODE_I1N, NODE_I1P, -i1); 00099 setN (NODE_5, NODE_I1P, ci); 00100 setN (NODE_I1P, NODE_5, ci); 00101 setN (NODE_5, NODE_5, u2); 00102 } 00103 00104 // properties 00105 PROP_REQ [] = { 00106 { "i1", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE }, 00107 { "v2", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE }, 00108 { "C", PROP_REAL, { 0.5, PROP_NO_STR }, PROP_RNGII (-1, 1) }, 00109 PROP_NO_PROP }; 00110 PROP_OPT [] = { 00111 { "a", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE }, 00112 { "c", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE }, 00113 { "e", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE }, 00114 PROP_NO_PROP }; 00115 struct define_t ivnoise::cirdef = 00116 { "IVnoise", 4, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };