00001 // NormalizedLinearAmplifier.cpp: implementation of the CNormalizedLinearAmplifier class. 00002 // 00004 00005 #include "NormalizedLinearAmplifier.h" 00006 00008 // Construction/Destruction 00010 00011 CNormalizedLinearAmplifier::CNormalizedLinearAmplifier(Chemical *InputChemical, Chemical *OutputChemical, RateConstant *k_amp, 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_amp = rateConstants.size(); 00025 rateConstants.push_back(k_amp); 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 CNormalizedLinearAmplifier::~CNormalizedLinearAmplifier() 00035 { 00036 00037 } 00038 00039 double CNormalizedLinearAmplifier::GetRate() const 00040 { 00041 return ((rateConstants[k_amp]->GetValue())/(chemicals[InputChemical]->GetInitialAmount()))*chemicals[InputChemical]->GetAmount(); 00042 } 00043 00044 void CNormalizedLinearAmplifier::SetTeXForm() 00045 { 00046 strstream stream; 00047 // TeX form of the reaction 00048 stream << rateConstants[k_amp]->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 *> *CNormalizedLinearAmplifier::GetChemicalJacobian() 00059 { 00060 chemicalJacobian[0]->SetWithRespectTo(chemicals[InputChemical]->GetChemicalNumber()); 00061 chemicalJacobian[0]->SetJValue((rateConstants[k_amp]->GetValue())/(chemicals[InputChemical]->GetInitialAmount())); 00062 00063 return &chemicalJacobian; 00064 }