Qucs-core  0.0.19
vnoise.cpp
Go to the documentation of this file.
00001 /*
00002  * vnoise.cpp - noise voltage source class implementation
00003  *
00004  * Copyright (C) 2004, 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 "vnoise.h"
00031 
00032 using namespace qucs;
00033 
00034 vnoise::vnoise () : circuit (2) {
00035   type = CIR_VNOISE;
00036   setVoltageSources (1);
00037 }
00038 
00039 void vnoise::initSP (void) {
00040   allocMatrixS ();
00041   setS (NODE_1, NODE_1, 0.0);
00042   setS (NODE_1, NODE_2, 1.0);
00043   setS (NODE_2, NODE_1, 1.0);
00044   setS (NODE_2, NODE_2, 0.0);
00045 }
00046 
00047 void vnoise::calcNoiseSP (nr_double_t frequency) {
00048   nr_double_t u = getPropertyDouble ("u");
00049   nr_double_t e = getPropertyDouble ("e");
00050   nr_double_t c = getPropertyDouble ("c");
00051   nr_double_t a = getPropertyDouble ("a");
00052   nr_double_t vpsd = u / (a + c * qucs::pow (frequency, e)) / kB / T0 / 4 / z0;
00053   setN (NODE_1, NODE_1, +vpsd); setN (NODE_2, NODE_2, +vpsd);
00054   setN (NODE_1, NODE_2, -vpsd); setN (NODE_2, NODE_1, -vpsd);
00055 }
00056 
00057 void vnoise::initDC (void) {
00058   allocMatrixMNA ();
00059   voltageSource (VSRC_1, NODE_1, NODE_2);
00060 }
00061 
00062 void vnoise::initTR (void) {
00063   initDC ();
00064 }
00065 
00066 void vnoise::initAC (void) {
00067   initDC ();
00068 }
00069 
00070 void vnoise::calcNoiseAC (nr_double_t frequency) {
00071   nr_double_t u = getPropertyDouble ("u");
00072   nr_double_t e = getPropertyDouble ("e");
00073   nr_double_t c = getPropertyDouble ("c");
00074   nr_double_t a = getPropertyDouble ("a");
00075   nr_double_t ipsd = u / (a + c * qucs::pow (frequency, e)) / kB / T0;
00076   setN (NODE_3, NODE_3, +ipsd);
00077 }
00078 
00079 // properties
00080 PROP_REQ [] = {
00081   { "u", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
00082   PROP_NO_PROP };
00083 PROP_OPT [] = {
00084   { "a", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
00085   { "c", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
00086   { "e", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
00087   PROP_NO_PROP };
00088 struct define_t vnoise::cirdef =
00089   { "Vnoise", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };