Qucs-core  0.0.19
iinoise.cpp
Go to the documentation of this file.
00001 /*
00002  * iinoise.cpp - correlated noise current 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 "iinoise.h"
00031 
00032 #define NODE_I1P 0
00033 #define NODE_I1N 3
00034 #define NODE_I2P 1
00035 #define NODE_I2N 2
00036 
00037 using namespace qucs;
00038 
00039 iinoise::iinoise () : circuit (4) {
00040   type = CIR_IINOISE;
00041 }
00042 
00043 void iinoise::initSP (void) {
00044   allocMatrixS ();
00045   setS (NODE_I1P, NODE_I1P, 1.0);
00046   setS (NODE_I1N, NODE_I1N, 1.0);
00047   setS (NODE_I2P, NODE_I2P, 1.0);
00048   setS (NODE_I2N, NODE_I2N, 1.0);
00049 }
00050 
00051 void iinoise::calcNoiseSP (nr_double_t frequency) {
00052   setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
00053 }
00054 
00055 matrix iinoise::calcMatrixCy (nr_double_t frequency) {
00056   nr_double_t C = getPropertyDouble ("C");
00057   nr_double_t e = getPropertyDouble ("e");
00058   nr_double_t c = getPropertyDouble ("c");
00059   nr_double_t a = getPropertyDouble ("a");
00060   nr_double_t k = a + c * qucs::pow (frequency, e);
00061   nr_double_t i1 = getPropertyDouble ("i1") / k / kB / T0;
00062   nr_double_t i2 = getPropertyDouble ("i2") / k / kB / T0;
00063   nr_double_t ci = C * std::sqrt (i1 * i2);
00064 
00065   matrix cy = matrix (4);
00066   // entries of source 1
00067   cy.set (NODE_I1P, NODE_I1P, +i1); cy.set (NODE_I1N, NODE_I1N, +i1);
00068   cy.set (NODE_I1P, NODE_I1N, -i1); cy.set (NODE_I1N, NODE_I1P, -i1);
00069   // entries of source 2
00070   cy.set (NODE_I2P, NODE_I2P, +i2); cy.set (NODE_I2N, NODE_I2N, +i2);
00071   cy.set (NODE_I2P, NODE_I2N, -i2); cy.set (NODE_I2N, NODE_I2P, -i2);
00072   // correlation entries
00073   cy.set (NODE_I1P, NODE_I2P, +ci); cy.set (NODE_I1N, NODE_I2N, +ci);
00074   cy.set (NODE_I1P, NODE_I2N, -ci); cy.set (NODE_I1N, NODE_I2P, -ci);
00075   cy.set (NODE_I2P, NODE_I1P, +ci); cy.set (NODE_I2N, NODE_I1N, +ci);
00076   cy.set (NODE_I2P, NODE_I1N, -ci); cy.set (NODE_I2N, NODE_I1P, -ci);
00077   return cy;
00078 }
00079 
00080 void iinoise::calcNoiseAC (nr_double_t frequency) {
00081   setMatrixN (calcMatrixCy (frequency));
00082 }
00083 
00084 // properties
00085 PROP_REQ [] = {
00086   { "i1", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
00087   { "i2", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
00088   { "C", PROP_REAL, { 0.5, PROP_NO_STR }, PROP_RNGII (-1, 1) },
00089   PROP_NO_PROP };
00090 PROP_OPT [] = {
00091   { "a", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
00092   { "c", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
00093   { "e", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
00094   PROP_NO_PROP };
00095 struct define_t iinoise::cirdef =
00096   { "IInoise", 4, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };