MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
lookupVolumeFromMesh.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

double convertConcToNumRateInTwoCompts (double v1, unsigned int n1, double v2, unsigned int n2, double scale)
 
double convertConcToNumRateUsingMesh (const Eref &e, const SrcFinfo *pools, bool doPartialConversion)
 
double convertConcToNumRateUsingVol (const Eref &e, const SrcFinfo *pools, double volume, double scale, bool doPartialConversion)
 
ObjId getCompt (Id id)
 
unsigned int getReactantVols (const Eref &reac, const SrcFinfo *pools, vector< double > &vols)
 
double lookupVolumeFromMesh (const Eref &e)
 

Variables

const double CONC_UNIT_CONV
 

Function Documentation

double convertConcToNumRateInTwoCompts ( double  v1,
unsigned int  n1,
double  v2,
unsigned int  n2,
double  scale 
)

Generates conversion factor for rates from concentration to mol# units. This variant is used when the reactants are in different compartments or mesh entries, and may therefore have different volumes. We already know the reactants and their affiliations. We use the first vol, v1, as the reference. The outcome of this calculation is: kf = Kf * convertConcToNumRate. The scale term is a conversion from the conc units to SI: The scale term is 1 if conc units are in SI, which is equal to moles per cubic metre, which is equal to millimolar. The scale term is 1e-3 for micromolar, uM.

Generates conversion factor for rates from concentration to mol# units. This variant is used when the reactants are in different compartments or mesh entries, and may therefore have different volumes. We already know the reactants and their affiliations.

Definition at line 187 of file lookupVolumeFromMesh.cpp.

References NA.

189 {
190  double conversion = 1.0;
191 
192  for ( unsigned int i = 1; i < n1; ++i )
193  conversion *= scale * NA * v1;
194  for ( unsigned int i = 0; i < n2; ++i )
195  conversion *= scale * NA * v2;
196 
197  if ( conversion <= 0 )
198  conversion = 1.0;
199 
200  return conversion;
201 }
const double NA
Definition: consts.cpp:15
double convertConcToNumRateUsingMesh ( const Eref e,
const SrcFinfo pools,
bool  doPartialConversion 
)

Generates conversion factor for rates from concentration to mol# units. Assumes that all reactant pools (substrate and product) are within the same mesh entry and therefore have the same volume. The outcome of this calculation is: kf = Kf * convertConcToNumRate. The Eref is an Enz or Reac. The SrcFinfo is a message to the pools. The meshIndex specifies the mesh voxel to use. The scale term is a conversion from the conc units to SI: The scale term is 1 if conc units are in SI, which is equal to moles per cubic metre, which is equal to millimolar. The scale term is 1e-3 for micromolar, uM. The doPartialConversion flag tells the function that there are other substrates not in the 'pools' list, and so it should compute the conversion for all pools, not n-1. This flag defaults to 0.

Returns conversion factor to convert rates from concentration to mol# units. Handles arbitrary combinations of volumes. Assumes that the reference volume for computing rates is the smallest volume. 26 Feb 2013: This is now changed to use the volume of the first entry. Should only be used for substrates. For products need to find the first substrate, separately, and use that to scale down the conv factor. Assumes all calculations are in SI: cubic metres and millimolar. 27 Feb 2013: This is changed to use the volume of a voxel of the the home compartment of the reac. Be warned: this can cause unexpected problems if the home compartment isn't according to convention. For example, if there is a single substrate and the home compartment is elsewhere, you will get very odd Kf:kf values. 9 Oct 2013: This is now changed to use the volume of the first substrate. Note that if the conversion is for products, then the routine has to look up the substrate list to get the first substrate. Reason is that the home compartment was often wrong in ReadKkit. Unfortunately this may yet cause problems with SBML. I don't know what conventions they use for cross-compartment reactions.

Definition at line 114 of file lookupVolumeFromMesh.cpp.

References Element::cinfo(), Eref::element(), Cinfo::findFinfo(), getReactantVols(), NA, and Finfo::name().

Referenced by ZombieEnz::vGetK1(), Reac::vGetNumKb(), ZombieReac::vGetNumKb(), Reac::vGetNumKf(), ZombieReac::vGetNumKf(), Enz::vGetNumKm(), ZombieMMenz::vGetNumKm(), MMenz::vGetNumKm(), ZombieEnz::vGetNumKm(), Reac::vReinit(), MMenz::vRemesh(), Reac::vRemesh(), Enz::vSetConcK1(), Reac::vSetConcKb(), Reac::vSetConcKf(), ZombieEnz::vSetK1(), Enz::vSetK1(), Enz::vSetKm(), MMenz::vSetKm(), ZombieReac::vSetNumKb(), Reac::vSetNumKb(), ZombieReac::vSetNumKf(), Reac::vSetNumKf(), Enz::vSetNumKm(), ZombieMMenz::vSetNumKm(), MMenz::vSetNumKm(), ZombieEnz::vSetNumKm(), and Enz::vSetRatio().

