00001 // TauNetwork.cpp: implementation of the CTauNetwork class. 00002 // 00004 00005 #include "TauNetwork.h" 00006 00008 // Construction/Destruction 00010 00011 CTauNetwork::CTauNetwork() 00012 { 00013 00014 } 00015 00016 CTauNetwork::CTauNetwork(CMixedReactionNetwork *pMixedNetwork) 00017 { 00018 m_pMixedNetwork = pMixedNetwork; 00019 // create the fake chemical, reaction, and rate constant. Give tau the next number 00020 // after the last real chemical 00021 m_pChemTau = new Chemical(m_pMixedNetwork->GetNumberOfChemicals(),0.0,"Tau"); 00022 m_pRxnTauReaction = new CTauReaction(m_pChemTau); 00023 } 00024 00025 CTauNetwork::~CTauNetwork() 00026 { 00027 delete m_pChemTau; 00028 delete m_pRxnTauReaction; 00029 } 00030 00031 double CTauNetwork::GetTOfTau() const 00032 { 00033 return m_pChemTau->GetAmount(); 00034 } 00035 00036 int CTauNetwork::GetNumberOfChemicals() const 00037 { 00038 // add one for the Tau "chemical" 00039 return m_pMixedNetwork->GetNumberOfChemicals() + 1; 00040 } 00041 00042 int CTauNetwork::GetNumberOfReactions() const 00043 { 00044 // add one for Tau "reaction" 00045 return m_pMixedNetwork->GetNumberOfReactions() + 1; 00046 } 00047 00048 Chemical *CTauNetwork::GetChemical(int chemicalNumber) 00049 { 00050 if(chemicalNumber != m_pChemTau->GetChemicalNumber()) 00051 { 00052 // chemical is a real chemical 00053 return m_pMixedNetwork->GetChemical(chemicalNumber); 00054 } 00055 else 00056 { 00057 // chemical is Tau 00058 return m_pChemTau; 00059 } 00060 } 00061 00062 std::vector<double> *CTauNetwork::GetReactionRates() 00063 { 00064 // grab a pointer to the rates in the mixed reaction network 00065 std::vector<double> *rxnRates = m_pMixedNetwork->GetReactionRates(); 00066 // get the current total stochastic rate and the current tau rate (= 1/(1-tau)) 00067 double gammaS = m_pMixedNetwork->GetTotalStochasticReactionProbability(); 00068 double tauRate = m_pRxnTauReaction->GetRate(); 00069 // fill up our own vector 00070 reactionRates.resize(0); 00071 for(int i = 0; i < rxnRates->size(); i++) 00072 { 00073 reactionRates.push_back(rxnRates->at(i)); 00074 // rescale the rate accordingly 00075 reactionRates[i] = reactionRates[i]*(tauRate/gammaS); 00076 } 00077 // now put tau on the rate vector, rescaled by gammaS 00078 reactionRates.push_back(tauRate/gammaS); 00079 // return the composite rate vector 00080 return &reactionRates; 00081 } 00082 00083 std::vector<Reaction *> *CTauNetwork::GetReactions() 00084 { 00085 // grab a pointer to the reactions in the mixed reaction network 00086 std::vector<Reaction *> *mixedRxns = m_pMixedNetwork->GetReactions(); 00087 // fill up our own vector 00088 reactions.resize(0); 00089 for(int i = 0; i < mixedRxns->size(); i++) 00090 { 00091 reactions.push_back(mixedRxns->at(i)); 00092 } 00093 // now put the tau reaction on 00094 reactions.push_back(m_pRxnTauReaction); 00095 // return the composite vector 00096 return &reactions; 00097 } 00098 00099 std::vector<Chemical *> *CTauNetwork::GetChemicals() 00100 { 00101 // grab a pointer to the chemicals in the mixed reaction network 00102 std::vector<Chemical *> *mixedChem = m_pMixedNetwork->GetChemicals(); 00103 // fill up our own vector 00104 chemicals.resize(0); 00105 for(int i = 0; i < mixedChem->size(); i++) 00106 { 00107 chemicals.push_back(mixedChem->at(i)); 00108 } 00109 // now put the tau chemical on 00110 chemicals.push_back(m_pChemTau); 00111 // return the composite vector 00112 return &chemicals; 00113 }