Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hbsolver.h
Go to the documentation of this file.
1 /*
2  * hbsolver.h - harmonic balance solver class definitions
3  *
4  * Copyright (C) 2005, 2006, 2007, 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 #ifndef __HBSOLVER_H__
26 #define __HBSOLVER_H__
27 
28 #include "ptrlist.h"
29 #include "tvector.h"
30 
31 namespace qucs {
32 
33 class vector;
34 class strlist;
35 class circuit;
36 
37 class hbsolver : public analysis
38 {
39  public:
41  hbsolver (char *);
42  hbsolver (hbsolver &);
43  ~hbsolver ();
44  int solve (void);
45  void initHB (void);
46  void initDC (void);
47  static void calc (hbsolver *);
48  void collectFrequencies (void);
49  int checkBalance (void);
50 
51  void splitCircuits (void);
52  void expandFrequencies (nr_double_t, int);
53  bool isExcitation (circuit *);
54  strlist * circuitNodes (ptrlist<circuit>);
55  void getNodeLists (void);
56  int assignVoltageSources (ptrlist<circuit>);
57  int assignNodes (ptrlist<circuit>, strlist *, int offset = 0);
58  void prepareLinear (void);
59  void createMatrixLinearA (void);
60  void fillMatrixLinearA (tmatrix<nr_complex_t> *, int);
61  void invertMatrix (tmatrix<nr_complex_t> *, tmatrix<nr_complex_t> *);
62  void createMatrixLinearY (void);
63  void saveResults (void);
64  void calcConstantCurrent (void);
65  nr_complex_t excitationZ (tvector<nr_complex_t> *, circuit *, int);
66  void finalSolution (void);
67  void fillMatrixNonLinear (tmatrix<nr_complex_t> *, tmatrix<nr_complex_t> *,
68  tvector<nr_complex_t> *, tvector<nr_complex_t> *,
69  tvector<nr_complex_t> *, tvector<nr_complex_t> *,
70  int);
71  void prepareNonLinear (void);
72  void solveHB (void);
73  void loadMatrices (void);
74  void VectorFFT (tvector<nr_complex_t> *, int isign = 1);
75  void VectorIFFT (tvector<nr_complex_t> *, int isign = 1);
76  int calcOrder (int);
77  void MatrixFFT (tmatrix<nr_complex_t> *);
78  void calcJacobian (void);
79  void solveVoltages (void);
80  tvector<nr_complex_t> expandVector (tvector<nr_complex_t>, int);
81  tmatrix<nr_complex_t> expandMatrix (tmatrix<nr_complex_t>, int);
82  tmatrix<nr_complex_t> extendMatrixLinear (tmatrix<nr_complex_t>, int);
83  void fillMatrixLinearExtended (tmatrix<nr_complex_t> *,
84  tvector<nr_complex_t> *);
85  void saveNodeVoltages (circuit *, int);
86 
87  private:
88  tvector<nr_double_t> negfreqs; // full frequency set
89  tvector<nr_double_t> posfreqs; // full frequency set but positive
90  tvector<nr_double_t> rfreqs; // real positive frequency set
91  int * ndfreqs; // number of frequencies for each dimension
92  tvector<nr_double_t> dfreqs; // base frequencies for each dimension
93  nr_double_t frequency;
95  ptrlist<circuit> excitations;
96  ptrlist<circuit> nolcircuits;
97  ptrlist<circuit> lincircuits;
98 
99  tmatrix<nr_complex_t> * Y; // transadmittance matrix of linear network
100  tmatrix<nr_complex_t> * A; // MNA-matrix of linear network
101  tmatrix<nr_complex_t> * Z; // transimpedance matrix of linear network
102 
103  tmatrix<nr_complex_t> * YV; // linear transadmittance matrix
104  tmatrix<nr_complex_t> * NA; // MNA-matrix of complete network
105 
106  tmatrix<nr_complex_t> * JQ; // C-Jacobian in t and f
107  tmatrix<nr_complex_t> * JG; // G-Jacobian in t and f
108  tmatrix<nr_complex_t> * JF; // full Jacobian for non-linear balancing
109  tvector<nr_complex_t> * IG; // currents in t and f
110  tvector<nr_complex_t> * FQ; // charges in t and f
113  tvector<nr_complex_t> * FV; // error vector F(V) of HB equation
114  tvector<nr_complex_t> * IL; // currents into linear network
115  tvector<nr_complex_t> * IN; // currents into non-linear network
116 
121 
122  tvector<nr_complex_t> * IC; // source currents into balanced nodes
123  tvector<nr_complex_t> * IS; // currents through sources themselves
126 
127  int runs;
128  int lnfreqs;
129  int nlfreqs;
130  int nnlvsrcs;
131  int nlnvsrcs;
132  int nlnnodes;
133  int nnanodes;
134  int nexnodes;
135  int nbanodes;
136 };
137 
138 } // namespace qucs
139 
140 #endif /* __HBSOLVER_H__ */
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
tmatrix< nr_complex_t > * YV
Definition: hbsolver.h:103
bool isExcitation(circuit *)
Definition: hbsolver.cpp:324
tmatrix< nr_complex_t > * Y
Definition: hbsolver.h:99
strlist * banodes
Definition: hbsolver.h:94
int checkBalance(void)
Definition: hbsolver.cpp:925
int assignVoltageSources(ptrlist< circuit >)
Definition: hbsolver.cpp:513
void initDC(void)
Definition: hbsolver.cpp:316
void VectorFFT(tvector< nr_complex_t > *, int isign=1)
Definition: hbsolver.cpp:1092
int calcOrder(int)
Definition: hbsolver.cpp:365
tvector< nr_complex_t > * FQ
Definition: hbsolver.h:110
void MatrixFFT(tmatrix< nr_complex_t > *)
Definition: hbsolver.cpp:1126
tvector< nr_complex_t > * RH
Definition: hbsolver.h:119
void loadMatrices(void)
Definition: hbsolver.cpp:1070
strlist * exnodes
Definition: hbsolver.h:94
void collectFrequencies(void)
Definition: hbsolver.cpp:374
tmatrix< nr_complex_t > * NA
Definition: hbsolver.h:104
tvector< nr_complex_t > * IR
Definition: hbsolver.h:117
tvector< nr_complex_t > * IL
Definition: hbsolver.h:114
void calcJacobian(void)
Definition: hbsolver.cpp:1204
void calcConstantCurrent(void)
Definition: hbsolver.cpp:871
tvector< nr_complex_t > * vs
Definition: hbsolver.h:125
tvector< nr_complex_t > * FV
Definition: hbsolver.h:113
tvector< nr_complex_t > * IC
Definition: hbsolver.h:122
void saveResults(void)
Definition: hbsolver.cpp:1392
ACREATOR(hbsolver)
void VectorIFFT(tvector< nr_complex_t > *, int isign=1)
Definition: hbsolver.cpp:1120
void invertMatrix(tmatrix< nr_complex_t > *, tmatrix< nr_complex_t > *)
Definition: hbsolver.cpp:649
hbsolver(char *)
Definition: hbsolver.cpp:70
void expandFrequencies(nr_double_t, int)
Definition: hbsolver.cpp:332
void getNodeLists(void)
Definition: hbsolver.cpp:471
tmatrix< nr_complex_t > * JF
Definition: hbsolver.h:108
ptrlist< circuit > nolcircuits
Definition: hbsolver.h:96
int assignNodes(ptrlist< circuit >, strlist *, int offset=0)
Definition: hbsolver.cpp:526
tmatrix< nr_complex_t > * JG
Definition: hbsolver.h:107
strlist * circuitNodes(ptrlist< circuit >)
Definition: hbsolver.cpp:456
static void calc(hbsolver *)
Definition: hbsolver.cpp:298
strlist * lnnodes
Definition: hbsolver.h:94
tvector< nr_double_t > posfreqs
Definition: hbsolver.h:89
tvector< nr_double_t > dfreqs
Definition: hbsolver.h:92
void solveVoltages(void)
Definition: hbsolver.cpp:1271
void prepareLinear(void)
Definition: hbsolver.cpp:546
void fillMatrixLinearExtended(tmatrix< nr_complex_t > *, tvector< nr_complex_t > *)
Definition: hbsolver.cpp:1314
void splitCircuits(void)
Definition: hbsolver.cpp:437
int solve(void)
placehoder for solution function
Definition: hbsolver.cpp:145
void createMatrixLinearY(void)
Definition: hbsolver.cpp:711
void prepareNonLinear(void)
Definition: hbsolver.cpp:993
tvector< nr_double_t > rfreqs
Definition: hbsolver.h:90
void saveNodeVoltages(circuit *, int)
Definition: hbsolver.cpp:1058
tmatrix< nr_complex_t > * Z
Definition: hbsolver.h:101
tvector< nr_complex_t > * VS
Definition: hbsolver.h:111
tvector< nr_complex_t > * x
Definition: hbsolver.h:124
tvector< nr_complex_t > * VP
Definition: hbsolver.h:112
void initHB(void)
Definition: hbsolver.cpp:307
strlist * nanodes
Definition: hbsolver.h:94
nr_double_t frequency
Definition: hbsolver.h:93
tmatrix< nr_complex_t > expandMatrix(tmatrix< nr_complex_t >, int)
Definition: hbsolver.cpp:1245
tvector< nr_complex_t > * QR
Definition: hbsolver.h:118
tvector< nr_complex_t > * IS
Definition: hbsolver.h:123
void fillMatrixLinearA(tmatrix< nr_complex_t > *, int)
Definition: hbsolver.cpp:597
int * ndfreqs
Definition: hbsolver.h:91
void fillMatrixNonLinear(tmatrix< nr_complex_t > *, tmatrix< nr_complex_t > *, tvector< nr_complex_t > *, tvector< nr_complex_t > *, tvector< nr_complex_t > *, tvector< nr_complex_t > *, int)
Definition: hbsolver.cpp:961
tvector< nr_complex_t > expandVector(tvector< nr_complex_t >, int)
Definition: hbsolver.cpp:1224
tvector< nr_complex_t > * IG
Definition: hbsolver.h:109
tvector< nr_complex_t > * IN
Definition: hbsolver.h:115
void finalSolution(void)
Definition: hbsolver.cpp:1346
nr_complex_t excitationZ(tvector< nr_complex_t > *, circuit *, int)
Definition: hbsolver.cpp:857
ptrlist< circuit > excitations
Definition: hbsolver.h:95
tmatrix< nr_complex_t > * JQ
Definition: hbsolver.h:106
tvector< nr_double_t > negfreqs
Definition: hbsolver.h:88
void createMatrixLinearA(void)
Definition: hbsolver.cpp:563
strlist * nlnodes
Definition: hbsolver.h:94
tmatrix< nr_complex_t > extendMatrixLinear(tmatrix< nr_complex_t >, int)
Definition: hbsolver.cpp:1298
ptrlist< circuit > lincircuits
Definition: hbsolver.h:97
tmatrix< nr_complex_t > * A
Definition: hbsolver.h:100
void solveHB(void)
Definition: hbsolver.cpp:1173
tvector< nr_complex_t > * OM
Definition: hbsolver.h:120