COPASI API  4.16.103
CLsodaMethod.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2002 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef COPASI_CLsodaMethod
16 #define COPASI_CLsodaMethod
17 
18 #include <sstream>
19 
24 #include "copasi/model/CState.h"
25 
26 class CModel;
27 
29 {
30  friend CTrajectoryMethod *
32 
33 public:
34  struct Data
35  {
38  };
39 
40  // Attributes
41 protected:
43  {
44  NONE = 0,
45  ALL,
47  };
48 
49  /**
50  * A pointer to the value of "Integrate Reduced Model"
51  */
53 
54 private:
55  /**
56  * A pointer to the value of "Relative Tolerance"
57  */
59 
60  /**
61  * A pointer to the value of "Absolute Tolerance"
62  */
64 
65  /**
66  * A pointer to the value of "Max Internal Steps"
67  */
69 
70 protected:
71  /**
72  * A pointer to the current state in complete model view.
73  */
75 
76 private:
77  /**
78  * mData.dim is the dimension of the ODE system.
79  * mData.pMethod contains CLsodaMethod * this to be used in the static method EvalF
80  */
82 
83  /**
84  * Pointer to the array with left hand side values.
85  */
87 
88  /**
89  * Vector containing the derivatives after calling eval
90  */
92 
93  /**
94  * Number of roots
95  */
97 
98 protected:
99  /**
100  * Current time.
101  */
103 
104  /**
105  * LSODA state.
106  */
108 
109 private:
110  /**
111  * Relative tolerance.
112  */
114 
115  /**
116  * A vector of absolute tolerances.
117  */
119 
120  /**
121  * Stream to capture LSODA error messages
122  */
123  std::ostringstream mErrorMsg;
124 
125  /**
126  * The LSODA integrator
127  */
129 
130  /**
131  * The LSODA integrator
132  */
134 
135  /**
136  * The state of the integrator
137  */
139 
140  /**
141  * LSODA C_FLOAT64 work area
142  */
144 
145  /**
146  * LSODA C_INT work area
147  */
149 
150  /**
151  * The way LSODA calculates the jacobian
152  */
154 
155 protected:
156  /**
157  * A pointer to the model
158  */
160 
161  /**
162  * A Boolean value indication whether we have no ODEs
163  */
164  bool mNoODE;
165 
166 private:
167  /**
168  * A dummy variable if we do not have any ODEs
169  */
171 
172  /**
173  * A mask which hides all roots being constant and zero.
174  */
176 
177  /**
178  * A which indicates whether roots change only discretely.
179  */
181 
182 protected:
183  /**
184  * A Boolean flag indicating whether we should try masking roots
185  */
187 
188 private:
189  /**
190  * Store the targeted end time to determine whether the internal
191  * step limit is exceeded.
192  */
194 
195  /**
196  * Root counter to determine whether the internal
197  * step limit is exceeded.
198  */
200 
201  /**
202  * A Boolean indicating whether we are in peekAhead mode
203  */
205 
206  // Operations
207 protected:
208  /**
209  * Default constructor.
210  * @param const CCopasiMethod::SubType & subType (default: deterministic)
211  * @param const CCopasiContainer * pParent (default: NULL)
212  */
214  const CCopasiContainer * pParent = NULL);
215 
216 public:
217  /**
218  * Copy constructor.
219  * @param "const CLsodaMethod &" src
220  * @param const CCopasiContainer * pParent (default: NULL)
221  */
222  CLsodaMethod(const CLsodaMethod & src,
223  const CCopasiContainer * pParent = NULL);
224 
225  /**
226  * Destructor.
227  */
228  ~CLsodaMethod();
229 
230  /**
231  * This methods must be called to elevate subgroups to
232  * derived objects. The default implementation does nothing.
233  * @return bool success
234  */
235  virtual bool elevateChildren();
236 
237  /**
238  * Inform the trajectory method that the state has changed outside
239  * its control
240  */
241  virtual void stateChanged();
242 
243  /**
244  * This instructs the method to calculate a time step of deltaT
245  * starting with the current state, i.e., the result of the previous
246  * step.
247  * The new state (after deltaT) is expected in the current state.
248  * The return value is the actual time step taken.
249  * @param "const double &" deltaT
250  * @return Status status
251  */
252  virtual Status step(const double & deltaT);
253 
254  /**
255  * This instructs the method to prepare for integration
256  * starting with the initialState given.
257  * @param "const CState *" initialState
258  */
259  virtual void start(const CState * initialState);
260 
261  /**
262  * This evaluates the derivatives
263  */
264  static void EvalF(const C_INT * n, const C_FLOAT64 * t, const C_FLOAT64 * y, C_FLOAT64 * ydot);
265 
266  virtual void evalF(const C_FLOAT64 * t, const C_FLOAT64 * y, C_FLOAT64 * ydot);
267 
268  /**
269  * This evaluates the roots
270  */
271  static void EvalR(const C_INT * n, const C_FLOAT64 * t, const C_FLOAT64 * y,
272  const C_INT * nr, C_FLOAT64 * r);
273 
274  virtual void evalR(const C_FLOAT64 * t, const C_FLOAT64 * y, const C_INT * nr, C_FLOAT64 * r);
275 
276  /**
277  * This evaluates the Jacobian
278  */
279  static void EvalJ(const C_INT * n, const C_FLOAT64 * t, const C_FLOAT64 * y,
280  const C_INT * ml, const C_INT * mu, C_FLOAT64 * pd, const C_INT * nRowPD);
281 
282  virtual void evalJ(const C_FLOAT64 * t, const C_FLOAT64 * y,
283  const C_INT * ml, const C_INT * mu, C_FLOAT64 * pd, const C_INT * nRowPD);
284 
285 private:
286  /**
287  * Initialize the method parameter
288  */
289  void initializeParameter();
290 
291  /**
292  * Mask roots which are constant and zero.
293  * @param CVectorCore< C_FLOAT64 > & rootValues
294  */
295  void maskRoots(CVectorCore< C_FLOAT64 > & rootValues);
296 
297  /**
298  * Create a mask which hides all roots being constant and zero.
299  */
300  void createRootMask();
301 
302  /**
303  * Peek ahead to detect simultaneous roots.
304  */
305  Status peekAhead();
306 
307 protected:
308  /**
309  * Destroy the mask which hides all roots being constant and zero.
310  */
311  void destroyRootMask();
312 };
313 #endif // COPASI_CLsodaMethod
#define C_INT
Definition: copasi.h:115
C_INT mLsodaStatus
Definition: CLsodaMethod.h:107
static void EvalR(const C_INT *n, const C_FLOAT64 *t, const C_FLOAT64 *y, const C_INT *nr, C_FLOAT64 *r)
CVector< C_FLOAT64 > mAtol
Definition: CLsodaMethod.h:118
static void EvalF(const C_INT *n, const C_FLOAT64 *t, const C_FLOAT64 *y, C_FLOAT64 *ydot)
C_FLOAT64 mDummy
Definition: CLsodaMethod.h:170
C_FLOAT64 * mpAbsoluteTolerance
Definition: CLsodaMethod.h:63
CVector< bool > mRootMask
Definition: CLsodaMethod.h:175
virtual void start(const CState *initialState)
C_FLOAT64 mRtol
Definition: CLsodaMethod.h:113
Definition: CState.h:305
CVector< C_FLOAT64 > mDWork
Definition: CLsodaMethod.h:143
virtual void evalR(const C_FLOAT64 *t, const C_FLOAT64 *y, const C_INT *nr, C_FLOAT64 *r)
CVector< bool > mDiscreteRoots
Definition: CLsodaMethod.h:180
C_FLOAT64 * mY
Definition: CLsodaMethod.h:86
CModel * mpModel
Definition: CLsodaMethod.h:159
#define C_INT32
Definition: copasi.h:90
void maskRoots(CVectorCore< C_FLOAT64 > &rootValues)
unsigned C_INT32 mRootCounter
Definition: CLsodaMethod.h:199
static void EvalJ(const C_INT *n, const C_FLOAT64 *t, const C_FLOAT64 *y, const C_INT *ml, const C_INT *mu, C_FLOAT64 *pd, const C_INT *nRowPD)
virtual Status step(const double &deltaT)
CState mMethodState
Definition: CLsodaMethod.h:74
C_FLOAT64 mTargetTime
Definition: CLsodaMethod.h:193
std::ostringstream mErrorMsg
Definition: CLsodaMethod.h:123
C_INT mNumRoots
Definition: CLsodaMethod.h:96
CLsodaMethod(const CCopasiMethod::SubType &subType=deterministic, const CCopasiContainer *pParent=NULL)
virtual bool elevateChildren()
Definition: CLSODA.h:24
bool * mpReducedModel
Definition: CLsodaMethod.h:52
CLsodaMethod * pMethod
Definition: CLsodaMethod.h:37
void destroyRootMask()
static CTrajectoryMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::deterministic)
C_FLOAT64 mTime
Definition: CLsodaMethod.h:102
unsigned C_INT32 * mpMaxInternalSteps
Definition: CLsodaMethod.h:68
#define C_FLOAT64
Definition: copasi.h:92
RootMasking mRootMasking
Definition: CLsodaMethod.h:186
bool mPeekAheadMode
Definition: CLsodaMethod.h:204
Status peekAhead()
void createRootMask()
virtual void stateChanged()
CLSODAR mLSODAR
Definition: CLsodaMethod.h:133
virtual void evalJ(const C_FLOAT64 *t, const C_FLOAT64 *y, const C_INT *ml, const C_INT *mu, C_FLOAT64 *pd, const C_INT *nRowPD)
Definition: CModel.h:50
CVector< C_FLOAT64 > mYdot
Definition: CLsodaMethod.h:91
void initializeParameter()
virtual void evalF(const C_FLOAT64 *t, const C_FLOAT64 *y, C_FLOAT64 *ydot)
CVector< C_INT > mIWork
Definition: CLsodaMethod.h:148
C_FLOAT64 * mpRelativeTolerance
Definition: CLsodaMethod.h:58