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

PoolTransitionReaction.cpp

Go to the documentation of this file.
00001 #include "pooltransitionreaction.h"
00002 
00003 CPoolTransitionReaction::CPoolTransitionReaction(Chemical *OldPoolForm, Chemical *NewPoolForm, RateConstant *k_t, RateConstant *K, std::string reactionName)
00004 :Reaction(reactionName)
00005 {
00006         // stoichiometry
00007         this->OldPoolForm = chemicals.size();
00008         chemicals.push_back(OldPoolForm);
00009         numberOfEachChemicalChangedByReaction.push_back(-1);
00010 
00011         this->NewPoolForm = chemicals.size();
00012         chemicals.push_back(NewPoolForm);
00013         numberOfEachChemicalChangedByReaction.push_back(+1);
00014 
00015         // rates
00016         this->k_t = rateConstants.size();
00017         rateConstants.push_back(k_t);
00018 
00019         this->K = rateConstants.size();
00020         rateConstants.push_back(K);
00021 
00022         // put enough dummy chemicalJacobian elements on the vector 
00023         // - they are recomputed every time you ask for the chemicalJacobian
00024         chemicalJacobian.push_back(new JElement(-1,-1));
00025         chemicalJacobian.push_back(new JElement(-1,-1));
00026 
00027         this->SetTeXForm();
00028 }
00029 
00030 CPoolTransitionReaction::~CPoolTransitionReaction(void)
00031 {
00032 }
00033 
00034 double CPoolTransitionReaction::GetRate() const
00035 {
00036         return (rateConstants[k_t]->GetValue()*chemicals[OldPoolForm]->GetAmount())/(rateConstants[K]->GetValue() + chemicals[NewPoolForm]->GetAmount());
00037 }
00038 
00039 void CPoolTransitionReaction::SetTeXForm()
00040 {
00041         strstream stream;
00042         // TeX form of the reaction
00043         stream << rateConstants[k_t]->GetTeXName().c_str();
00044         stream << " {\\left[" << chemicals[OldPoolForm]->GetTeXName().c_str() << "\\right]";
00045         stream << "\\over {";
00046         stream <<  rateConstants[K]->GetTeXName().c_str() << " + ";
00047         stream << "\\left[" << chemicals[NewPoolForm]->GetTeXName().c_str() << "\\right]}}";
00048         // add a NULL
00049         stream << ends;
00050         // set the TeX string equal to what's in the stream
00051         m_sTeXForm = stream.str();
00052         // allow memory to be freed
00053         stream.rdbuf()->freeze(0);
00054 }
00055 
00056 std::vector<Reaction::JElement *> *CPoolTransitionReaction::GetChemicalJacobian()
00057 {
00058         double denom = rateConstants[K]->GetValue() + chemicals[NewPoolForm]->GetAmount();
00059         
00060         chemicalJacobian[0]->SetWithRespectTo(chemicals[OldPoolForm]->GetChemicalNumber());
00061         chemicalJacobian[0]->SetJValue(rateConstants[k_t]->GetValue()/denom);
00062         
00063         chemicalJacobian[1]->SetWithRespectTo(chemicals[NewPoolForm]->GetChemicalNumber());
00064         chemicalJacobian[1]->SetJValue(-1.0*(rateConstants[k_t]->GetValue()*chemicals[OldPoolForm]->GetAmount())/(denom*denom));
00065 
00066         return &chemicalJacobian;
00067 }

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