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