MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
EnzBase.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 
10 #include "header.h"
11 #include "ElementValueFinfo.h"
12 #include "lookupVolumeFromMesh.h"
13 #include "EnzBase.h"
14 
15 #define EPSILON 1e-15
16 
19  "subOut",
20  "Sends out increment of molecules on product each timestep"
21  );
22  return &subOut;
23 }
24 
27  "prdOut",
28  "Sends out increment of molecules on product each timestep"
29  );
30  return &prdOut;
31 }
32 
34 {
36  // Field Definitions
39  "Km",
40  "Michaelis-Menten constant in SI conc units (milliMolar)",
43  );
44 
46  "numKm",
47  "Michaelis-Menten constant in number units, volume dependent",
50  );
51 
53  "kcat",
54  "Forward rate constant for enzyme, units 1/sec",
57  );
58 
60  "numSubstrates",
61  "Number of substrates in this MM reaction. Usually 1."
62  "Does not include the enzyme itself",
64  );
65 
67  "numProducts",
68  "Number of products in this MM reaction. Usually 1.",
70  );
71 
72 
74  // Shared Msg Definitions
76  static DestFinfo process( "process",
77  "Handles process call",
79 
80  static DestFinfo reinit( "reinit",
81  "Handles reinit call",
83 
84  /*
85  static DestFinfo group( "group",
86  "Handle for group msgs. Doesn't do anything",
87  new OpFuncDummy() );
88  */
89 
90  static DestFinfo remesh( "remesh",
91  "Tells the MMEnz to recompute its numKm after remeshing",
93 
95  // MsgDest Definitions
97  static DestFinfo enzDest( "enzDest",
98  "Handles # of molecules of Enzyme",
100  static DestFinfo subDest( "subDest",
101  "Handles # of molecules of substrate",
103  static DestFinfo prdDest( "prdDest",
104  "Handles # of molecules of product. Dummy.",
106  static Finfo* subShared[] = {
107  subOut(), &subDest
108  };
109 
110  static Finfo* prdShared[] = {
111  prdOut(), &prdDest
112  };
113  static SharedFinfo sub( "sub",
114  "Connects to substrate molecule",
115  subShared, sizeof( subShared ) / sizeof( const Finfo* )
116  );
117  static SharedFinfo prd( "prd",
118  "Connects to product molecule",
119  prdShared, sizeof( prdShared ) / sizeof( const Finfo* )
120  );
121  static Finfo* procShared[] = {
122  &process, &reinit
123  };
124  static SharedFinfo proc( "proc",
125  "Shared message for process and reinit",
126  procShared, sizeof( procShared ) / sizeof( const Finfo* )
127  );
128 
129  static Finfo* enzBaseFinfos[] = {
130  &Km, // ElementValue
131  &numKm, // ElementValue
132  &kcat, // Value
133  &numSub, // ReadOnlyElementValue
134  &numPrd, // ReadOnlyElementValue
135  &enzDest, // DestFinfo
136  &sub, // SharedFinfo
137  &prd, // SharedFinfo
138  &proc, // SharedFinfo
139  &remesh, // Destfinfo
140  };
141 
142  static string doc[] =
143  {
144  "Name", "EnzBase",
145  "Author", "Upi Bhalla",
146  "Description", "Abstract base class for enzymes."
147  };
148  static ZeroSizeDinfo< int > dinfo;
149  static Cinfo enzBaseCinfo (
150  "EnzBase",
152  enzBaseFinfos,
153  sizeof( enzBaseFinfos ) / sizeof ( Finfo* ),
154  &dinfo,
155  doc,
156  sizeof( doc )/sizeof( string ),
157  true // Don't create it, it is a an astract base class.
158  );
159 
160  return &enzBaseCinfo;
161 }
162 
164 
166 // EnzBase internal functions
168 
170 {;}
171 
173 {;}
174 
176 // MsgDest Definitions
178 
179 void EnzBase::sub( double n )
180 {
181  vSub( n );
182 }
183 
184 void EnzBase::prd( double n ) // dummy
185 {;}
186 
187 void EnzBase::enz( double n )
188 {
189  vEnz( n );
190 }
191 
192 void EnzBase::process( const Eref& e, ProcPtr p )
193 {
194  vProcess( e, p );
195 }
196 
197 void EnzBase::reinit( const Eref& e, ProcPtr p )
198 {
199  vReinit( e, p );
200 }
201 
202 void EnzBase::remesh( const Eref& e )
203 {
204  vRemesh( e );
205 }
206 
208 // Virtual MsgDest Definitions. Mostly dummys, the derived classes don't
209 // need to do anything here.
211 void EnzBase::vSub( double n )
212 {;}
213 
214 void EnzBase::vEnz( double n )
215 {;}
216 
217 void EnzBase::vProcess( const Eref& e, ProcPtr p )
218 {;}
219 
220 void EnzBase::vReinit( const Eref& e, ProcPtr p )
221 {;}
222 
223 void EnzBase::vRemesh( const Eref& e )
224 {;}
225 
227 // Field Definitions
229 
230 void EnzBase::setKm( const Eref& enz, double v )
231 {
232  vSetKm( enz, v );
233 }
234 
235 double EnzBase::getKm( const Eref& enz ) const
236 {
237  return vGetKm( enz );
238 }
239 
240 void EnzBase::setNumKm( const Eref& enz, double v )
241 {
242  vSetNumKm( enz, v );
243 }
244 
245 double EnzBase::getNumKm( const Eref& enz ) const
246 {
247  return vGetNumKm( enz );
248 }
249 
250 
251 void EnzBase::setKcat( const Eref& e, double v )
252 {
253  vSetKcat( e, v );
254 }
255 
256 double EnzBase::getKcat( const Eref& e ) const
257 {
258  return vGetKcat( e );
259 }
260 
261 unsigned int EnzBase::getNumSub( const Eref& e ) const
262 {
263  const vector< MsgFuncBinding >* mfb =
264  e.element()->getMsgAndFunc( subOut()->getBindIndex() );
265  assert( mfb );
266  return ( mfb->size() );
267 }
268 
269 unsigned int EnzBase::getNumPrd( const Eref& e ) const
270 {
271  const vector< MsgFuncBinding >* mfb =
272  e.element()->getMsgAndFunc( prdOut()->getBindIndex() );
273  assert( mfb );
274  return ( mfb->size() );
275 }
276 
278 // Zombie conversion routine to convert between Enz subclasses.
280 // static func
281 
291 void EnzBase::zombify( Element* orig, const Cinfo* zClass, Id solver )
292 {
293  if ( orig->cinfo() == zClass )
294  return;
295  unsigned int start = orig->localDataStart();
296  unsigned int num = orig->numLocalData();
297  if ( num == 0 )
298  return;
299  vector< double > Km( num, 0.0 );
300  vector< double > kcat( num, 0.0 );
301  for ( unsigned int i = 0; i < num; ++i ) {
302  Eref er( orig, i + start );
303  const EnzBase* eb =
304  reinterpret_cast< const EnzBase* >( er.data() );
305  kcat[ i ] = eb->getKcat( er );
306  Km[ i ] = eb->getKm( er );
307  }
308  orig->zombieSwap( zClass );
309  for ( unsigned int i = 0; i < num; ++i ) {
310  Eref er( orig, i + start );
311  EnzBase* eb = reinterpret_cast< EnzBase* >( er.data() );
312  eb->setSolver( solver, orig->id() );
313  eb->setKcat( er, kcat[i] );
314  eb->setKm( er, Km[i] );
315  }
316 }
317 
318 // Virtual func: default does nothing.
319 void EnzBase::setSolver( Id solver, Id orig )
320 {
321  ;
322 }
virtual void vReinit(const Eref &e, ProcPtr p)
Definition: EnzBase.cpp:220
char * data() const
Definition: Eref.cpp:41
virtual double vGetKcat(const Eref &e) const =0
unsigned int getNumPrd(const Eref &e) const
Definition: EnzBase.cpp:269
static SrcFinfo2< double, double > * subOut()
Definition: EnzBase.cpp:17
static const Cinfo * enzBaseCinfo
Definition: EnzBase.cpp:163
void setNumKm(const Eref &e, double v)
Definition: EnzBase.cpp:240
double getKm(const Eref &e) const
Definition: EnzBase.cpp:235
double getNumKm(const Eref &e) const
Definition: EnzBase.cpp:245
EnzBase()
Definition: EnzBase.cpp:169
static void zombify(Element *original, const Cinfo *zClass, Id solver)
Definition: EnzBase.cpp:291
virtual double vGetNumKm(const Eref &e) const =0
virtual void zombieSwap(const Cinfo *zCinfo)
virtual func, this base version must be called by all derived classes
Definition: Element.cpp:159
DestFinfo * enzDest()
Definition: CplxEnzBase.cpp:32
Element * element() const
Definition: Eref.h:42
virtual double vGetKm(const Eref &e) const =0
Id id() const
Definition: Element.cpp:71
virtual void vEnz(double n)
Definition: EnzBase.cpp:214
void enz(double n)
Definition: EnzBase.cpp:187
virtual ~EnzBase()
Definition: EnzBase.cpp:172
void sub(double n)
Definition: EnzBase.cpp:179
unsigned int getNumSub(const Eref &e) const
Definition: EnzBase.cpp:261
void setKm(const Eref &e, double v)
Definition: EnzBase.cpp:230
Definition: EpFunc.h:49
virtual void vProcess(const Eref &e, ProcPtr p)
Definition: EnzBase.cpp:217
Definition: OpFunc.h:27
Definition: Eref.h:26
const vector< MsgFuncBinding > * getMsgAndFunc(BindIndex b) const
Definition: Element.cpp:300
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual void vSetKcat(const Eref &e, double v)=0
void remesh(const Eref &e)
Definition: EnzBase.cpp:202
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.
virtual void vSetKm(const Eref &e, double v)=0
double getKcat(const Eref &e) const
Definition: EnzBase.cpp:256
void prd(double n)
Definition: EnzBase.cpp:184
Definition: Id.h:17
virtual void vRemesh(const Eref &e)
Definition: EnzBase.cpp:223
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
void process(const Eref &e, ProcPtr p)
Definition: EnzBase.cpp:192
static SrcFinfo2< double, double > * prdOut()
Definition: EnzBase.cpp:25
virtual void vSetNumKm(const Eref &e, double v)=0
void setKcat(const Eref &e, double v)
Definition: EnzBase.cpp:251
Definition: Cinfo.h:18
virtual void vSub(double n)
Definition: EnzBase.cpp:211
static const Cinfo * initCinfo()
Definition: EnzBase.cpp:33
void reinit(const Eref &e, ProcPtr p)
Definition: EnzBase.cpp:197
Definition: Finfo.h:12
virtual void setSolver(Id solver, Id orig)
Assign solver info.
Definition: EnzBase.cpp:319