116 {
117  vector< double > vols;
118  // unsigned int smallest = getReactantVols( e, pools, vols );
119  double conv = 1.0;
120  getReactantVols( e, pools, vols );
121  if ( vols.size() == 0 ) { // Should this be an assertion?
122  // cout << "Warning: convertConcToNumRateUsingMesh: zero reactants on " << e.id().path() << endl;
123  return 1.0;
124  }
125  for ( unsigned int i = 0; i < vols.size(); ++i ) {
126  conv *= vols[i] * NA;
127  }
128  if ( !doPartialConversion ) {
129  if ( pools->name() == "subOut" ) {
130  conv /= vols[0] * NA;
131  } else {
132  const Finfo* f = e.element()->cinfo()->findFinfo( "subOut" );
133  assert( f );
134  const SrcFinfo* toSub = dynamic_cast< const SrcFinfo* >( f );
135  assert( toSub );
136  vector< double > subVols;
137  getReactantVols( e, toSub, subVols );
138  if ( subVols.size() == 0 ) // no substrates!
139  return 1.0;
140  conv /= subVols[0] * NA;
141  }
142  /*
143  Id compt = getCompt( e.id() );
144  if ( compt != Id() ) {
145  Id mesh( compt.value() + 1 );
146  double meshVol = Field< double >::get( mesh, "volume" );
147  conv /= meshVol * NA;
148  }
149  */
150  }
151  return conv;
152 }
const double NA
Definition: consts.cpp:15
unsigned int getReactantVols(const Eref &reac, const SrcFinfo *pools, vector< double > &vols)
const string & name() const
Definition: Finfo.cpp:80
Element * element() const
Definition: Eref.h:42
const Cinfo * cinfo() const
Definition: Element.cpp:66
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double convertConcToNumRateUsingVol ( const Eref e,
const SrcFinfo pools,
double  volume,
double  scale,
bool  doPartialConversion 
)

Generates conversion factor for rates from concentration to mol# units. This variant already knows the volume, but has to figure out # of reactants. The scale term is a conversion from the conc units to SI: The scale term is 1 if conc units are in SI, which is equal to moles per cubic metre, which is equal to millimolar. The scale term is 1e-3 for micromolar, uM. The doPartialConversion flag tells the function that there are other substrates not in the 'pools' list, and so it should compute the conversion for all pools, not n-1. This flag defaults to 0.

Generates conversion factor for rates from concentration to mol# units. This variant already knows the volume, but has to figure out # of reactants.

Definition at line 160 of file lookupVolumeFromMesh.cpp.

References Eref::element(), SrcFinfo::getBindIndex(), Element::getMsgAndFunc(), and NA.

162 {
163  const vector< MsgFuncBinding >* mfb =
164  e.element()->getMsgAndFunc( pools->getBindIndex() );
165  double conversion = 1.0;
166  if ( mfb && mfb->size() > 0 ) {
167  if ( doPartialConversion || mfb->size() > 1 ) {
168  conversion = scale * NA * volume;
169  double power = doPartialConversion + mfb->size() - 1;
170  if ( power > 1.0 ) {
171  conversion = pow( conversion, power );
172  }
173  }
174  if ( conversion <= 0 )
175  conversion = 1.0;
176  }
177 
178  return conversion;
179 }
const double NA
Definition: consts.cpp:15
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
Element * element() const
Definition: Eref.h:42
const vector< MsgFuncBinding > * getMsgAndFunc(BindIndex b) const
Definition: Element.cpp:300

+ Here is the call graph for this function:

ObjId getCompt ( Id  id)

Returns the compartment in which the specified object is located. Traverses the tree toward the rood till it finds a compartment.

Definition at line 23 of file lookupVolumeFromMesh.cpp.

References Element::cinfo(), ObjId::element(), getCompt(), ObjId::id, Cinfo::isA(), and Neutral::parent().

Referenced by ReadKkit::assignPoolCompartments(), ReadKkit::assignReacCompartments(), findMeshOfEnz(), findParentComptOfReac(), getCompt(), Stoich::installEnzyme(), Stoich::installMMenz(), Stoich::installReaction(), isOffSolverReac(), and lookupVolumeFromMesh().

