MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ZombieEnz.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2010 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 #include "header.h"
10 
11 #include "lookupVolumeFromMesh.h"
12 #include "RateTerm.h"
13 #include "FuncTerm.h"
14 #include "SparseMatrix.h"
15 #include "KinSparseMatrix.h"
16 #include "VoxelPoolsBase.h"
17 #include "../mesh/VoxelJunction.h"
18 #include "XferInfo.h"
19 #include "ZombiePoolInterface.h"
20 #include "Stoich.h"
21 
22 #include "EnzBase.h"
23 #include "CplxEnzBase.h"
24 #include "ZombieEnz.h"
25 
26 #define EPSILON 1e-15
27 
29 {
31  // Field Definitions
34  // MsgDest Definitions
37  // Shared Msg Definitions
39 
40  static Dinfo< ZombieEnz > dinfo;
41  static Cinfo zombieEnzCinfo (
42  "ZombieEnz",
44  0,
45  0,
46  &dinfo
47  );
48 
49  return &zombieEnzCinfo;
50 }
52 
54 
56  dynamic_cast< const SrcFinfo2< double, double >* >(
57  zombieEnzCinfo->findFinfo( "subOut" ) );
58 
60 // ZombieEnz internal functions
62 
64  :
65  stoich_( 0 ),
66  concK1_( 1.0 )
67 { ; }
68 
70 { ; }
71 
73 // MsgDest Definitions
75 
76 /*
77 void ZombieEnz::vRemesh( const Eref& e )
78 {
79  stoich_->setEnzK1( e, concK1_ );
80 }
81 */
82 
83 
85 // Field Definitions
87 
88 // v is in number units.
89 void ZombieEnz::vSetK1( const Eref& e, double v )
90 {
91  double volScale =
92  convertConcToNumRateUsingMesh( e, subOut, true );
93 
94  concK1_ = v * volScale;
95  stoich_->setEnzK1( e, concK1_ );
96 }
97 
98 // k1 is In number units.
99 double ZombieEnz::vGetK1( const Eref& e ) const
100 {
101  // return stoich_->getEnzNumK1( e );
102  double volScale =
103  convertConcToNumRateUsingMesh( e, subOut, true );
104 
105  return concK1_ / volScale;
106 }
107 
108 void ZombieEnz::vSetK2( const Eref& e, double v )
109 {
110  stoich_->setEnzK2( e, v );
111 }
112 
113 double ZombieEnz::vGetK2( const Eref& e ) const
114 {
115  return stoich_->getEnzK2( e );
116 }
117 
118 void ZombieEnz::vSetKcat( const Eref& e, double v )
119 {
120  double k2 = getK2( e );
121  double k3 = getKcat( e );
122  double ratio = 4.0;
123  if ( v < EPSILON )
124  v = EPSILON;
125  if ( k3 > EPSILON ) {
126  ratio = k2/k3;
127  }
128  double Km = (k2 + k3) / concK1_;
129  concK1_ = v * (1.0 + ratio) / Km;
130 
131  stoich_->setEnzK1( e, concK1_ );
132  stoich_->setEnzK3( e, v );
133  stoich_->setEnzK2( e, v * ratio );
134 }
135 
136 double ZombieEnz::vGetKcat( const Eref& e ) const
137 {
138  return stoich_->getEnzK3( e );
139 }
140 
141 
142 void ZombieEnz::vSetKm( const Eref& e, double v )
143 {
144  double k2 = getK2( e );
145  double k3 = getKcat( e );
146  concK1_ = ( k2 + k3 ) / v;
147  stoich_->setEnzK1( e, concK1_ );
148 }
149 
150 double ZombieEnz::vGetKm( const Eref& e ) const
151 {
152  double k2 = getK2( e );
153  double k3 = getKcat( e );
154 
155  return ( k2 + k3 ) / concK1_;
156 }
157 
158 void ZombieEnz::vSetNumKm( const Eref& e, double v )
159 {
160  double k2 = getK2( e );
161  double k3 = getKcat( e );
162  double volScale =
163  convertConcToNumRateUsingMesh( e, subOut, 1 );
164  concK1_ = ( k2 + k3 ) / ( v * volScale );
165 
166  stoich_->setEnzK1( e, concK1_ );
167 }
168 
169 double ZombieEnz::vGetNumKm( const Eref& e ) const
170 {
171  double k2 = vGetK2( e );
172  double k3 = vGetKcat( e );
173  double volScale =
174  convertConcToNumRateUsingMesh( e, subOut, 1 );
175 
176  return volScale * ( k2 + k3 ) / concK1_;
177 }
178 
179 void ZombieEnz::vSetRatio( const Eref& e, double v )
180 {
181  double Km = getKm( e );
182  double k2 = getK2( e );
183  double k3 = getKcat( e );
184 
185  k2 = v * k3;
186 
187  stoich_->setEnzK2( e, k2 );
188  double k1 = ( k2 + k3 ) / Km;
189 
190  setConcK1( e, k1 );
191 }
192 
193 double ZombieEnz::vGetRatio( const Eref& e ) const
194 {
195  double k2 = getK2( e );
196  double k3 = getKcat( e );
197  return k2 / k3;
198 }
199 
200 void ZombieEnz::vSetConcK1( const Eref& e, double v )
201 {
202  concK1_ = v;
203  stoich_->setEnzK1( e, v );
204 }
205 
206 double ZombieEnz::vGetConcK1( const Eref& e ) const
207 {
208  return concK1_;
209 }
210 
212 // Utility function
214 
215 // static func
216 void ZombieEnz::setSolver( Id stoich, Id enz )
217 {
218  static const Finfo* subFinfo = Cinfo::find("Enz")->findFinfo( "subOut");
219  static const Finfo* prdFinfo = Cinfo::find("Enz")->findFinfo( "prdOut");
220  static const Finfo* enzFinfo = Cinfo::find("Enz")->findFinfo( "enzOut");
221  static const Finfo* cplxFinfo= Cinfo::find("Enz")->findFinfo("cplxOut");
222 
223  assert( subFinfo );
224  assert( prdFinfo );
225  assert( enzFinfo );
226  assert( cplxFinfo );
227  vector< Id > enzMols;
228  vector< Id > cplxMols;
229  bool isOK = true;
230  unsigned int numReactants;
231  numReactants = enz.element()->getNeighbors( enzMols, enzFinfo );
232  bool hasEnz = ( numReactants == 1 );
233  vector< Id > subs;
234  numReactants = enz.element()->getNeighbors( subs, subFinfo );
235  bool hasSubs = ( numReactants > 0 );
236  numReactants = enz.element()->getNeighbors( cplxMols, cplxFinfo );
237  bool hasCplx = ( numReactants == 1 );
238  vector< Id > prds;
239  numReactants = enz.element()->getNeighbors( prds, prdFinfo );
240  bool hasPrds = ( numReactants > 0 );
241  assert( stoich.element()->cinfo()->isA( "Stoich" ) );
242  stoich_ = reinterpret_cast< Stoich* >( stoich.eref().data() );
243 
244  if ( hasEnz && hasSubs && hasCplx && hasPrds ) {
245  stoich_->installEnzyme( enz, enzMols[0], cplxMols[0], subs, prds );
246  } else {
247  stoich_->installDummyEnzyme( enz, Id() );
248  string msg = "";
249  if ( !hasEnz ) msg = msg + " enzyme";
250  if ( !hasCplx ) msg = msg + " enzyme-substrate complex";
251  if ( !hasSubs ) msg = msg + " substrates";
252  if ( !hasPrds ) msg = msg + " products";
253  cout << "Warning: ZombieEnz:setSolver: Dangling Enz '" <<
254  enz.path() << "':\nMissing " << msg << endl;
255  }
256 }
void vSetK1(const Eref &e, double v)
Definition: ZombieEnz.cpp:89
char * data() const
Definition: Eref.cpp:41
double getEnzK2(const Eref &e) const
Get rate k2 (1/sec) for enzyme.
Definition: Stoich.cpp:1986
void setEnzK3(const Eref &e, double v) const
Set rate k3 (1/sec) for enzyme.
Definition: Stoich.cpp:1966
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
void setSolver(Id solver, Id orig)
Assign solver info.
Definition: ZombieEnz.cpp:216
void vSetRatio(const Eref &e, double v)
Definition: ZombieEnz.cpp:179
Definition: Dinfo.h:60
double getK2(const Eref &e) const
void setEnzK1(const Eref &e, double v) const
Later handle all the volumes when this conversion is done.
Definition: Stoich.cpp:1943
double vGetConcK1(const Eref &e) const
Definition: ZombieEnz.cpp:206
double getKm(const Eref &e) const
Definition: EnzBase.cpp:235
static const Cinfo * find(const std::string &name)
Definition: Cinfo.cpp:200
double vGetKcat(const Eref &e) const
Definition: ZombieEnz.cpp:136
double vGetK1(const Eref &e) const
Definition: ZombieEnz.cpp:99
Eref eref() const
Definition: Id.cpp:125
double vGetNumKm(const Eref &e) const
Definition: ZombieEnz.cpp:169
void installEnzyme(Id enzId, Id enzMolId, Id cplxId, const vector< Id > &subs, const vector< Id > &prds)
Definition: Stoich.cpp:1732
Definition: Stoich.h:49
void setConcK1(const Eref &e, double v)
double vGetKm(const Eref &e) const
Definition: ZombieEnz.cpp:150
void setEnzK2(const Eref &e, double v) const
Set rate k2 (1/sec) for enzyme.
Definition: Stoich.cpp:1951
static const SrcFinfo2< double, double > * subOut
Definition: ZombieEnz.cpp:55
Definition: Eref.h:26
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
void vSetKcat(const Eref &e, double v)
Definition: ZombieEnz.cpp:118
const Cinfo * cinfo() const
Definition: Element.cpp:66
void vSetNumKm(const Eref &e, double v)
Definition: ZombieEnz.cpp:158
double convertConcToNumRateUsingMesh(const Eref &e, const SrcFinfo *pools, bool doPartialConversion)
#define EPSILON
Definition: ZombieEnz.cpp:26
double getEnzK3(const Eref &e) const
Get rate k3, aka kcat, for enzyme.
Definition: Stoich.cpp:1994
double getKcat(const Eref &e) const
Definition: EnzBase.cpp:256
static const Cinfo * zombieEnzCinfo
Definition: ZombieEnz.cpp:53
Definition: Id.h:17
unsigned int getNeighbors(vector< Id > &ret, const Finfo *finfo) const
Definition: Element.cpp:949
void vSetK2(const Eref &e, double v)
Definition: ZombieEnz.cpp:108
void vSetConcK1(const Eref &e, double v)
Definition: ZombieEnz.cpp:200
double vGetRatio(const Eref &e) const
Definition: ZombieEnz.cpp:193
Stoich * stoich_
Definition: ZombieEnz.h:64
double concK1_
Definition: ZombieEnz.h:65
Definition: Cinfo.h:18
static const Cinfo * initCinfo()
Definition: ZombieEnz.cpp:28
double vGetK2(const Eref &e) const
Definition: ZombieEnz.cpp:113
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
static const Cinfo * initCinfo()
Definition: CplxEnzBase.cpp:49
void vSetKm(const Eref &e, double v)
Definition: ZombieEnz.cpp:142
Definition: Finfo.h:12