COPASI API  4.16.103
CHybridNextReactionRKMethod.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/trajectory/CHybridNextReactionRKMethod.cpp,v $
3  $Revision: 1.6 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2011/03/07 19:34:14 $
7  End CVS Header */
8 
9 // Copyright (C) 2011 - 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) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 /**
19  * CHybridNextReactionRKMethod
20  *
21  * First approach to an hybrid algorithm. Gibson's Next Reaction method is
22  * combined with a RungeKutta numerical integrator.
23  *
24  * File name: CHybridNextReactionRKMethod.h
25  * Author: Juergen Pahle
26  * Email: juergen.pahle@eml-r.villa-bosch.de
27  *
28  * Last change: 15, December 2004
29  *
30  * (C) European Media Lab 2003.
31  */
32 
33 /* HEADER FILE ***************************************************************/
34 #include "copasi.h"
36 #include "model/CState.h"
37 
39 {}
40 
41 /**
42  * Simulates the system over the next interval of time. The new time after
43  * this step is returned.
44  *
45  * @param currentTime A C_FLOAT64 specifying the current time
46  * @param endTime A C_FLOAT64 specifying the endTime of the current step()
47  * @return A C_FLOAT giving the new time
48  */
50 {
51  size_t rIndex = 0;
52  C_FLOAT64 ds = 0.0;
53 
54  // if there are stochastic reactions
55  if (mPQ.size() != 0) // there is at least one stochastic reaction
56  {
57  getStochTimeAndIndex(ds, rIndex);
58 
59  if (ds <= endTime) // ds is an absolute time value!
60  {
61  // if there are deterministic reactions
62  if (mFirstReactionFlag != NULL) // there is at least one deterministic reaction
63  {
64  integrateDeterministicPart(ds - currentTime);
65  }
66 
67  fireReaction(rIndex);
69 
71  {
74  }
75 
76  updatePriorityQueue(rIndex, ds);
77  }
78  else
79  {
80  ds = endTime;
81 
82  // if there are deterministic reactions
83  if (mFirstReactionFlag != NULL) // there is at least one deterministic reaction
84  {
85  integrateDeterministicPart(endTime - currentTime);
86  }
87 
89 
91  {
94  }
95 
97  }
98  }
99  else // there is no stochastic reaction
100  {
101  ds = currentTime + mStepsize;
102 
103  if (ds <= endTime)
104  {
105  // if there are deterministic reactions
106  if (mFirstReactionFlag != NULL) // there is at least one deterministic reaction
107  {
108  integrateDeterministicPart(mStepsize);
109  }
110 
111  mpCurrentState->setTime(ds);
112 
114  {
115  partitionSystem();
117  }
118 
120  }
121  else
122  {
123  ds = endTime;
124 
125  // if there are deterministic reactions
126  if (mFirstReactionFlag != NULL) // there is at least one deterministic reaction
127  {
128  integrateDeterministicPart(endTime - currentTime);
129  }
130 
131  mpCurrentState->setTime(ds);
132 
134  {
135  partitionSystem();
137  }
138 
140  }
141  }
142 
143  //deprecated: outputDebug(mOutputFile, 1); // DEBUG
144  //deprecated: outputData(mOutputFile, 1); // DEBUG
145  return ds;
146 }
void getStochTimeAndIndex(C_FLOAT64 &ds, size_t &rIndex)
CHybridNextReactionRKMethod(const CCopasiContainer *pParent=NULL)
CHybridStochFlag * mFirstReactionFlag
#define C_INVALID_INDEX
Definition: copasi.h:222
CIndexedPriorityQueue mPQ
void setTime(const C_FLOAT64 &time)
Definition: CState.cpp:326
void integrateDeterministicPart(C_FLOAT64 ds)
size_t mStepsAfterPartitionSystem
C_FLOAT64 mStepsize
void updatePriorityQueue(size_t rIndex, C_FLOAT64 time)
unsigned C_INT32 mPartitioningInterval
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 doSingleStep(C_FLOAT64 time, C_FLOAT64 endTime)
void fireReaction(size_t rIndex)