24 {
25  ObjId pa = Neutral::parent( id.eref() ).id;
26  if ( pa == ObjId() )
27  return pa;
28  else if ( pa.element()->cinfo()->isA( "ChemCompt" ) )
29  return pa;
30  return getCompt( pa );
31 }
static ObjId parent(const Eref &e)
Definition: Neutral.cpp:701
Id id
Definition: ObjId.h:98
Definition: ObjId.h:20
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
const Cinfo * cinfo() const
Definition: Element.cpp:66
Element * element() const
Definition: ObjId.cpp:124
ObjId getCompt(Id id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int getReactantVols ( const Eref reac,
const SrcFinfo pools,
vector< double > &  vols 
)

Utility function to get volumes for all reactants (substrates or products) of Reacs or Enzymes. Does NOT get volumes for the Enzyme itself.

Figures out all the volumes of the substrates or products on the specified reaction 'reac'. The SrcFinfo is for the sub or prd msg. Returns the index of the smallest vol. Passes back a vector of volumes. The meshIndex is zero. Reasoning is as follows: both in the case of well-stirred (single mesh entry) models, and in the case of spatial models with consistent mesh sizes and alignments, the mesh entry volumes are in the same ratio. Cases with more complex arrangements may also use the current vols as a starting point, but will need to add index-specific scaling factors to their reaction system.

Definition at line 58 of file lookupVolumeFromMesh.cpp.

References Element::cinfo(), Msg::e2(), Eref::element(), SrcFinfo::getBindIndex(), Msg::getMsg(), Element::getMsgAndFunc(), Cinfo::isA(), and lookupVolumeFromMesh().

Referenced by convertConcToNumRateUsingMesh().

60 {
61  static const unsigned int meshIndex = 0;
62 
63  const vector< MsgFuncBinding >* mfb =
64  reac.element()->getMsgAndFunc( pools->getBindIndex() );
65  unsigned int smallIndex = 0;
66 
67  vols.resize( 0 );
68  if ( mfb ) {
69  for ( unsigned int i = 0; i < mfb->size(); ++i ) {
70  double v = 1;
71  Element* pool = Msg::getMsg( (*mfb)[i].mid )->e2();
72  if ( pool == reac.element() )
73  pool = Msg::getMsg( (*mfb)[i].mid )->e1();
74  assert( pool != reac.element() );
75  Eref pooler( pool, meshIndex );
76  if ( pool->cinfo()->isA( "PoolBase" ) ) {
77  v = lookupVolumeFromMesh( pooler );
78  } else {
79  cout << "Error: getReactantVols: pool is of unknown type\n";
80  assert( 0 );
81  }
82  vols.push_back( v );
83  if ( v < vols[0] )
84  smallIndex = i;
85  }
86  }
87  return smallIndex;
88 }
Element * e2() const
Definition: Msg.h:68
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
Element * element() const
Definition: Eref.h:42
Definition: Eref.h:26
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
const vector< MsgFuncBinding > * getMsgAndFunc(BindIndex b) const
Definition: Element.cpp:300
const Cinfo * cinfo() const
Definition: Element.cpp:66
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
double lookupVolumeFromMesh(const Eref &e)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double lookupVolumeFromMesh ( const Eref e)

Utility function for kinetics classes to find their volume from the attached mesh. Works for Pools and subclasses.

Utility function to find the size of a pool. We assume one-to-one match between pool indices and mesh indices: that is what they are for.

Definition at line 36 of file lookupVolumeFromMesh.cpp.

References Eref::dataIndex(), LookupField< L, A >::get(), getCompt(), and Eref::id().

Referenced by ReadKkit::buildEnz(), getReactantVols(), PoolBase::setNinit(), ZombiePool::vGetConc(), Pool::vGetConc(), ZombiePool::vGetConcInit(), ZombiePool::vGetVolume(), Pool::vGetVolume(), ZombieBufPool::vSetConc(), BufPool::vSetConc(), ZombiePool::vSetConc(), Pool::vSetConc(), ZombiePool::vSetConcInit(), and Pool::vSetConcInit().

37 {
38  ObjId compt = getCompt( e.id() );
39  if ( compt == ObjId() )
40  return 1.0;
42  get( compt, "oneVoxelVolume", e.dataIndex() );
43 }
Id id() const
Definition: Eref.cpp:62
static A get(const ObjId &dest, const string &field, L index)
Definition: SetGet.h:532
unsigned int dataIndex() const
Definition: Eref.h:50
Definition: ObjId.h:20
ObjId getCompt(Id id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const double CONC_UNIT_CONV

Used to provide the conversion factor from preferred units to SI.