COPASI API  4.16.103
CCSPMethod.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/tssanalysis/CCSPMethod.h,v $
3 // $Revision: 1.14 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/06/05 13:33:03 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_CCSPMethod
24 #define COPASI_CCSPMethod
25 
26 #include <sstream>
27 #include "utilities/CVector.h"
28 #include "utilities/CMatrix.h"
29 
31 
32 #include "odepack++/CLSODA.h"
33 
34 class CModel;
35 class CState;
36 
37 class CCSPMethod : public CTSSAMethod
38 {
39  friend CTSSAMethod *
41 
42 public:
43 
44  /**
45  * CSP related staff
46  */
47 
48  /**
49  * Unit matrix
50  */
52 
53  /**
54  * A value related to a measure of the time scale separation of the fast and slow modes
55  */
57 
58  /**
59  * An alternative value related to a mesure of the time scale separation of the fast and slow modes
60  */
62 
63  /**
64  * A maximux relative error
65  */
67 
68  /**
69  * A maximux absolute error
70  */
72 
73  /**
74  * Max number of the refinement iterations
75  */
77 
78  /**
79  * A vector of the current right hand side
80  */
82 
83  /**
84  * An error vector build on the basis of the solution vector
85  */
87 
88  /**
89  * The basis vectors B from the time step (T - delta T)
90  */
92 
94  /**
95  * indicates whether the basis vectors B were computed on the time step (T - delta T)
96  */
98 
99  /**
100  * CSP Output
101  */
102 
104 
105  /**
106  * Amplitudes of reaction modes (column vector);
107  **/
108 
110 
111  /**
112  * Radical Pointer: whenever is not a small number, species k is said to be CSP radical
113  **/
114 
116 
117  /**
118  * Fast Reaction Pointer of the m-th reaction mode : whenever is not a small number,
119  * the r-th reaction is said to be a fast reaction
120  **/
121 
124 
125  /**
126  * Participation Index : is a mesure of participation of the r-th elementary reaction
127  * to the balancing act of the i-th mode (matrix)
128  **/
129 
135 
136  /**
137  * Importance Index: is a measure of relative importance of the contribution of r-th elementary
138  * reaction to the current reaction rate of i-th species
139  **/
140 
143 
144  // Operations
145 private:
146  /**
147  * Default constructor.
148  * @param const CCopasiContainer * pParent (default: NULL)
149  */
150  CCSPMethod(const CCopasiContainer * pParent = NULL);
151 
152 public:
153  /**
154  * Copy constructor.
155  * @param "const CCSPMethod &" src
156  * @param const CCopasiContainer * pParent (default: NULL)
157  */
158  CCSPMethod(const CCSPMethod & src,
159  const CCopasiContainer * pParent = NULL);
160 
161  /**
162  * Destructor.
163  */
164  ~CCSPMethod();
165 
166  /**
167  * This instructs the method to calculate a time step of deltaT
168  * starting with the current state, i.e., the result of the previous
169  * step.
170  * The new state (after deltaT) is expected in the current state.
171  * The return value is the actual timestep taken.
172  * @param "const double &" deltaT
173  */
174  virtual void step(const double & deltaT);
175 
176  /**
177  * This instructs the method to prepare for integration
178  * starting with the initialState given.
179  * @param "const CState *" initialState
180  */
181  virtual void start(const CState * initialState);
182 
183  /**
184  * Intialize the method parameter
185  */
186  void initializeParameter();
187 
188  /**
189  * CSP related staff
190  */
191 
192  /**
193  * Multiplication of submatrix
194  */
195 
197 
198  /**
199  * Substruction of submatrix
200  */
201 
203 
204  /**
205  * Addition of submatrix
206  */
207 
209 
210  /**
211  * Normalize submatrix
212  */
213 
214  void smnorm(C_INT & n, CMatrix< C_FLOAT64 > & A, CMatrix< C_FLOAT64 > & B, C_INT & n1);
215 
216  /**
217  * TEST: perturbate basis vectors A
218  */
219 
220  void perturbateA(C_INT & n, CMatrix< C_FLOAT64 > & A, C_FLOAT64 delta);
221 
222  /**
223  * Inverse submatrix
224  */
225 
227 
228  /**
229  * compute amplitudes of fast and slow modes
230  **/
231 
233 
234  /**
235  * compute CSP radical pointer and fast reaction pointers
236  **/
237 
239 
240  /**
241  * compute CSP Participation Index
242  **/
243 
244  void CSPParticipationIndex(C_INT & N, C_INT & M, C_FLOAT64 & tauM1, CMatrix< C_FLOAT64 > & B0); //NEW
245 
246  /**
247  * compute CSP Importance Index
248  **/
249 
250  void CSPImportanceIndex(C_INT & N, C_FLOAT64 & tauM1, CMatrix< C_FLOAT64 > & Q);
251 
252  /**
253  * correct for the contribution of the fast time-scales to y
254  **/
256 
257  /**
258  * Refinement Procedre :
259  * Lamm, Combustion Science and Technoligy, 1993.
260  **/
262 
263  /**
264  * evaluate Jacobian for the current y
265  **/
266  //void calculateJacobianX(C_INT & n, CVector<C_FLOAT64> & y, CMatrix <C_FLOAT64> & J);
268 
269  /**
270  * find the new number of fast according to the time-scale separation ratio
271  **/
272  void findTimeScaleSeparation(C_INT & n, C_INT & k, CVector< C_FLOAT64 > & tsc, C_INT & info);
273 
274  /**
275  * find the number of candidates to fast according to the time-scale separation ratio
276  **/
277  void findCandidatesNumber(C_INT & n, C_INT & k, CVector< C_FLOAT64 > & tsc, C_INT & info);
278 
279  /**
280  * check : whether each of the analysed M modes is exhausted
281  **/
282 
284 
285  /**
286  * compute the norm C of the off-diagonal blocks
287  **/
289 
290  /**
291  * Start procedure of the CSP algorithm.
292  * S.H. Lam and D.A. Gaussis, International Journal of Chemical Kinetics,
293  * 26, pp. 461-486, 1994
294  */
295  void cspstep(const double & deltaT, C_INT & n, C_INT & m, CMatrix< C_FLOAT64 > & A, CMatrix< C_FLOAT64 > & B);
296 
297  /**
298  * CSP output : empty
299  **/
300 
301  void emptyOutputData(C_INT & N, C_INT & M, C_INT & R);
302 
303  /**
304  * CSP output
305  **/
306 
307  void CSPOutput(C_INT & N, C_INT & M, C_INT & R);
308 
309  /**
310  *vectors contain whole data for all calculation steps
311  **/
312  std::vector< CMatrix<C_FLOAT64> > mVec_mAmplitude;
313  std::vector< CMatrix<C_FLOAT64> > mVec_mRadicalPointer;
314  std::vector< CMatrix<C_FLOAT64> > mVec_mFastReactionPointer;
315  std::vector< CMatrix<C_FLOAT64> > mVec_mFastReactionPointerNormed;
316  std::vector< CMatrix<C_FLOAT64> > mVec_mParticipationIndex;
317  std::vector< CMatrix<C_FLOAT64> > mVec_mParticipationIndexNormedRow;
318  std::vector< CMatrix<C_FLOAT64> > mVec_mParticipationIndexNormedColumn;
319  std::vector< CMatrix<C_FLOAT64> > mVec_mFastParticipationIndex;
320  std::vector< CMatrix<C_FLOAT64> > mVec_mSlowParticipationIndex;
321  std::vector< CMatrix<C_FLOAT64> > mVec_mImportanceIndex;
322  std::vector< CMatrix<C_FLOAT64> > mVec_mImportanceIndexNormedRow;
323 
324  /**
325  *CArraAnnotations for CQTSSAResultSubWidget
326  **/
327 
328  /*
329  std::map< std::string, CArrayAnnotation* > mapTableToName;
330  std::vector<std::string> tableNames;
331  */
332 
344 
345  /**
346  *required for creation of above listed CArrayAnnotation
347  **/
355 
358 
361 
362  /**
363  *input for every CArraAnnotations
364  *contain data for single stepcalculation
365  **/
375 
378 
379  /**
380  * return CArrayAnnotation for visualization
381  * in the CQTSSAResultSubWidget
382  **/
383 
384  /*
385  const std::vector<std::string> getTableName() const
386  {return tableNames;}
387  */
388 
390  {return pAmplitudeAnn;}
392  {return pRadicalPointerAnn;}
394  {return pFastReactionPointerAnn;}
398  {return pParticipationIndexAnn;}
408  {return pImportanceIndexAnn;}
411 
412  /**
413  * upgrade all vectors with values from actually calculalion for current step
414  **/
415  void setVectors(int fast);
416 
417 
418  /**
419  * set vectors to NaN when the reduction was not possible
420  **/
421  void setVectorsToNaN();
422 
423  /**
424  * empty every vector to be able to fill them with new values for a
425  * new calculation also nullify the step counter
426  **/
427  void emptyVectors();
428 
429  /**
430  * create the CArraAnnotations for every table in the CQTSSAResultSubWidget
431  * input for each CArraAnnotations is a seperate CMatrix
432  **/
433  void createAnnotationsM();
434 
435  /**
436  * Predifine the CArrayAnnotation for plots
437  **/
438 
439  virtual void predifineAnnotation();
440 
441 
442 
443  /**
444  * set the every CArrayAnnotation for the requested step
445  * set the desription of CArayAnnotation for both dimensions
446  **/
447  //void setAnnotationM(int step);
448  virtual bool setAnnotationM(size_t step);
449 
450  /**
451  * print of the standart report sequence for ILDM Method
452  * @param std::ostream * ostream
453  **/
454  void printResult(std::ostream * ostream) const;
455 };
456 #endif // COPASI_CCSPMethod
void CSPParticipationIndex(C_INT &N, C_INT &M, C_FLOAT64 &tauM1, CMatrix< C_FLOAT64 > &B0)
std::vector< CMatrix< C_FLOAT64 > > mVec_mImportanceIndex
Definition: CCSPMethod.h:321
#define C_INT
Definition: copasi.h:115
CMatrix< C_FLOAT64 > mAmplitudeTab
Definition: CCSPMethod.h:366
CCSPMethod(const CCopasiContainer *pParent=NULL)
Definition: CCSPMethod.cpp:36
const CArrayAnnotation * getSlowParticipationIndexAnn() const
Definition: CCSPMethod.h:405
CMatrix< C_FLOAT64 > mParticipationIndexNormedColumn
Definition: CCSPMethod.h:132
CArrayAnnotation * pParticipationIndexNormedRowAnn
Definition: CCSPMethod.h:338
CArrayAnnotation * pSlowParticipationIndexAnn
Definition: CCSPMethod.h:341
CMatrix< C_FLOAT64 > mParticipationIndexTab
Definition: CCSPMethod.h:370
std::vector< CMatrix< C_FLOAT64 > > mVec_mFastParticipationIndex
Definition: CCSPMethod.h:319
void calculateJacobian(C_INT &n, CVector< C_FLOAT64 > &y, CMatrix< C_FLOAT64 > &J)
void findCandidatesNumber(C_INT &n, C_INT &k, CVector< C_FLOAT64 > &tsc, C_INT &info)
Definition: CCSPMethod.cpp:328
const CArrayAnnotation * getImportanceIndexAnn() const
Definition: CCSPMethod.h:407
CArrayAnnotation * pTmp5NormedRow
Definition: CCSPMethod.h:360
C_FLOAT64 mTsc
Definition: CCSPMethod.h:61
void CSPOutput(C_INT &N, C_INT &M, C_INT &R)
virtual void step(const double &deltaT)
void findTimeScaleSeparation(C_INT &n, C_INT &k, CVector< C_FLOAT64 > &tsc, C_INT &info)
#define TAU
std::vector< CMatrix< C_FLOAT64 > > mVec_mRadicalPointer
Definition: CCSPMethod.h:313
void sminverse(C_INT &n, CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B)
Definition: CCSPMethod.cpp:164
static CTSSAMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::unset)
Definition: CTSSAMethod.cpp:44
Definition: CState.h:305
std::vector< CMatrix< C_FLOAT64 > > mVec_mSlowParticipationIndex
Definition: CCSPMethod.h:320
bool modesAreExhausted(C_INT &N, C_INT &M, C_FLOAT64 &tauM, C_FLOAT64 &tauM1, CVector< C_FLOAT64 > &g, CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B, CMatrix< C_FLOAT64 > &F)
const CArrayAnnotation * getFastParticipationIndexAnn() const
Definition: CCSPMethod.h:403
CMatrix< C_FLOAT64 > mFastParticipationIndexTab
Definition: CCSPMethod.h:376
void CSPImportanceIndex(C_INT &N, C_FLOAT64 &tauM1, CMatrix< C_FLOAT64 > &Q)
void CSPradicalPointer(C_INT &N, C_INT &M, CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B)
CMatrix< C_FLOAT64 > mImportanceIndexNormedRow
Definition: CCSPMethod.h:142
void smadd(CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B, CMatrix< C_FLOAT64 > &C, C_INT &n1, C_INT &n2)
Definition: CCSPMethod.cpp:114
CMatrix< C_FLOAT64 > mFastReactionPointerNormedTab
Definition: CCSPMethod.h:369
std::vector< CMatrix< C_FLOAT64 > > mVec_mParticipationIndexNormedRow
Definition: CCSPMethod.h:317
void yCorrection(C_INT &N, C_INT &M, CVector< C_FLOAT64 > &y, CMatrix< C_FLOAT64 > &TAUM, CMatrix< C_FLOAT64 > &F, CMatrix< C_FLOAT64 > &A)
CMatrix< C_FLOAT64 > mImportanceIndex
Definition: CCSPMethod.h:141
const CArrayAnnotation * getFastReactionPointerNormedAnn() const
Definition: CCSPMethod.h:395
CVector< C_FLOAT64 > mFastParticipationIndex
Definition: CCSPMethod.h:133
C_INT mCSPbasis
Definition: CCSPMethod.h:97
CMatrix< C_FLOAT64 > mI
Definition: CCSPMethod.h:51
CArrayAnnotation * pTmp3
Definition: CCSPMethod.h:350
CArrayAnnotation * pFastReactionPointerNormedAnn
Definition: CCSPMethod.h:336
void modesAmplitude(C_INT &N, C_INT &M, CVector< C_FLOAT64 > &g, CMatrix< C_FLOAT64 > &B, CMatrix< C_FLOAT64 > &F)
std::vector< CMatrix< C_FLOAT64 > > mVec_mAmplitude
Definition: CCSPMethod.h:312
CArrayAnnotation * pTmp4NormedColumn
Definition: CCSPMethod.h:353
CVector< C_FLOAT64 > mSlowParticipationIndex
Definition: CCSPMethod.h:134
CMatrix< C_FLOAT64 > mParticipationIndexNormedRowTab
Definition: CCSPMethod.h:371
void emptyOutputData(C_INT &N, C_INT &M, C_INT &R)
CArrayAnnotation * pParticipationIndexAnn
Definition: CCSPMethod.h:337
CMatrix< C_FLOAT64 > mRadicalPointer
Definition: CCSPMethod.h:115
const CArrayAnnotation * getParticipationIndexNormedRowAnn() const
Definition: CCSPMethod.h:399
CArrayAnnotation * pTmp2
Definition: CCSPMethod.h:349
CArrayAnnotation * pTmp1
Definition: CCSPMethod.h:348
CVector< C_FLOAT64 > mG
Definition: CCSPMethod.h:81
void createAnnotationsM()
const CArrayAnnotation * getImportanceIndexNormedRowAnn() const
Definition: CCSPMethod.h:409
CMatrix< C_FLOAT64 > mParticipationIndexNormedRow
Definition: CCSPMethod.h:131
std::vector< CMatrix< C_FLOAT64 > > mVec_mParticipationIndex
Definition: CCSPMethod.h:316
CMatrix< C_FLOAT64 > mFastReactionPointerNormed
Definition: CCSPMethod.h:123
CArrayAnnotation * pImportanceIndexNormedRowAnn
Definition: CCSPMethod.h:343
C_FLOAT64 mEps
Definition: CCSPMethod.h:56
CArrayAnnotation * pTmp4Fast
Definition: CCSPMethod.h:356
CVector< C_FLOAT64 > mYerror
Definition: CCSPMethod.h:86
void smmult(CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B, CMatrix< C_FLOAT64 > &C, C_INT &n1, C_INT &n2, C_INT &n3)
Definition: CCSPMethod.cpp:85
CArrayAnnotation * pTmp4NormedRow
Definition: CCSPMethod.h:354
CMatrix< C_FLOAT64 > mSlowParticipationIndexTab
Definition: CCSPMethod.h:377
C_FLOAT64 mRerror
Definition: CCSPMethod.h:66
CArrayAnnotation * pAmplitudeAnn
Definition: CCSPMethod.h:333
const CArrayAnnotation * getParticipationIndexNormedColumnAnn() const
Definition: CCSPMethod.h:401
void perturbateA(C_INT &n, CMatrix< C_FLOAT64 > &A, C_FLOAT64 delta)
Definition: CCSPMethod.cpp:153
CArrayAnnotation * pTmp4
Definition: CCSPMethod.h:352
void initializeParameter()
Definition: CCSPMethod.cpp:70
CArrayAnnotation * pImportanceIndexAnn
Definition: CCSPMethod.h:342
C_INT mTStep
Definition: CCSPMethod.h:93
CMatrix< C_FLOAT64 > mParticipationIndex
Definition: CCSPMethod.h:130
CArrayAnnotation * pTmp3Normed
Definition: CCSPMethod.h:351
CMatrix< C_FLOAT64 > mFastReactionPointerTab
Definition: CCSPMethod.h:368
CArrayAnnotation * pTmp5
Definition: CCSPMethod.h:359
void emptyVectors()
CMatrix< C_FLOAT64 > mImportanceIndexTab
Definition: CCSPMethod.h:373
#define C_FLOAT64
Definition: copasi.h:92
CArrayAnnotation * pTmp4Slow
Definition: CCSPMethod.h:357
std::vector< CMatrix< C_FLOAT64 > > mVec_mImportanceIndexNormedRow
Definition: CCSPMethod.h:322
CArrayAnnotation * pParticipationIndexNormedColumnAnn
Definition: CCSPMethod.h:339
CMatrix< C_FLOAT64 > mB
Definition: CCSPMethod.h:91
CArrayAnnotation * pFastReactionPointerAnn
Definition: CCSPMethod.h:335
C_INT isBlockDiagonal(C_INT &N, C_INT &M, CMatrix< C_FLOAT64 > &ALA, C_FLOAT64 SMALL)
Definition: CCSPMethod.cpp:938
const CArrayAnnotation * getFastReactionPointerAnn() const
Definition: CCSPMethod.h:393
void smsubst(CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B, CMatrix< C_FLOAT64 > &C, C_INT &n1, C_INT &n2)
Definition: CCSPMethod.cpp:102
virtual void predifineAnnotation()
std::vector< CMatrix< C_FLOAT64 > > mVec_mFastReactionPointerNormed
Definition: CCSPMethod.h:315
virtual bool setAnnotationM(size_t step)
Definition: CModel.h:50
CArrayAnnotation * pRadicalPointerAnn
Definition: CCSPMethod.h:334
C_INT mSetVectors
Definition: CCSPMethod.h:103
CMatrix< C_FLOAT64 > mImportanceIndexNormedRowTab
Definition: CCSPMethod.h:374
C_FLOAT64 mAerror
Definition: CCSPMethod.h:71
void cspstep(const double &deltaT, C_INT &n, C_INT &m, CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B)
Definition: CCSPMethod.cpp:401
void setVectors(int fast)
CMatrix< C_FLOAT64 > mRadicalPointerTab
Definition: CCSPMethod.h:367
C_INT mIter
Definition: CCSPMethod.h:76
std::vector< CMatrix< C_FLOAT64 > > mVec_mParticipationIndexNormedColumn
Definition: CCSPMethod.h:318
CArrayAnnotation * pFastParticipationIndexAnn
Definition: CCSPMethod.h:340
CMatrix< C_FLOAT64 > mFastReactionPointer
Definition: CCSPMethod.h:122
void setVectorsToNaN()
void smnorm(C_INT &n, CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B, C_INT &n1)
Definition: CCSPMethod.cpp:126
const CArrayAnnotation * getAmplitudeAnn() const
Definition: CCSPMethod.h:389
const CArrayAnnotation * getParticipationIndexAnn() const
Definition: CCSPMethod.h:397
void printResult(std::ostream *ostream) const
void basisRefinement(C_INT &N, C_INT &M, CMatrix< C_FLOAT64 > &ALA, CMatrix< C_FLOAT64 > &TAU, CMatrix< C_FLOAT64 > &A, CMatrix< C_FLOAT64 > &B, CMatrix< C_FLOAT64 > &A0, CMatrix< C_FLOAT64 > &B0)
std::vector< CMatrix< C_FLOAT64 > > mVec_mFastReactionPointer
Definition: CCSPMethod.h:314
virtual void start(const CState *initialState)
CVector< C_FLOAT64 > mAmplitude
Definition: CCSPMethod.h:109
CMatrix< C_FLOAT64 > mParticipationIndexNormedColumnTab
Definition: CCSPMethod.h:372
const CArrayAnnotation * getRadicalPointerAnn() const
Definition: CCSPMethod.h:391