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

TransformationReaction.cpp

Go to the documentation of this file.
00001 // TransformationReaction.cpp: implementation of the TransformationReaction class.
00002 //
00004 
00005 #include "TransformationReaction.h"
00006 
00008 // Construction/Destruction
00010 
00011 TransformationReaction::TransformationReaction(Chemical *OldForm, Chemical *NewForm, RateConstant *k_trans, std::string reactionName)
00012 :Reaction(reactionName)
00013 {
00014         // stoichiometry
00015         this->OldForm = chemicals.size();
00016         chemicals.push_back(OldForm);
00017         numberOfEachChemicalChangedByReaction.push_back(-1);
00018 
00019         this->NewForm = chemicals.size();
00020         chemicals.push_back(NewForm);
00021         numberOfEachChemicalChangedByReaction.push_back(+1);
00022 
00023         // rates
00024         this->k_trans = rateConstants.size();
00025         rateConstants.push_back(k_trans);
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 TransformationReaction::~TransformationReaction()
00035 {
00036 
00037 }
00038 
00039 double TransformationReaction::GetRate() const
00040 {
00041         return rateConstants[k_trans]->GetValue() * chemicals[OldForm]->GetAmount();
00042 }
00043 
00044 void TransformationReaction::SetTeXForm()
00045 {
00046         std::stringstream stream;
00047         // TeX form of the reaction
00048         stream << rateConstants[k_trans]->GetTeXName().c_str();
00049         stream << "\\left [" << chemicals[OldForm]->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 *> *TransformationReaction::GetChemicalJacobian()
00060 {
00061         chemicalJacobian[0]->SetWithRespectTo(chemicals[OldForm]->GetChemicalNumber());
00062         chemicalJacobian[0]->SetJValue(rateConstants[k_trans]->GetValue());
00063         
00064         return &chemicalJacobian;
00065 }

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