Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dcfeed.cpp
Go to the documentation of this file.
1 /*
2  * dcfeed.cpp - DC feed 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 "dcfeed.h"
31 
32 using namespace qucs;
33 
34 dcfeed::dcfeed () : circuit (2) {
35  type = CIR_DCFEED;
36 }
37 
38 void dcfeed::initSP (void) {
39  allocMatrixS ();
40  setS (NODE_1, NODE_1, 1.0);
41  setS (NODE_2, NODE_2, 1.0);
42  setS (NODE_1, NODE_2, 0.0);
43  setS (NODE_2, NODE_1, 0.0);
44 }
45 
46 void dcfeed::initDC (void) {
48  allocMatrixMNA ();
50 }
51 
52 void dcfeed::initAC (void) {
54  allocMatrixMNA ();
55 }
56 
57 #define fState 0 // flux state
58 #define vState 1 // voltage state
59 
60 void dcfeed::initTR (void) {
61  initDC ();
62  setStates (2);
63 }
64 
65 void dcfeed::calcTR (nr_double_t) {
66  nr_double_t l = getPropertyDouble ("L");
67  nr_double_t r, v;
68  nr_double_t i = real (getJ (VSRC_1));
69 
70  setState (fState, i * l);
71  integrate (fState, l, r, v);
72  setD (VSRC_1, VSRC_1, -r);
73  setE (VSRC_1, v);
74 }
75 
76 // properties
77 PROP_REQ [] = {
78  PROP_NO_PROP };
79 PROP_OPT [] = {
80  { "L", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
81  PROP_NO_PROP };
82 struct define_t dcfeed::cirdef =
void initTR(void)
Definition: dcfeed.cpp:60
#define PROP_POS_RANGE
Definition: netdefs.h:129
l
Definition: parse_vcd.y:213
#define NODE_2
Definition: circuit.h:35
matrix real(matrix a)
Real part matrix.
Definition: matrix.cpp:568
#define PROP_DEF
Definition: netdefs.h:189
void integrate(int, nr_double_t, nr_double_t &, nr_double_t &)
Definition: integrator.cpp:67
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
void setD(int, int, nr_complex_t)
Definition: circuit.cpp:373
#define PROP_REAL
Definition: netdefs.h:174
void setStates(int n)
Definition: states.h:52
#define PROP_NO_PROP
Definition: netdefs.h:122
void setVoltageSources(int)
Definition: circuit.cpp:607
#define PROP_NO_STR
Definition: netdefs.h:125
void allocMatrixS(void)
Definition: circuit.cpp:251
#define PROP_LINEAR
Definition: netdefs.h:120
r
Definition: parse_mdl.y:515
#define VSRC_1
Definition: circuit.h:40
i
Definition: parse_mdl.y:516
void initAC(void)
Definition: dcfeed.cpp:52
nr_double_t getJ(int, nr_double_t)
Definition: circuit.cpp:951
#define fState
Definition: dcfeed.cpp:57
#define PROP_COMPONENT
Definition: netdefs.h:116
PROP_REQ[]
Definition: dcfeed.cpp:77
void setE(int, nr_complex_t)
Definition: circuit.cpp:385
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: dcfeed.cpp:38
v
Definition: parse_zvr.y:141
void calcTR(nr_double_t)
Definition: dcfeed.cpp:65
void allocMatrixMNA(void)
Definition: circuit.cpp:267
#define NODE_1
Definition: circuit.h:34
void voltageSource(int, int, int, nr_double_t value=0.0)
Definition: circuit.cpp:748
PROP_OPT[]
Definition: dcfeed.cpp:79
void setS(int, int, nr_complex_t)
Definition: circuit.cpp:587
PROP_NO_SUBSTRATE
Definition: dcfeed.cpp:83
void initDC(void)
Definition: dcfeed.cpp:46
void setState(int, state_type_t, int n=0)
Definition: states.cpp:109