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

ChemicalSource.cpp

Go to the documentation of this file.
00001 // ChemicalSource.cpp: implementation of the CChemicalSource class.
00002 //
00004 
00005 #include "ChemicalSource.h"
00006 
00008 // Construction/Destruction
00010 
00011 CChemicalSource::CChemicalSource(Chemical *ChangedChemical, Chemical *SourceChemical, 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->SourceChemical = chemicals.size();
00020         chemicals.push_back(SourceChemical);
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 CChemicalSource::~CChemicalSource()
00033 {
00034 
00035 }
00036 
00037 double CChemicalSource::GetRate() const
00038 {
00039         return chemicals[SourceChemical]->GetAmount();
00040 }
00041 
00042 void CChemicalSource::SetTeXForm()
00043 {
00044         strstream stream;
00045         // TeX form of the reaction
00046         stream << chemicals[SourceChemical]->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 *> *CChemicalSource::GetChemicalJacobian()
00055 {
00056         chemicalJacobian[0]->SetWithRespectTo(chemicals[SourceChemical]->GetChemicalNumber());
00057         chemicalJacobian[0]->SetJValue(1.0);
00058         
00059         return &chemicalJacobian;
00060 }

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