00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00021 class FuncRate: public ExternReac
00022 {
00023 public:
00024 FuncRate( double k, unsigned int targetPoolIndex )
00025 : k_( k ), funcVolPower_( 0.0 )
00026 {
00027 func_.setTarget( targetPoolIndex );
00028 }
00029
00030 double operator() ( const double* S ) const {
00031 return func_( S, 0.0 );
00032 }
00033
00034 unsigned int getReactants( vector< unsigned int >& molIndex ) const{
00035 molIndex.resize( 1 );
00036 molIndex[0] = func_.getTarget();
00037
00038
00039 return 0;
00040
00041 }
00042
00043 void setReactants( const vector< unsigned int >& molIndex ) {
00044 assert( molIndex.size() > 0 );
00045 func_.setTarget( molIndex[0] );
00046 }
00047
00048 const vector< unsigned int >& getFuncArgIndex()
00049 {
00050 return func_.getReactantIndex();
00051 }
00052
00053 void setFuncArgIndex( const vector< unsigned int >& mol ) {
00054 func_.setReactantIndex( mol );
00055 }
00056
00057 void setExpr( const string& s ) {
00058 func_.setExpr( s );
00059 }
00060 const string& getExpr() const {
00061 return func_.getExpr();
00062 }
00063
00064 RateTerm* copyWithVolScaling(
00065 double vol, double sub, double prd ) const
00066 {
00067 double ratio = sub * pow( NA * vol, funcVolPower_ );
00068 FuncRate* ret = new FuncRate( k_ / ratio, func_.getTarget() );
00069 ret->funcVolPower_ = funcVolPower_;
00070 ret->func_ = func_;
00071
00072 return ret;
00073 }
00074
00075 protected:
00076 FuncTerm func_;
00077 double k_;
00078 double funcVolPower_;
00079
00080 };
00081
00082
00097 class FuncReac: public FuncRate
00098 {
00099 public:
00100 FuncReac( double k, vector< unsigned int > v )
00101 : FuncRate( k, 0 ),
00102 v_( v )
00103 {;}
00104
00105 double operator() ( const double* S ) const {
00106
00107 double ret = func_( S, 0.0 );
00108 vector< unsigned int >::const_iterator i;
00109 for ( i = v_.begin(); i != v_.end(); i++) {
00110 assert( !std::isnan( S[ *i ] ) );
00111 ret *= S[ *i ];
00112 }
00113 return ret;
00114 }
00115
00116 unsigned int getReactants( vector< unsigned int >& molIndex ) const{
00117 molIndex = v_;
00118 return numSubstrates_;
00119 }
00120
00121 void setReactants( const vector< unsigned int >& molIndex ) {
00122 v_ = molIndex;
00123 }
00124
00125 void rescaleVolume( short comptIndex,
00126 const vector< short >& compartmentLookup, double ratio )
00127 {
00128 for ( unsigned int i = 1; i < v_.size(); ++i ) {
00129 if ( comptIndex == compartmentLookup[ v_[i] ] )
00130 k_ /= ratio;
00131 }
00132 }
00133
00134
00135 RateTerm* copyWithVolScaling(
00136 double vol, double sub, double prd ) const
00137 {
00138 assert( v_.size() > 0 );
00139 double ratio = sub * pow( NA * vol,
00140 funcVolPower_ + (int)( v_.size() ) - 1 );
00141 FuncReac* ret = new FuncReac( k_ / ratio, v_ );
00142 ret->func_ = func_;
00143 ret->funcVolPower_ = funcVolPower_;
00144 return ret;
00145
00146 }
00147
00148 private:
00149 vector< unsigned int > v_;
00150 unsigned int numSubstrates_;
00151 };
00152