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