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

NormalizedLinearAttenuator.cpp

Go to the documentation of this file.
00001 // NormalizedLinearAttenuator.cpp: implementation of the CNormalizedLinearAttenuator class.
00002 //
00004 
00005 #include "NormalizedLinearAttenuator.h"
00006 
00008 // Construction/Destruction
00010 
00011 CNormalizedLinearAttenuator::CNormalizedLinearAttenuator(Chemical *InputChemical, Chemical *OutputChemical, RateConstant *k_atten, std::string reactionName)
00012 :Reaction(reactionName)
00013 {
00014         // stoichiometry
00015         this->InputChemical = chemicals.size();
00016         chemicals.push_back(InputChemical);
00017         numberOfEachChemicalChangedByReaction.push_back(0);
00018 
00019         this->OutputChemical = chemicals.size();
00020         chemicals.push_back(OutputChemical);
00021         numberOfEachChemicalChangedByReaction.push_back(-1);
00022 
00023         // rates
00024         this->k_atten = rateConstants.size();
00025         rateConstants.push_back(k_atten);
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 CNormalizedLinearAttenuator::~CNormalizedLinearAttenuator()
00035 {
00036         
00037 }
00038 
00039 double CNormalizedLinearAttenuator::GetRate() const
00040 {
00041         return ((rateConstants[k_atten]->GetValue())/(chemicals[InputChemical]->GetInitialAmount()))*chemicals[InputChemical]->GetAmount();
00042 }
00043 
00044 void CNormalizedLinearAttenuator::SetTeXForm()
00045 {
00046         strstream stream;
00047         // TeX form of the reaction
00048         stream << rateConstants[k_atten]->GetTeXName().c_str();
00049         stream << "{ " << chemicals[InputChemical]->GetTeXName().c_str() << " \\over ";
00050         stream << chemicals[InputChemical]->GetTeXName().c_str() << "_0 }";
00051         stream << ends;
00052         // set the TeX string equal to what's in the stream
00053         m_sTeXForm = stream.str();
00054         // allow memory to be freed
00055         stream.rdbuf()->freeze(0);
00056 }
00057 
00058 std::vector<Reaction::JElement *> *CNormalizedLinearAttenuator::GetChemicalJacobian()
00059 {
00060         chemicalJacobian[0]->SetWithRespectTo(chemicals[InputChemical]->GetChemicalNumber());
00061         chemicalJacobian[0]->SetJValue((rateConstants[k_atten]->GetValue())/(chemicals[InputChemical]->GetInitialAmount()));
00062         
00063         return &chemicalJacobian;
00064 }

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