COPASI API  4.16.103
CMathReaction.cpp
Go to the documentation of this file.
1 // Copyright (C) 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 #include "copasi.h"
7 
8 #include "CMathReaction.h"
9 #include "CMathContainer.h"
10 
11 #include "model/CReaction.h"
12 
14  mpReaction(NULL),
15  mpParticleFlux(NULL),
16  mpFlux(NULL),
17  mpPropensity(NULL),
18  mModifiedSpecies(),
19  mStepUpdates()
20 {}
21 
23 {}
24 
25 void CMathReaction::initialize(const CReaction * pReaction, CMathContainer & container)
26 {
27  mpReaction = pReaction;
28 
29  // Sanity Check
30  if (mpReaction == NULL) return;
31 
35 
37  std::pair< C_FLOAT64, C_FLOAT64 * > * pStepUpdate = mStepUpdates.array();
38  std::pair< C_FLOAT64, C_FLOAT64 * > * pStepUpdateEnd = pStepUpdate + mStepUpdates.size();
40 
41  for (; pStepUpdate != pStepUpdateEnd; ++pStepUpdate, ++it)
42  {
43  CMathObject * pParticleNumber = container.getMathObject((*it)->getMetabolite()->getValueReference());
44  mModifiedSpecies.insert(pParticleNumber);
45  pStepUpdate->first = (*it)->getMultiplicity();
46  pStepUpdate->second = (C_FLOAT64 *) pParticleNumber->getValuePointer();
47  }
48 }
49 
51  CMathContainer & /* container */,
52  const size_t & valueOffset,
53  const size_t & objectOffset)
54 {
55  mpReaction = src.mpReaction;
56 
57  mpParticleFlux = src.mpParticleFlux + objectOffset;
58  mpFlux = src.mpFlux + objectOffset;
59  mpPropensity = src.mpPropensity + objectOffset;
60 
62  std::pair< C_FLOAT64, C_FLOAT64 * > * pStepUpdate = mStepUpdates.array();
63  std::pair< C_FLOAT64, C_FLOAT64 * > * pStepUpdateEnd = pStepUpdate + mStepUpdates.size();
64  const std::pair< C_FLOAT64, C_FLOAT64 * > * pStepUpdateSrc = src.mStepUpdates.array();
65 
66  for (; pStepUpdate != pStepUpdateEnd; ++pStepUpdate, ++pStepUpdateSrc)
67  {
68  pStepUpdate->first = pStepUpdateSrc->first;
69  pStepUpdate->second = pStepUpdateSrc->second + valueOffset;
70  }
71 
72  CObjectInterface::ObjectSet::const_iterator it = src.mModifiedSpecies.begin();
73  CObjectInterface::ObjectSet::const_iterator end = src.mModifiedSpecies.end();
74 
75  for (; it != end; ++it)
76  {
77  mModifiedSpecies.insert(*it + objectOffset);
78  }
79 }
80 
81 void CMathReaction::fire(const C_FLOAT64 & count)
82 {
83  std::pair< C_FLOAT64, C_FLOAT64 * > * pStepUpdate = mStepUpdates.array();
84  std::pair< C_FLOAT64, C_FLOAT64 * > * pStepUpdateEnd = pStepUpdate + mStepUpdates.size();
85 
86  for (; pStepUpdate != pStepUpdateEnd; ++pStepUpdate)
87  {
88  *pStepUpdate->second += pStepUpdate->first * count;
89  }
90 }
91 
93 {
94  return mpParticleFlux;
95 }
96 
98 {
99  return mpFlux;
100 }
101 
103 {
104  return mpPropensity;
105 }
106 
108 {
109  return mModifiedSpecies;
110 }
111 
113 {
114  return mpReaction;
115 }
CMathObject * mpParticleFlux
Definition: CMathReaction.h:92
CCopasiObject * getParticleFluxReference()
Definition: CReaction.cpp:207
CMathObject * getMathObject(const CObjectInterface *pObject) const
const CReaction * getModelReaction() const
virtual size_t size() const
const CObjectInterface::ObjectSet & getModifiedSpecies() const
iterator begin()
CMathObject * mpPropensity
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
CObjectInterface::ObjectSet mModifiedSpecies
CCopasiObject * getPropensityReference()
Definition: CReaction.cpp:210
const CCopasiVector< CChemEqElement > & getBalances() const
Definition: CChemEq.cpp:69
virtual void * getValuePointer() const
const CMathObject * getFluxObject() const
CMathObject * mpFlux
Definition: CMathReaction.h:97
void copy(const CMathReaction &src, CMathContainer &container, const size_t &valueOffset, const size_t &objectOffset)
CVector< std::pair< C_FLOAT64, C_FLOAT64 * > > mStepUpdates
size_t size() const
Definition: CVector.h:100
void fire(const C_FLOAT64 &count)
std::set< const CObjectInterface * > ObjectSet
const CMathObject * getPropensityObject() const
const CReaction * mpReaction
Definition: CMathReaction.h:87
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
void initialize(const CReaction *pReaction, CMathContainer &container)
const CMathObject * getParticleFluxObject() const
CCopasiObject * getFluxReference()
Definition: CReaction.cpp:198