Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

MixedReactionNetwork.cpp

Go to the documentation of this file.
00001 // MixedReactionNetwork.cpp: implementation of the CMixedReactionNetwork class.
00002 //
00004 
00005 #include "MixedReactionNetwork.h"
00006 
00008 // Construction/Destruction
00010 
00011 CMixedReactionNetwork::CMixedReactionNetwork()
00012 {
00013 
00014 }
00015 
00016 CMixedReactionNetwork::CMixedReactionNetwork(ReactionNetwork *pReactionNetwork, intVector stocReactionList)
00017 {
00018         m_pReactionNetwork = pReactionNetwork;
00019         m_viStochasticList = stocReactionList;
00020 
00021         // make sure the stochastic reaction list is sorted - reactions
00022         // are indexed by number in the master list
00023         std::sort(m_viStochasticList.begin(),m_viStochasticList.end());
00024 
00025         // partition the list of reactions into noisy and non-noisy
00026         int listKey = 0;
00027         for(int i = 0; i < m_pReactionNetwork->GetNumberOfReactions(); i++)
00028         {
00029                 if(i == m_viStochasticList[listKey])
00030                 {
00031                         m_vpStochasticReactions.push_back(m_pReactionNetwork->GetReactions()->at(i));
00032                         m_dStochasticReactionRates.push_back(0.0);
00033                         listKey++;
00034                 }
00035                 else
00036                 {
00037                         m_vpDeterministicReactions.push_back(m_pReactionNetwork->GetReactions()->at(i));
00038                         m_dDeterministicReactionRates.push_back(0.0);
00039                 }
00040 
00041         }
00042 
00043 }
00044 
00045 CMixedReactionNetwork::~CMixedReactionNetwork()
00046 {
00047 
00048 }
00049 
00050 int CMixedReactionNetwork::GetNumberOfChemicals() const
00051 {
00052         return m_pReactionNetwork->GetNumberOfChemicals();
00053 }
00054 
00055 // returns the total number of reactions, stochastic and deterministic
00056 
00057 int CMixedReactionNetwork::GetNumberOfReactions() const
00058 {
00059         return m_pReactionNetwork->GetNumberOfReactions();
00060 }
00061 
00062 int CMixedReactionNetwork::GetNumberOfRateConstants() const
00063 {
00064         return m_pReactionNetwork->GetNumberOfRateConstants();
00065 }
00066 
00067 Chemical *CMixedReactionNetwork::GetChemical(int chemicalNumber)
00068 {
00069         return m_pReactionNetwork->GetChemical(chemicalNumber);
00070 }
00071 
00072 RateConstant *CMixedReactionNetwork::GetRateConstant(int rateConstantNumber)
00073 {
00074         return m_pReactionNetwork->GetRateConstant(rateConstantNumber);
00075 }
00076 
00077 void CMixedReactionNetwork::ChemicalReset()
00078 {
00079         for(int i = 0; i < this->GetNumberOfChemicals(); i++)
00080         {
00081                 m_pReactionNetwork->GetChemical(i)->Reset();
00082         }
00083 }
00084 
00085 void CMixedReactionNetwork::RateConstantReset()
00086 {
00087         for(int i = 0; i < this->GetNumberOfRateConstants(); i++)
00088         {
00089                 m_pReactionNetwork->GetRateConstant(i)->Reset();
00090         }
00091 }
00092 
00093 void CMixedReactionNetwork::SetAmount(int chemicalNumber, double amount)
00094 {
00095         m_pReactionNetwork->GetChemical(chemicalNumber)->SetAmount(amount);
00096 }
00097 
00098 vpReaction *CMixedReactionNetwork::GetReactions()
00099 {
00100         return m_pReactionNetwork->GetReactions();
00101 }
00102 
00103 Reaction *CMixedReactionNetwork::GetReaction(int reactionNumber)
00104 {
00105         return m_pReactionNetwork->GetReaction(reactionNumber);
00106 }
00107 
00108 vpReaction *CMixedReactionNetwork::GetStochasticReactions()
00109 {
00110         return &m_vpStochasticReactions;
00111 }
00112 
00113 Reaction *CMixedReactionNetwork::GetStochasticReaction(int reactionNumber)
00114 {
00115         return m_vpStochasticReactions[reactionNumber];
00116 }
00117 
00118 vpReaction *CMixedReactionNetwork::GetDeterministicReactions()
00119 {
00120         return &m_vpDeterministicReactions;
00121 }
00122 
00123 Reaction *CMixedReactionNetwork::GetDeterministicReaction(int reactionNumber)
00124 {
00125         return m_vpDeterministicReactions[reactionNumber];
00126 }
00127 
00128 vpChemical *CMixedReactionNetwork::GetChemicals()
00129 {
00130         return m_pReactionNetwork->GetChemicals();
00131 }
00132 
00133 vpRateConstant *CMixedReactionNetwork::GetRateConstants()
00134 {
00135         return m_pReactionNetwork->GetRateConstants();
00136 }
00137 
00138 int CMixedReactionNetwork::GetNumberOfStochasticReactions() const
00139 {
00140         return m_vpStochasticReactions.size();
00141 }
00142 
00143 int CMixedReactionNetwork::GetNumberOfDeterministicReactions() const
00144 {
00145         return m_vpDeterministicReactions.size();
00146 }
00147 
00148 dblVector *CMixedReactionNetwork::GetReactionRates()
00149 {
00150         // ensure synchrony with the bulk reactions vector 
00151         if(reactionRates.size() != m_pReactionNetwork->GetNumberOfReactions())
00152         {
00153                 // clear out the old vector
00154                 reactionRates.erase(reactionRates.begin(),reactionRates.end());
00155                 // fill the vector with the appropriate rates
00156                 for(int i = 0; i < m_pReactionNetwork->GetNumberOfReactions(); i++)
00157                 {
00158                         double rate = m_pReactionNetwork->GetReaction(i)->GetRate();
00159                         reactionRates.push_back(rate);
00160                 }
00161         }
00162         else
00163         {
00164                 for(int i = 0; i < m_pReactionNetwork->GetNumberOfReactions(); i++)
00165                 {
00166                         double rate = m_pReactionNetwork->GetReaction(i)->GetRate();
00167                         reactionRates[i] = rate;
00168                 }
00169         }
00170         
00171         // now set rates for stochastic reactions to zero
00172         for(int i = 0; i < m_viStochasticList.size(); i++)
00173         {
00174                 reactionRates[m_viStochasticList[i]] = 0.0;
00175         }
00176         
00177         // return the vector of rates
00178         return &reactionRates;
00179 }
00180 
00181 dblVector *CMixedReactionNetwork::GetStochasticReactionRates()
00182 {
00183         for(int i = 0; i < this->GetNumberOfStochasticReactions(); i++)
00184         {
00185                 m_dStochasticReactionRates[i] = m_vpStochasticReactions[i]->GetRate();
00186         }
00187         
00188         // return the vector
00189         return &m_dStochasticReactionRates;
00190 }
00191 
00192 dblVector *CMixedReactionNetwork::GetDeterministicReactionRates()
00193 {
00194         for(int i = 0; i < this->GetNumberOfDeterministicReactions(); i++)
00195         {
00196                 m_dDeterministicReactionRates[i] = m_vpDeterministicReactions[i]->GetRate();
00197         }
00198         
00199         // return the vector
00200         return &m_dDeterministicReactionRates;
00201 }
00202 
00203 double CMixedReactionNetwork::GetTotalStochasticReactionProbability()
00204 {
00205         double totalP = 0.0;
00206 
00207         for(int i = 0; i < this->GetNumberOfStochasticReactions(); i++)
00208         {
00209                 totalP += this->GetStochasticReaction(i)->GetRate();
00210         }
00211 
00212         return totalP;
00213 }

Generated on Mon Nov 3 09:38:01 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002