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