Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dcblock.cpp
Go to the documentation of this file.
1 /*
2  * dcblock.cpp - DC block class implementation
3  *
4  * Copyright (C) 2003, 2004, 2005, 2008 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id$
22  *
23  */
24 
25 #if HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 
29 #include "component.h"
30 #include "dcblock.h"
31 
32 using namespace qucs;
33 
34 dcblock::dcblock () : circuit (2) {
35  type = CIR_DCBLOCK;
36 }
37 
38 void dcblock::initSP (void) {
39  allocMatrixS ();
40  setS (NODE_1, NODE_1, 0.0);
41  setS (NODE_2, NODE_2, 0.0);
42  setS (NODE_1, NODE_2, 1.0);
43  setS (NODE_2, NODE_1, 1.0);
44 }
45 
46 void dcblock::initDC (void) {
47  setISource (false);
48  setVoltageSources (0);
49  allocMatrixMNA ();
50 }
51 
52 void dcblock::initAC (void) {
53  setISource (false);
54  setVoltageSources (1);
55  allocMatrixMNA ();
56  voltageSource (VSRC_1, NODE_1, NODE_2);
57 }
58 
59 #define qState 0 // charge state
60 #define cState 1 // current state
61 
62 void dcblock::initTR (void) {
63  setStates (2);
64  initDC ();
65  setISource (true);
66 }
67 
68 void dcblock::calcTR (nr_double_t) {
69  nr_double_t c = getPropertyDouble ("C");
70  nr_double_t g, i;
71  nr_double_t v = real (getV (NODE_1) - getV (NODE_2));
72 
73  setState (qState, c * v);
74  integrate (qState, c, g, i);
75  setY (NODE_1, NODE_1, +g); setY (NODE_2, NODE_2, +g);
76  setY (NODE_1, NODE_2, -g); setY (NODE_2, NODE_1, -g);
77  setI (NODE_1 , -i);
78  setI (NODE_2 , +i);
79 }
80 
81 // properties
82 PROP_REQ [] = {
83  PROP_NO_PROP };
84 PROP_OPT [] = {
85  { "C", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
86  PROP_NO_PROP };
87 struct define_t dcblock::cirdef =
#define PROP_POS_RANGE
Definition: netdefs.h:129
#define NODE_2
Definition: circuit.h:35
matrix real(matrix a)
Real part matrix.
Definition: matrix.cpp:568
#define qState
Definition: dcblock.cpp:59
#define PROP_DEF
Definition: netdefs.h:189
PROP_OPT[]
Definition: acsolver.cpp:232
#define PROP_REAL
Definition: netdefs.h:174
#define PROP_NO_PROP
Definition: netdefs.h:122
#define PROP_NO_STR
Definition: netdefs.h:125
void calcTR(nr_double_t)
Definition: dcblock.cpp:68
#define PROP_LINEAR
Definition: netdefs.h:120
void initDC(void)
Definition: dcblock.cpp:46
void initTR(void)
Definition: dcblock.cpp:62
void initAC(void)
Definition: dcblock.cpp:52
#define VSRC_1
Definition: circuit.h:40
i
Definition: parse_mdl.y:516
PROP_NO_SUBSTRATE
Definition: dcblock.cpp:88
#define PROP_COMPONENT
Definition: netdefs.h:116
nr_complex_t integrate(vector v, const nr_complex_t)
Definition: vector.cpp:1207
type
Definition: parse_vcd.y:164
v
Definition: parse_zvr.y:141
#define NODE_1
Definition: circuit.h:34
PROP_REQ[]
Definition: acsolver.cpp:229
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: dcblock.cpp:38