00001 // Reaction.h: interface for the Reaction class. 00002 // 00004 00005 #if !defined(AFX_REACTION_H__17E9EE60_DB43_11D3_8099_00A0C9B3BB18__INCLUDED_) 00006 #define AFX_REACTION_H__17E9EE60_DB43_11D3_8099_00A0C9B3BB18__INCLUDED_ 00007 00008 #ifndef SWIG 00009 #if _MSC_VER > 1000 00010 #pragma once 00011 #endif // _MSC_VER > 1000 00012 #endif 00013 00014 #ifdef _WIN32 00015 #include <strstream> 00016 #endif 00017 00018 #include <vector> 00019 #include <string> 00020 //#include <strstrea.h> 00021 #include <sstream> 00022 #include <iostream> 00023 #include "Chemical.h" 00024 #include "RateConstant.h" 00025 00026 class Chemical; // Both files refer to one another 00027 00028 00029 class Reaction 00030 { 00031 public: 00032 class JElement 00033 { 00034 public: 00035 JElement() {return;} 00036 JElement(int withRespectTo, double jValue) 00037 { 00038 _withRespectTo = withRespectTo; 00039 _jValue = jValue; 00040 } 00041 virtual ~JElement() {return;} 00042 int GetWithRespectTo() const {return _withRespectTo;} 00043 double GetJValue() const {return _jValue;} 00044 void SetWithRespectTo(int withRespectTo) {_withRespectTo = withRespectTo;} 00045 void SetJValue(double jValue) {_jValue = jValue;} 00046 private: 00047 int _withRespectTo; 00048 double _jValue; 00049 }; 00050 int GetNumberChangedByReaction(int chemicalNumber); 00051 void DoReactionOnce(); 00052 Reaction(); 00053 Reaction(std::string reactionName); 00054 virtual ~Reaction(); 00055 std::vector<Chemical *> *GetChemicals(); 00056 virtual double GetRate() const = 0; 00057 virtual std::vector<JElement *> *GetChemicalJacobian() = 0; 00058 virtual std::string GetTeXForm() const {return m_sTeXForm;} 00059 virtual void SetTeXForm() = 0; 00060 std::string GetName() const {return reactionName;} 00061 protected: 00062 // For stochastic simulations, should probably store the rate last 00063 // calculated, and store a bool that tells whether any neighboring 00064 // chemical has changed concentration. Would need a member function 00065 // for alerting the reaction, called in SetAmount for the chemical. 00066 00067 // Reactions that depend or affect the chemical 00068 std::vector<Chemical *> chemicals; 00069 // Name explains it all 00070 std::vector<int> numberOfEachChemicalChangedByReaction; 00071 // Rate constants for this reaction 00072 std::vector<RateConstant *> rateConstants; 00073 // Jacobian w.r.t. variables (chemicals) 00074 std::vector<JElement *> chemicalJacobian; 00075 // string for name of reaction 00076 std::string reactionName; 00077 // string giving TeX formatted reaction term 00078 std::string m_sTeXForm; 00079 }; 00080 00081 #endif // !defined(AFX_REACTION_H__17E9EE60_DB43_11D3_8099_00A0C9B3BB18__INCLUDED_)