00001 // FirstOrderDestructionReaction.cpp: implementation of the CFirstOrderDestructionReaction class. 00002 // 00004 00005 #include "FirstOrderDestructionReaction.h" 00006 00008 // Construction/Destruction 00010 00011 CFirstOrderDestructionReaction::CFirstOrderDestructionReaction(Chemical *DestroyingEnzyme, Chemical *Substrate, RateConstant *k_fod, std::string reactionName) 00012 :Reaction(reactionName) 00013 { 00014 // stoichiometry 00015 this->DestroyingEnzyme = chemicals.size(); 00016 chemicals.push_back(DestroyingEnzyme); 00017 numberOfEachChemicalChangedByReaction.push_back(0); 00018 00019 this->Substrate = chemicals.size(); 00020 chemicals.push_back(Substrate); 00021 numberOfEachChemicalChangedByReaction.push_back(-1); 00022 00023 // rates 00024 this->k_fod = rateConstants.size(); 00025 rateConstants.push_back(k_fod); 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 chemicalJacobian.push_back(new JElement(-1,-1)); 00031 00032 this->SetTeXForm(); 00033 00034 } 00035 00036 CFirstOrderDestructionReaction::~CFirstOrderDestructionReaction() 00037 { 00038 00039 } 00040 00041 double CFirstOrderDestructionReaction::GetRate() const 00042 { 00043 double kfod = rateConstants[k_fod]->GetValue(); 00044 double de = chemicals[DestroyingEnzyme]->GetAmount(); 00045 double su = chemicals[Substrate]->GetAmount(); 00046 return kfod*de*su; 00047 } 00048 00049 void CFirstOrderDestructionReaction::SetTeXForm() 00050 { 00051 std::stringstream stream; 00052 // TeX form of the reaction 00053 stream << rateConstants[k_fod]->GetTeXName().c_str(); 00054 stream << "\\left [" << chemicals[DestroyingEnzyme]->GetTeXName().c_str(); 00055 stream << "\\right ]"; 00056 stream << " \\left [" << chemicals[Substrate]->GetTeXName().c_str(); 00057 stream << "\\right ]"; 00058 stream << ends; 00059 // set the TeX string equal to what's in the stream 00060 m_sTeXForm = stream.str(); 00061 // free up the string 00062 // stream.rdbuf()->freeze(0); 00063 } 00064 00065 std::vector<Reaction::JElement *> *CFirstOrderDestructionReaction::GetChemicalJacobian() 00066 { 00067 chemicalJacobian[0]->SetWithRespectTo(chemicals[DestroyingEnzyme]->GetChemicalNumber()); 00068 chemicalJacobian[0]->SetJValue(rateConstants[k_fod]->GetValue()*chemicals[Substrate]->GetAmount()); 00069 00070 chemicalJacobian[1]->SetWithRespectTo(chemicals[Substrate]->GetChemicalNumber()); 00071 chemicalJacobian[1]->SetJValue(rateConstants[k_fod]->GetValue()*chemicals[DestroyingEnzyme]->GetAmount()); 00072 00073 return &chemicalJacobian; 00074 } 00075