MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
gpc.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/elec/gpc.h,v 1.21 2017/01/12 14:46:22 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #ifndef GPC_H
33 #define GPC_H
34 
35 #include <ac/f2c.h>
36 #include <drive.h>
37 
38 #ifdef USE_MESCHACH
39 extern "C" {
40 #include <meschach/matrix2.h>
41 }
42 #endif /* USE_MESCHACH */
43 
44 
45 /*
46  * classe di routines che consentono di invertire matrici;
47  * allocano autonomamente lo spazio di lavoro lo gestiscono e lo distruggono;
48  * usate per l'inversione delle matrici nel progetto dei controllori
49  */
50 
51 /* GPCInv - begin */
52 
53 class GPCInv {
54 protected:
56 
57 public:
58  GPCInv(void);
59  virtual ~GPCInv(void);
60 
61  virtual integer Inv(integer ndima, integer nrowa,
62  integer ncola, doublereal* a) = 0;
63 };
64 
65 /* GPCInv - end */
66 
67 
68 /*
69  * si appoggia sulla routine LAPACK dgesvd() che esegue la decomposizione SVD;
70  * quindi la pseudoinversa viene ricostruita in loco, orientata per righe
71  */
72 
73 /* GPC_LAPACK_pinv - begin */
74 
75 class GPC_LAPACK_pinv : public GPCInv {
76 protected:
77  integer m; /* in realta' non servono, e' solo per sicurezza */
79 
82 
83  integer iWork; /* per ridimensionare pdWork */
84 
89 
90 public:
92  ~GPC_LAPACK_pinv(void);
93  integer Inv(integer ndima, integer nrowa, integer ncola, doublereal* a);
94 };
95 
96 /* GPC_LAPACK_pinv - end */
97 
98 
99 #ifdef USE_MESCHACH
100 /* GPC_Meschach_QRinv - begin */
101 
102 class GPC_Meschach_QRinv : public GPCInv {
103 protected:
104  integer m; /* in realta' non servono, e' solo per sicurezza */
105  integer n;
106 
107  MAT* A;
108  VEC* diag;
109  VEC* x;
110  VEC* b;
111  PERM* pivot;
112 
113 public:
114  GPC_Meschach_QRinv(integer m, integer n);
115  ~GPC_Meschach_QRinv(void);
116  integer Inv(integer ndima, integer nrowa, integer ncola, doublereal* a);
117 };
118 
119 /* GPC_Meschach_QRinv - end */
120 #endif /* USE_MESCHACH */
121 
122 
123 /*
124  * Progetta le matrici di controllo per un controllore discreto MIMO
125  * a partire dal sistema identificato
126  */
127 
128 /* GPCDesigner - begin */
129 
130 class GPCDesigner {
131 protected:
136 
137  integer iPredStep; /* passo della predizione piu' in avanti */
138  integer iContrStep; /* passo del controllo piu' avanti */
139  integer iPredHor; /* passo iniziale della predizione */
140  integer iContrHor; /* passo iniziale del controllo (sempre 0) */
141 
143 
145 
150 
155 
156 public:
157  GPCDesigner(integer iNumOut, integer iNumIn,
158  integer iOrdA, integer iOrdB,
159  integer iPredS, integer iContrS,
160  integer iPredH, integer iContrH,
161  doublereal dPF);
162 
163  virtual ~GPCDesigner(void);
164 
165  virtual void DesignControl(const doublereal* /* pdTheta */ ,
166  doublereal** ppda = NULL,
167  doublereal** ppdb = NULL,
168  doublereal** ppdm = NULL,
169  doublereal** ppdc = NULL);
170 
171  inline doublereal* pdGetAc(void) const;
172  inline doublereal* pdGetBc(void) const;
173  inline doublereal* pdGetMd(void) const;
174  inline doublereal* pdGetCc(void) const;
175 
176  inline integer iGetPredStep(void) const;
177  inline integer iGetContrStep(void) const;
178  inline integer iGetPredHor(void) const;
179  inline integer iGetContrHor(void) const;
180 };
181 
182 inline doublereal*
184 {
185  return pdac;
186 }
187 
188 inline doublereal*
190 {
191  return pdbc;
192 }
193 
194 inline doublereal*
196 {
197  return pdmd;
198 }
199 
200 inline doublereal*
202 {
203  return pdcc;
204 }
205 
206 inline integer
208 {
209  return iPredStep;
210 }
211 
212 inline integer
214 {
215  return iContrStep;
216 }
217 
218 inline integer
220 {
221  return iPredHor;
222 }
223 
224 inline integer
226 {
227  return iContrHor;
228 }
229 
230 /* GPCControlDesigner - end */
231 
232 
233 /*
234  * progetta un controllore deadbeat basato su un sistema ARX o ARMAX
235  */
236 
237 /* DeadBeat - begin */
238 
239 #ifdef USE_DBC
240 class DeadBeat : public GPCDesigner{
241 protected:
242  integer iDim;
243  integer iTmpRows;
244  integer iTmpCols;
245 
246  doublereal* pdPTmp;
247 
248  flag f_armax;
249 
250  GPCInv* pInv;
251 
252 public:
253  DeadBeat(integer iNumOut, integer iNumIn, integer iOrdA, integer iOrdB,
254  integer iPredS, integer iContrS, doublereal dPF, flag f);
255  virtual ~DeadBeat(void);
256 
257  void DesignControl(const doublereal* pdTheta,
258  doublereal** ppda = NULL, doublereal** ppdb = NULL,
259  doublereal** ppdm = NULL, doublereal** ppdc = NULL);
260 };
261 #endif /* USE_DBC */
262 
263 /* DeadBeat - end */
264 
265 
266 /*
267  * progetta un controllore GPC basato su un sistema ARX o ARMAX
268  */
269 
270 /* GPC - begin */
271 
272 class GPC : public GPCDesigner{
273 protected:
277 
279 
283 
286 
288 
290 
291 public:
292  GPC(integer iNumOut, integer iNumIn, integer iOrdA, integer iOrdB,
293  integer iPredS, integer iContrS, integer iPredH, integer iContrH,
294  doublereal* pW, doublereal* pR, DriveCaller* pDC, doublereal dPF,
295  flag f);
296 
297  virtual ~GPC(void);
298 
299  void DesignControl(const doublereal* pdTheta,
300  doublereal** ppda = NULL, doublereal** ppdb = NULL,
301  doublereal** ppdm = NULL, doublereal** ppdc = NULL);
302 };
303 
304 /* GPC - end */
305 
306 #endif /* GPC_H */
307 
doublereal * pdW
Definition: gpc.h:280
integer iGetContrHor(void) const
Definition: gpc.h:225
DriveOwner Weight
Definition: gpc.h:282
virtual ~GPCDesigner(void)
Definition: gpc.cc:811
doublereal * pdInvP
Definition: gpc.h:285
long int flag
Definition: mbdyn.h:43
integer iPredStep
Definition: gpc.h:137
doublereal * pdA
Definition: gpc.h:146
integer n
Definition: gpc.h:78
doublereal * pdWork
Definition: gpc.h:88
GPCInv * pInv
Definition: gpc.h:289
integer iGetContrStep(void) const
Definition: gpc.h:213
doublereal * pdBase
Definition: gpc.h:144
doublereal * pdGetAc(void) const
Definition: gpc.h:183
doublereal * pdac
Definition: gpc.h:151
GPC(integer iNumOut, integer iNumIn, integer iOrdA, integer iOrdB, integer iPredS, integer iContrS, integer iPredH, integer iContrH, doublereal *pW, doublereal *pR, DriveCaller *pDC, doublereal dPF, flag f)
doublereal * pdM
Definition: gpc.h:284
doublereal * pdVt
Definition: gpc.h:87
doublereal dPeriodicFactor
Definition: gpc.h:142
doublereal * pdBase
Definition: gpc.h:55
virtual integer Inv(integer ndima, integer nrowa, integer ncola, doublereal *a)=0
doublereal * pdPTmp
Definition: gpc.h:278
virtual ~GPC(void)
doublereal * pdS
Definition: gpc.h:85
integer iMax
Definition: gpc.h:81
integer iContrHor
Definition: gpc.h:140
integer iOrderB
Definition: gpc.h:135
integer iTmpRows
Definition: gpc.h:275
integer iTmpCols
Definition: gpc.h:276
Definition: gpc.h:53
integer iDim
Definition: gpc.h:274
integer m
Definition: gpc.h:77
doublereal * pdU
Definition: gpc.h:86
integer iOrderA
Definition: gpc.h:134
doublereal * pdC
Definition: gpc.h:149
integer Inv(integer ndima, integer nrowa, integer ncola, doublereal *a)
Definition: gpc.cc:662
integer iMin
Definition: gpc.h:80
integer iNumOutputs
Definition: gpc.h:132
doublereal * pdbc
Definition: gpc.h:152
void DesignControl(const doublereal *pdTheta, doublereal **ppda=NULL, doublereal **ppdb=NULL, doublereal **ppdm=NULL, doublereal **ppdc=NULL)
integer iNumInputs
Definition: gpc.h:133
doublereal * pdR
Definition: gpc.h:281
doublereal * pdP
Definition: gpc.h:148
doublereal * pdGetCc(void) const
Definition: gpc.h:201
doublereal * pdB
Definition: gpc.h:147
~GPC_LAPACK_pinv(void)
Definition: gpc.cc:652
GPCDesigner(integer iNumOut, integer iNumIn, integer iOrdA, integer iOrdB, integer iPredS, integer iContrS, integer iPredH, integer iContrH, doublereal dPF)
Definition: gpc.cc:781
virtual ~GPCInv(void)
Definition: gpc.cc:588
doublereal * pdcc
Definition: gpc.h:154
doublereal * pdGetMd(void) const
Definition: gpc.h:195
integer iGetPredHor(void) const
Definition: gpc.h:219
static const doublereal a
Definition: hfluid_.h:289
integer iGetPredStep(void) const
Definition: gpc.h:207
doublereal * pdmd
Definition: gpc.h:153
Definition: gpc.h:272
virtual void DesignControl(const doublereal *, doublereal **ppda=NULL, doublereal **ppdb=NULL, doublereal **ppdm=NULL, doublereal **ppdc=NULL)
Definition: gpc.cc:818
integer iWork
Definition: gpc.h:83
double doublereal
Definition: colamd.c:52
integer iContrStep
Definition: gpc.h:138
long int integer
Definition: colamd.c:51
flag f_armax
Definition: gpc.h:287
doublereal * pdGetBc(void) const
Definition: gpc.h:189
GPCInv(void)
Definition: gpc.cc:582
GPC_LAPACK_pinv(integer n, integer m)
Definition: gpc.cc:600
integer iPredHor
Definition: gpc.h:139