MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Pool.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 "../basecode/header.h"
11 #include "../basecode/ElementValueFinfo.h"
12 #include "lookupVolumeFromMesh.h"
13 #include "PoolBase.h"
14 #include "Pool.h"
15 
16 #define EPSILON 1e-15
17 
19 {
21  // Field Definitions: All inherited from PoolBase.
24  // MsgDest Definitions: All inherited
27  // SrcFinfo Definitions: All inherited.
30  // SharedMsg Definitions: All inherited.
32  static Dinfo< Pool > dinfo;
33  static Cinfo poolCinfo (
34  "Pool",
36  0,
37  0,
38  &dinfo
39  );
40 
41  return &poolCinfo;
42 }
43 
45 // Class definitions
47 static const Cinfo* poolCinfo = Pool::initCinfo();
48 
49 const SrcFinfo1< double >& nOut = *dynamic_cast<const SrcFinfo1< double >*
50  >(poolCinfo->findFinfo( "nOut"));
51 
53  : n_( 0.0 ), nInit_( 0.0 ), diffConst_( 0.0 ), motorConst_( 0.0 ),
54  A_( 0.0 ), B_( 0.0 ), species_( 0 )
55 {;}
56 
58 {;}
59 
61 // Field Definitions
68 void Pool::vSetIsBuffered( const Eref& e, bool v )
69 {
70  static const Cinfo* bufPoolCinfo = Cinfo::find( "BufPool" );
71  if (vGetIsBuffered( e ) == v)
72  return;
73  if (v)
74  {
75  e.element()->replaceCinfo( bufPoolCinfo );
76  }
77  else
78  {
79  e.element()->replaceCinfo( poolCinfo );
80  }
81 }
82 
83 bool Pool::vGetIsBuffered( const Eref& e ) const
84 {
88  return e.element()->cinfo()->name() == "BufPool";
89 }
90 
92 //
94 // MsgDest Definitions
96 
97 void Pool::vProcess( const Eref& e, ProcPtr p )
98 {
99  // double A = e.sumBuf( aSlot );
100  // double B = e.sumBuf( bSlot );
101 
102  if ( n_ > EPSILON && B_ > EPSILON )
103  {
104  double C = exp( -B_ * p->dt / n_ );
105  n_ *= C + (A_ / B_ ) * ( 1.0 - C );
106  }
107  else
108  {
109  n_ += ( A_ - B_ ) * p->dt;
110  if ( n_ < 0.0 )
111  n_ = 0.0;
112  }
113 
114  A_ = B_ = 0.0;
115 
116  nOut.send( e, n_ );
117 }
118 
119 void Pool::vReinit( const Eref& e, ProcPtr p )
120 {
121  A_ = B_ = 0.0;
122  n_ = getNinit( e );
123 
124  nOut.send( e, n_ );
125 }
126 
127 void Pool::vReac( double A, double B )
128 {
129  A_ += A;
130  B_ += B;
131 }
132 
133 void Pool::vIncrement( double val )
134 {
135  if ( val > 0 )
136  A_ += val;
137  else
138  B_ -= val;
139 }
140 
141 void Pool::vDecrement( double val )
142 {
143  if ( val < 0 )
144  A_ -= val;
145  else
146  B_ += val;
147 }
148 
149 void Pool::vnIn( double val)
150 {
151  n_ = val;
152  B_ = 0;
153  A_ = 0;
154 }
155 
156 void Pool::vHandleMolWt( const Eref& e, double v )
157 {
158  ; // Here I should update DiffConst too.
159 }
160 
162 // Field Definitions
164 
165 void Pool::vSetN( const Eref& e, double v )
166 {
167  n_ = v;
168 }
169 
170 double Pool::vGetN( const Eref& e ) const
171 {
172  return n_;
173 }
174 
175 void Pool::vSetNinit( const Eref& e, double v )
176 {
177  nInit_ = v;
178 }
179 
180 double Pool::vGetNinit( const Eref& e ) const
181 {
182  return nInit_;
183 }
184 
185 // Conc is given in millimolar. Volume is in m^3
186 void Pool::vSetConc( const Eref& e, double c )
187 {
188  n_ = NA * c * lookupVolumeFromMesh( e );
189 }
190 
191 // Returns conc in millimolar.
192 double Pool::vGetConc( const Eref& e ) const
193 {
194  return (n_ / NA) / lookupVolumeFromMesh( e );
195 }
196 
197 void Pool::vSetConcInit( const Eref& e, double c )
198 {
199  nInit_ = NA * c * lookupVolumeFromMesh( e );
200 }
201 
202 void Pool::vSetDiffConst( const Eref& e, double v )
203 {
204  diffConst_ = v;
205 }
206 
207 double Pool::vGetDiffConst( const Eref& e ) const
208 {
209  return diffConst_;
210 }
211 
212 void Pool::vSetMotorConst( const Eref& e, double v )
213 {
214  motorConst_ = v;
215 }
216 
217 double Pool::vGetMotorConst( const Eref& e ) const
218 {
219  return motorConst_;
220 }
221 
222 void Pool::vSetVolume( const Eref& e, double v )
223 {
224  cout << "Warning: Pool::vSetVolume: Operation not permitted. Ignored\n";
225 }
226 
227 double Pool::vGetVolume( const Eref& e ) const
228 {
229  return lookupVolumeFromMesh( e );
230 }
231 
232 void Pool::vSetSpecies( const Eref& e, SpeciesId v )
233 {
234  species_ = v;
235 }
236 
238 {
239  return species_;
240 }
void vSetConc(const Eref &e, double v)
Definition: Pool.cpp:186
bool vGetIsBuffered(const Eref &e) const
Definition: Pool.cpp:83
void vSetN(const Eref &e, double v)
Definition: Pool.cpp:165
const double NA
Definition: consts.cpp:15
Definition: Dinfo.h:60
static const Cinfo * initCinfo()
Definition: PoolBase.cpp:19
double vGetMotorConst(const Eref &e) const
Definition: Pool.cpp:217
void vReinit(const Eref &e, ProcPtr p)
Definition: Pool.cpp:119
static const Cinfo * find(const std::string &name)
Definition: Cinfo.cpp:200
void vnIn(double val)
Definition: Pool.cpp:149
void vSetSpecies(const Eref &e, SpeciesId v)
Definition: Pool.cpp:232
static const Cinfo * bufPoolCinfo
Definition: BufPool.cpp:47
double B_
Internal state variables, used only in explict mode.
Definition: Pool.h:88
Element * element() const
Definition: Eref.h:42
void vSetMotorConst(const Eref &e, double v)
Dummy MotorConst field for most Pool subclasses.
Definition: Pool.cpp:212
void send(const Eref &er, T arg) const
Definition: SrcFinfo.h:106
void vSetDiffConst(const Eref &e, double v)
Definition: Pool.cpp:202
void vIncrement(double val)
Definition: Pool.cpp:133
void vProcess(const Eref &e, ProcPtr p)
Definition: Pool.cpp:97
double nInit_
Number of molecules in pool.
Definition: Pool.h:84
const std::string & name() const
Definition: Cinfo.cpp:260
void vReac(double A, double B)
Definition: Pool.cpp:127
Pool()
Definition: Pool.cpp:52
static const Cinfo * poolCinfo
Definition: Pool.cpp:47
double vGetVolume(const Eref &e) const
Definition: Pool.cpp:227
double vGetConc(const Eref &e) const
Definition: Pool.cpp:192
void vSetIsBuffered(const Eref &e, bool v)
Definition: Pool.cpp:68
static const Cinfo * initCinfo()
Definition: Pool.cpp:18
double dt
Definition: ProcInfo.h:18
~Pool()
Definition: Pool.cpp:57
void vHandleMolWt(const Eref &e, double v)
Definition: Pool.cpp:156
Definition: Eref.h:26
const SrcFinfo1< double > & nOut
Definition: Pool.cpp:49
void vSetConcInit(const Eref &e, double v)
Definition: Pool.cpp:197
const Cinfo * cinfo() const
Definition: Element.cpp:66
double vGetNinit(const Eref &e) const
Definition: Pool.cpp:180
double n_
Definition: Pool.h:83
unsigned int SpeciesId
Definition: PoolBase.h:18
double vGetDiffConst(const Eref &e) const
Definition: Pool.cpp:207
void vSetNinit(const Eref &e, double v)
Definition: Pool.cpp:175
SpeciesId vGetSpecies(const Eref &e) const
Definition: Pool.cpp:237
double diffConst_
initial number of molecules.
Definition: Pool.h:85
double motorConst_
Diffusion constant.
Definition: Pool.h:86
double vGetN(const Eref &e) const
Definition: Pool.cpp:170
#define EPSILON
Definition: Pool.cpp:16
void vSetVolume(const Eref &e, double v)
Definition: Pool.cpp:222
double A_
Motor transport constant.
Definition: Pool.h:87
unsigned int species_
Definition: Pool.h:94
double getNinit(const Eref &e) const
Definition: PoolBase.cpp:319
void replaceCinfo(const Cinfo *newCinfo)
Support function for zombieSwap, replaces Cinfo.
Definition: Element.cpp:740
Definition: Cinfo.h:18
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
double lookupVolumeFromMesh(const Eref &e)
void vDecrement(double val)
Definition: Pool.cpp:141