My Project
0.0.16
QUCS Mapping
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
DownLoad
QUCS-src
qucs-0.0.16
qucs-core
src
nasolver.h
Go to the documentation of this file.
1
/*
2
* nasolver.h - nodal analysis solver class definitions
3
*
4
* Copyright (C) 2004, 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: nasolver.h 1825 2011-03-11 20:42:14Z ela $
22
*
23
*/
24
25
#ifndef __NASOLVER_H__
26
#define __NASOLVER_H__
27
28
#include "
tvector.h
"
29
#include "
tmatrix.h
"
30
#include "
eqnsys.h
"
31
#include "
nasolution.h
"
32
33
// Convergence helper definitions.
34
#define CONV_None 0
35
#define CONV_Attenuation 1
36
#define CONV_LineSearch 2
37
#define CONV_SteepestDescent 3
38
#define CONV_GMinStepping 4
39
#define CONV_SourceStepping 5
40
41
class
analysis
;
42
class
circuit
;
43
class
nodelist
;
44
class
vector
;
45
46
template
<
class
nr_type_t>
47
class
nasolver
:
public
analysis
48
{
49
public
:
50
nasolver
();
51
nasolver
(
char
*);
52
nasolver
(
nasolver
&);
53
~nasolver
();
54
int
solve_once
(
void
);
55
int
solve_nonlinear
(
void
);
56
int
solve_nonlinear_continuation_gMin
(
void
);
57
int
solve_nonlinear_continuation_Source
(
void
);
58
int
solve_linear
(
void
);
59
void
solve_pre
(
void
);
60
void
solve_post
(
void
);
61
void
setDescription
(
const
char
*
n
) { desc =
n
; }
62
const
char
*
getDescription
(
void
) {
return
desc; }
63
void
saveResults
(
const
char
*,
const
char
*,
int
,
vector
* f = NULL);
64
typedef
void (*
calculate_func_t
) (
nasolver<nr_type_t>
*);
65
void
setCalculation
(
calculate_func_t
f) { calculate_func = f; }
66
void
calculate
(
void
) {
if
(calculate_func) (*calculate_func) (
this
); }
67
const
char
*
getHelperDescription
(
void
);
68
69
protected
:
70
void
restartNR
(
void
);
71
void
savePreviousIteration
(
void
);
72
void
restorePreviousIteration
(
void
);
73
int
countNodes
(
void
);
74
int
getNodeNr
(
char
*);
75
int
findAssignedNode
(
circuit
*,
int
);
76
int
countVoltageSources
(
void
);
77
void
saveSolution
(
void
);
78
circuit
*
findVoltageSource
(
int
);
79
void
applyNodeset
(
bool
nokeep =
true
);
80
void
createNoiseMatrix
(
void
);
81
void
runMNA
(
void
);
82
void
createMatrix
(
void
);
83
void
storeSolution
(
void
);
84
void
recallSolution
(
void
);
85
86
private
:
87
void
assignVoltageSources (
void
);
88
void
createGMatrix (
void
);
89
void
createBMatrix (
void
);
90
void
createCMatrix (
void
);
91
void
createDMatrix (
void
);
92
void
createIVector (
void
);
93
void
createEVector (
void
);
94
void
createZVector (
void
);
95
void
applyAttenuation (
void
);
96
void
lineSearch (
void
);
97
void
steepestDescent (
void
);
98
char
* createV (
int
,
const
char
*,
int
);
99
char
* createI (
int
,
const
char
*,
int
);
100
char
* createOP (
const
char
*,
const
char
*);
101
void
saveNodeVoltages (
void
);
102
void
saveBranchCurrents (
void
);
103
int
checkConvergence (
void
);
104
nr_type_t MatValX (
nr_complex_t
,
nr_complex_t
*);
105
nr_type_t MatValX (
nr_complex_t
, nr_double_t *);
106
107
protected
:
108
tvector<nr_type_t>
*
z
;
109
tvector<nr_type_t>
*
x
;
110
tvector<nr_type_t>
*
xprev
;
111
tvector<nr_type_t>
*
zprev
;
112
tmatrix<nr_type_t>
*
A
;
113
tmatrix<nr_type_t>
*
C
;
114
int
iterations
;
115
int
convHelper
;
116
int
fixpoint
;
117
int
eqnAlgo
;
118
int
updateMatrix
;
119
nr_double_t
gMin
,
srcFactor
;
120
121
private
:
122
nodelist
* nlist;
123
eqnsys<nr_type_t>
* eqns;
124
nr_double_t reltol;
125
nr_double_t abstol;
126
nr_double_t vntol;
127
nasolution<nr_type_t>
solution;
128
129
private
:
130
const
char
* desc;
131
calculate_func_t
calculate_func;
132
};
133
134
#include "
nasolver.cpp
"
135
136
#endif
/* __NASOLVER_H__ */
Generated on Tue Dec 25 2012 14:30:34 for My Project by
1.8.2