22 #include "../mesh/VoxelJunction.h"
25 #include "../builtins/Variable.h"
26 #include "../builtins/Function.h"
30 #include "../scheduling/Clock.h"
31 #include "../shell/Shell.h"
32 #include "../shell/Wildcard.h"
41 "Wildcard path for reaction system handled by Stoich",
48 "Id of Kinetic reaction solver class that works with this "
50 " Must be of class Ksolve, or Gsolve (at present) "
51 " Must be assigned before the path is set.",
58 "Id of Diffusion solver class that works with this Stoich."
59 " Must be of class Dsolve "
60 " If left unset then the system will be assumed to work in a"
61 " non-diffusive, well-stirred cell. If it is going to be "
62 " used it must be assigned before the path is set.",
69 "Id of chemical compartment class that works with this Stoich."
70 " Must be derived from class ChemCompt."
71 " If left unset then the system will be assumed to work in a"
72 " non-diffusive, well-stirred cell. If it is going to be "
73 " used it must be assigned before the path is set.",
80 "Flag: allow negative values if true. Default is false."
81 " This is used to protect the chemical system from going unstable"
82 " in cases where the numerical integration gives a negative value."
83 " Typically it is a small negative value but is obviously"
84 " physically impossible. In some cases we want to use the "
85 " solvers to handle general systems of equations (not purely "
86 " chemical ones), so we have this flag to allow it.",
93 "Number of time-varying pools to be computed by the "
100 "Number of buffered pools to be computed by the "
101 "numerical engine. Includes pools controlled by functions.",
107 "Total number of pools handled by the numerical engine. "
108 "This includes variable ones, buffered ones, and functions. "
109 "It includes local pools as well as cross-solver proxy pools.",
115 "Number of pools here by proxy as substrates of a cross-"
116 "compartment reaction.",
123 "Map to look up the index of the pool from its Id."
124 "poolIndex = poolIdMap[ Id::value() - poolOffset ] "
125 "where the poolOffset is the smallest Id::value. "
126 "poolOffset is passed back as the last entry of this vector."
127 " Any Ids that are not pools return EMPTY=~0. ",
133 "Total number of rate terms in the reaction system.",
142 "The non-zero matrix entries in the sparse matrix. Their"
143 "column indices are in a separate vector and the row"
144 "information in a third",
152 "Column Index of each matrix entry",
160 "Row start for each block of entries and column indices",
168 "Return vector of proxy pools for X-compt reactions between "
169 "current stoich, and the argument, which is a StoichId. "
170 "The returned pools belong to the compartment handling the "
171 "Stoich specified in the argument. "
172 "If no pools are found, return an empty vector.",
178 "Status of Stoich in the model building process. Values are: "
179 "-1: Reaction path not yet assigned.\n "
180 "0: Successfully built stoichiometry matrix.\n "
181 "1: Warning: Missing a reactant in a Reac or Enz.\n "
182 "2: Warning: Missing a substrate in an MMenz.\n "
183 "3: Warning: Missing substrates as well as reactants.\n "
184 "4: Warning: Compartment not defined.\n "
185 "8: Warning: Neither Ksolve nor Dsolve defined.\n "
186 "16: Warning: No objects found on path.\n "
195 "Restore all zombies to their native state",
199 "Args: voxel#, volRatio\n"
200 "Handles requests for runtime volume changes in the specified "
201 "voxel#, Used in adaptors changing spine vols.",
214 static Finfo* stoichFinfos[] =
241 sizeof( stoichFinfos ) /
sizeof (
Finfo* ),
258 allowNegative_( false ),
279 for ( vector< RateTerm* >::iterator j =
rates_.begin();
283 for ( vector< FuncTerm* >::iterator j =
funcs_.begin();
325 cout <<
"Stoich::setPath: need to clear old path.\n";
331 cout <<
"Stoich::setPath: need to first set ksolve.\n";
335 vector< ObjId > elist;
343 ret.resize( elist.size() );
344 for (
unsigned int i = 0; i < elist.size(); ++i )
345 ret[i] = elist[i].
id;
351 ret.reserve( elist.size() );
352 for ( vector< ObjId >::const_iterator
353 i = elist.begin(); i != elist.end(); ++i )
355 if ( i->element()->cinfo()->isA(
"PoolBase" ) ||
356 i->element()->cinfo()->isA(
"ReacBase" ) ||
357 i->element()->cinfo()->isA(
"EnzBase" ) ||
358 i->element()->cinfo()->isA(
"Function" ) )
359 ret.push_back( i->id );
367 cout <<
"Warning: Stoich::setElist/setPath: Compartment not set. Aborting.\n";
373 cout <<
"Warning: Stoich::setElist/setPath: Neither solver has been set. Aborting.\n";
384 if( temp.size() == 0 )
386 cout <<
"Warning: Stoich::setElist/setPath: No kinetics objects found on path. Aborting.\n";
431 cout <<
"Error: Stoich::setKsolve: invalid class assigned,"
432 " should be either Ksolve or Gsolve\n";
460 cout <<
"Error: Stoich::setDsolve: invalid class assigned,"
461 " should be Dsolve\n";
481 cout <<
"Error: Stoich::setCompartment: invalid class assigned,"
482 " should be ChemCompt or derived class\n";
486 vector< double > temp;
487 vector< double > vols =
489 if ( vols.size() > 0 )
492 sort( vols.begin(), vols.end() );
493 double bigVol = vols.back();
494 assert( bigVol > 0.0 );
495 temp.push_back( vols[0] / bigVol );
496 for ( vector< double >::iterator
497 i = vols.begin(); i != vols.end(); ++i )
499 if ( !
doubleEq( temp.back(), *i / bigVol ) )
500 temp.push_back( *i / bigVol );
533 return vector< unsigned int >( 1, 0 );
535 unsigned int minId = 1000000;
536 unsigned int maxId = 0;
537 unsigned int maxIndex = 0;
538 map< Id, unsigned int >::const_iterator i;
541 unsigned int j = i->first.value();
542 if ( j < minId ) minId = j;
543 if ( j > maxId ) maxId = j;
544 if ( maxIndex < i->second ) maxIndex = i->second;
546 vector< unsigned int > ret( maxId - minId + 2, ~0U );
549 unsigned int j = i->first.value() - minId;
552 ret[ ret.size() -1 ] = minId;
559 map< Id, unsigned int >::const_iterator i;
562 if( i->second == index )
585 assert( i <
rates_.size() );
601 assert( i <
funcs_.size() );
629 static vector< Id >
dummy;
632 cout <<
"Warning: Stoich::getProxyPools: argument " << i <<
633 " is not a Stoich\n";
637 map< Id, vector< Id > >::const_iterator j =
660 vector< Id >& poolCompts,
661 map< Id, Id >& poolComptMap )
663 assert( myCompt !=
Id() );
666 vector< Id > neighbors;
670 neighbors.insert( neighbors.end(), n2.begin(), n2.end() );
671 for ( vector< Id >::const_iterator
672 j = neighbors.begin(); j != neighbors.end(); ++j )
675 if ( myCompt != otherCompt )
678 poolCompts.push_back( otherCompt );
679 poolComptMap[ *j ] = otherCompt;
681 if ( j->element()->cinfo()->isA(
"BufPool" ) )
683 cout <<
"Warning: Avoid BufPool: " << j->
path() <<
684 "\n as reactant in cross-compartment reactions\n";
697 for ( vector< Id >::const_iterator i = compts.begin();
698 i != compts.end(); ++i )
700 if ( ret.first ==
Id() )
704 else if ( ret.first != *i )
706 if ( ret.second ==
Id() )
710 cout <<
"Error: Stoich::extractCompts: more than 2 compartments\n";
715 if ( ( ret.second !=
Id() ) && ret.second < ret.first )
718 ret.first = ret.second;
719 ret.second = ret.first;
734 map< Id, Id > poolComptMap;
737 temp.reserve( elist.size() );
738 for ( vector< Id >::const_iterator
739 i = elist.begin(); i != elist.end(); ++i )
741 const Element* e = i->element();
747 if ( e->
cinfo()->
isA(
"ReacBase" ) )
752 else if ( e->
cinfo()->
isA(
"CplxEnzBase" ) )
757 else if ( e->
cinfo()->
isA(
"EnzBase" ) )
765 temp.push_back( *i );
770 temp.push_back( *i );
775 for ( map< Id, Id >::iterator
776 i = poolComptMap.begin(); i != poolComptMap.end(); ++i )
784 for ( map<
Id, vector< Id > >::iterator
787 if ( i->first != myCompt )
790 i->second.begin(), i->second.end() );
902 vector< string > func;
904 if ( func.size() > 0 && func[0] ==
"increment" )
910 else if ( func.size() > 0 && func[0] ==
"setNumKf" )
926 sort( v.begin(), v.end() );
927 vector< Id >::iterator last = unique( v.begin(), v.end() );
928 v.erase( last, v.end() );
953 unsigned int totNumRates =
958 rates_.resize( totNumRates, 0 );
984 for ( vector< Id >::const_iterator i = elist.begin();
985 i != elist.end(); ++i )
1002 vector< Id >::iterator i;
1016 vector< Id >::iterator i;
1058 vector< Id >::iterator i;
1070 static const Finfo* funcInputFinfo = varCinfo->
findFinfo(
"input" );
1082 vector< pair< Id, unsigned int> > srcPools;
1086 ei.element()->getInputsWithTgtIndex( srcPools, df );
1087 assert( numSrc == n );
1088 vector< unsigned int > poolIndex( numSrc, 0 );
1089 for (
unsigned int i = 0; i < numSrc; ++i )
1091 unsigned int j = srcPools[i].second;
1094 cout <<
"Warning: Stoich::installAndUnschedFunc: tgt index not allocated, " << j <<
", " << numSrc << endl;
1107 assert( funcIndex != ~0U );
1110 funcs_[ funcIndex ] = ft;
1116 static const Finfo* funcInputFinfo = varCinfo->
findFinfo(
"input" );
1125 assert( rateIndex != ~0U );
1126 assert( tempIndex != ~0U );
1130 int stoichEntry =
N_.
get( tempIndex, rateIndex );
1131 N_.
set( tempIndex, rateIndex, stoichEntry + 1 );
1136 vector< pair< Id, unsigned int > > srcPools;
1140 ei.element()->getInputsWithTgtIndex( srcPools, df );
1141 assert( numSrc == n );
1142 vector< unsigned int > poolIndex( numSrc, 0 );
1143 for (
unsigned int i = 0; i < numSrc; ++i )
1145 unsigned int j = srcPools[i].second;
1148 cout <<
"Warning: Stoich::installAndUnschedFuncRate: tgt index not allocated, " << j <<
", " << numSrc << endl;
1162 static const Finfo* funcSrcFinfo = varCinfo->
findFinfo(
"input" );
1163 assert( funcSrcFinfo );
1168 assert( rateIndex != ~0U );
1170 double k =
rates_[rateIndex]->getR1();
1171 vector< unsigned int > reactants;
1172 unsigned int numForward =
rates_[rateIndex]->getReactants( reactants );
1174 reactants.resize( numForward );
1176 delete rates_[rateIndex];
1182 vector< Id > srcPools;
1186 ei.element()->getNeighbors( srcPools, funcSrcFinfo);
1187 assert( numSrc == n );
1188 vector< unsigned int > poolIndex( numSrc, 0 );
1189 for (
unsigned int i = 0; i < numSrc; ++i )
1198 for (
unsigned int i = 0; i <
rates_.size(); ++i )
1200 vector< unsigned int > molIndex;
1201 if (
rates_[i]->getReactants( molIndex ) > 1 )
1203 if ( molIndex.size() == 2 && molIndex[0] == molIndex[1] )
1207 oldRate->
getR1(), molIndex[ 0 ]
1211 else if ( molIndex.size() > 2 )
1234 if ( !finfo )
return Id();
1238 if ( ret[0].element()->cinfo()->isA(
"Function" ) )
1248 if ( funcId !=
Id() )
1257 if ( funcId !=
Id() )
1285 vector< Id > temp = elist;
1291 for ( vector< Id >::const_iterator i = temp.begin(); i != temp.end(); ++i )
1303 if ( funcId !=
Id() )
1316 for (
unsigned int j = 0; j <
numVoxels_; ++j )
1329 if ( funcId ==
Id() )
1332 if ( funcId !=
Id() )
1334 cout <<
"Warning: Stoich::zombifyModel: Probably you don't want to send increment to a BufPool:" << i->path() << endl;
1342 for (
unsigned int j = 0; j <
numVoxels_; ++j )
1353 if ( funcId !=
Id() )
1355 Element* fe = funcId.element();
1416 temp.insert( temp.end(),
1418 for ( vector< Id >::iterator i = temp.begin(); i != temp.end(); ++i )
1426 temp.insert( temp.end(),
1428 for ( vector< Id >::iterator i = temp.begin(); i != temp.end(); ++i )
1436 temp.insert( temp.end(),
1438 for ( vector< Id >::iterator i = temp.begin(); i != temp.end(); ++i )
1446 temp.insert( temp.end(),
1448 for ( vector< Id >::iterator i = temp.begin(); i != temp.end(); ++i )
1456 if ( e != 0 && e->
getTick() == -2 )
1466 map< Id, unsigned int >::const_iterator i =
poolLookup_.find(
id );
1476 map< Id, unsigned int >::const_iterator i =
rateTermLookup_.find(
id );
1486 map< Id, unsigned int >::const_iterator i =
funcLookup_.find(
id );
1495 double rate,
const vector< Id >& reactants )
1498 if ( reactants.size() == 1 )
1503 else if ( reactants.size() == 2 )
1509 else if ( reactants.size() > 2 )
1511 vector< unsigned int > temp;
1512 for (
unsigned int i = 0; i < reactants.size(); ++i )
1514 rateTerm =
new NOrder( rate, temp );
1518 cout <<
"Warning: Stoich::makeHalfReaction: no reactants\n";
1526 const vector< Id >& subs,
1527 const vector< Id >& prds )
1529 static vector< Id >
dummy;
1533 vector< Id > subCompt;
1534 vector< Id > prdCompt;
1535 for ( vector< Id >::const_iterator
1536 i = subs.begin(); i != subs.end(); ++i )
1538 for ( vector< Id >::const_iterator
1539 i = prds.begin(); i != prds.end(); ++i )
1563 const vector< Id >& subs,
1564 const vector< Id >& prds )
1569 unsigned int revRateIndex = rateIndex;
1572 rates_[ rateIndex ] = forward;
1573 revRateIndex = rateIndex + 1;
1574 rates_[ revRateIndex ] = reverse;
1582 vector< unsigned int > molIndex;
1583 vector< double > reacScaleSubstrates;
1584 vector< double > reacScaleProducts;
1588 unsigned int numReactants = forward->
getReactants( molIndex );
1589 for (
unsigned int i = 0; i < numReactants; ++i )
1591 int temp =
N_.
get( molIndex[i], rateIndex );
1592 N_.
set( molIndex[i], rateIndex, temp - 1 );
1593 temp =
N_.
get( molIndex[i], revRateIndex );
1594 N_.
set( molIndex[i], revRateIndex, temp + 1 );
1598 for (
unsigned int i = 0; i < numReactants; ++i )
1600 int temp =
N_.
get( molIndex[i], rateIndex );
1601 N_.
set( molIndex[i], rateIndex, temp + 1 );
1602 temp =
N_.
get( molIndex[i], revRateIndex );
1603 N_.
set( molIndex[i], revRateIndex, temp - 1 );
1608 unsigned int numReactants = forward->
getReactants( molIndex );
1609 for (
unsigned int i = 0; i < numReactants; ++i )
1611 int temp =
N_.
get( molIndex[i], rateIndex );
1612 N_.
set( molIndex[i], rateIndex, temp - 1 );
1616 for (
unsigned int i = 0; i < numReactants; ++i )
1618 int temp =
N_.
get( molIndex[i], revRateIndex );
1619 N_.
set( molIndex[i], rateIndex, temp + 1 );
1627 cout <<
"Warning: Stoich::installMMenz: No " << s <<
" for: " <<
1628 enzId.
path() << endl;
1637 const vector< Id >& subs,
const vector< Id >& prds )
1642 if ( enzMols.size() != 1 )
1649 if ( prds.size() < 1 )
1657 if ( subs.size() == 1 )
1660 meb =
new MMEnzyme1( 1, 1, enzIndex, subIndex );
1662 else if ( subs.size() > 1 )
1664 vector< unsigned int > v;
1665 for (
unsigned int i = 0; i < subs.size(); ++i )
1668 meb =
new MMEnzyme( 1, 1, enzIndex, rateTerm );
1679 vector< Id > subCompt;
1681 for ( vector< Id >::const_iterator
1682 i = subs.begin(); i != subs.end(); ++i )
1692 const vector< Id >& subs,
const vector< Id >& prds )
1696 for (
unsigned int i = 0; i < subs.size(); ++i )
1699 int temp =
N_.
get( poolIndex, rateIndex );
1700 N_.
set( poolIndex, rateIndex, temp - 1 );
1702 for (
unsigned int i = 0; i < prds.size(); ++i )
1705 int temp =
N_.
get( poolIndex, rateIndex );
1706 N_.
set( poolIndex, rateIndex, temp + 1 );
1720 rates_[ rateIndex ] = r1;
1721 rates_[ rateIndex + 1 ] = r2;
1722 rates_[ rateIndex + 2 ] = r3;
1727 rates_[ rateIndex + 1 ] = r3;
1733 const vector< Id >& subs,
const vector< Id >& prds )
1735 vector< Id > temp( subs );
1736 temp.insert( temp.begin(), enzMolId );
1739 temp.resize( 1, cplxId );
1747 vector< Id > subCompt;
1749 for ( vector< Id >::const_iterator
1750 i = subs.begin(); i != subs.end(); ++i )
1778 Id enzId,
Id enzMolId,
const vector< Id >& prds )
1784 rates_[ rateIndex ] = r1;
1785 rates_[ rateIndex + 1 ] = r2;
1786 rates_[ rateIndex + 2 ] = r3;
1791 rates_[ rateIndex + 1 ] = r3;
1794 vector< unsigned int > poolIndex;
1795 unsigned int numReactants = r2->
getReactants( poolIndex );
1796 assert( numReactants == 1 );
1797 unsigned int cplxPool = poolIndex[0];
1802 for (
unsigned int i = 0; i < numReactants; ++i )
1804 int temp =
N_.
get( poolIndex[i], rateIndex );
1805 N_.
set( poolIndex[i], rateIndex, temp - 1 );
1806 temp =
N_.
get( poolIndex[i], rateIndex + 1 );
1807 N_.
set( poolIndex[i], rateIndex + 1, temp + 1 );
1810 int temp =
N_.
get( cplxPool, rateIndex );
1811 N_.
set( cplxPool, rateIndex, temp + 1 );
1812 temp =
N_.
get( cplxPool, rateIndex + 1 );
1813 N_.
set( cplxPool, rateIndex + 1, temp -1 );
1818 for (
unsigned int i = 0; i < numReactants; ++i )
1820 int temp =
N_.
get( poolIndex[i], rateIndex );
1821 N_.
set( poolIndex[i], rateIndex, temp - 1 );
1823 int temp =
N_.
get( cplxPool, rateIndex );
1824 N_.
set( cplxPool, rateIndex, temp + 1 );
1830 unsigned int reac3index = (
useOneWay_ ) ? rateIndex + 2 : rateIndex + 1;
1831 int temp =
N_.
get( cplxPool, reac3index );
1832 N_.
set( cplxPool, reac3index, temp - 1 );
1835 for (
unsigned int i = 0; i < prds.size(); ++i )
1838 int temp =
N_.
get( j, reac3index );
1839 N_.
set( j, reac3index, temp + 1 );
1843 temp =
N_.
get( enzPool, reac3index );
1844 N_.
set( enzPool, reac3index, temp + 1 );
1882 rates_[ i + 1 ]->setR1( v );
1947 rates_[ index ]->setR1( v );
1956 rates_[ index + 1 ]->setR1( v );
1961 rates_[ index ]->setR2( v );
1971 rates_[ index + 2 ]->setR1( v );
1976 rates_[ index + 1 ]->setR1( v );
2050 cout <<
"Warning: Stoich::setFunctionExpr( " << e.
id().
path() <<
2051 ", " << expr <<
" ): func not found";
2074 for ( vector< Id >::const_iterator
2081 cout <<
"Id=" << *i <<
", (Kf,Kb) = (" << Kf <<
", " << Kb <<
2082 "), (kf, kb) = (" << kf <<
", " << kb <<
")\n";
2095 for ( map<
Id, vector< Id > >::const_iterator
2097 ret.push_back( i->first );
2104 static vector< Id > blank( 0 );
2105 map< Id, vector < Id > >::const_iterator i =
2120 for ( vector< FuncTerm* >::const_iterator i =
funcs_.begin();
2125 (*i)->evalPool( s, t );
2150 for ( vector< Id >::iterator
2158 vector< Id >::iterator i;
2161 assert ( i->element()->cinfo()->isA(
"ReacBase" ) );
2169 assert ( i->element()->cinfo()->isA(
"CplxEnzBase" ) );
2179 assert( i->element()->cinfo()->isA(
"MMEnzBase" ) );
void setExpr(const string &e)
unsigned int innerInstallReaction(Id reacId, const vector< Id > &subs, const vector< Id > &prds)
void updateFuncs(double *s, double t) const
Updates the function values, within s.
double getEnzNumK1(const Eref &e) const
pair< Id, Id > extractCompts(const vector< Id > &compts)
int wildcardFind(const string &path, vector< ObjId > &ret)
vector< vector< Id > > prdComptVec_
Id zombifyPoolFuncWithScaling(Id pool)
void setMMenzKm(const Eref &e, double v) const
double getEnzK2(const Eref &e) const
Get rate k2 (1/sec) for enzyme.
vector< Id > offSolverMMenzVec_
Id getCompartment() const
void installAndUnschedFunc(Id func, Id pool, double volScale)
void setEnzK3(const Eref &e, double v) const
Set rate k3 (1/sec) for enzyme.
void setReacKf(const Eref &e, double v) const
void installAndUnschedFuncRate(Id func, Id pool)
const vector< T > & matrixEntry() const
Here we expose the sparse matrix for MOOSE use.
Id compartment_
Contains Id of compartment holding reac system. Optional.
map< Id, vector< Id > > offSolverPoolMap_
void setAllowNegative(bool v)
T get(unsigned int row, unsigned int column) const
static bool isOffSolverReac(const Element *e, Id myCompt, vector< Id > &poolCompts, map< Id, Id > &poolComptMap)
vector< unsigned int > species_
static const Cinfo * stoichCinfo
double getR1(const Eref &e) const
Element * element() const
Synonym for Id::operator()()
vector< pair< Id, Id > > offSolverMMenzCompts_
void installAndUnschedFuncReac(Id func, Id reac)
std::string path(const std::string &separator="/") const
map< Id, unsigned int > rateTermLookup_
unsigned int value() const
void set(unsigned int row, unsigned int column, T value)
vector< Id > offSolverPoolVec_
void setEnzK1(const Eref &e, double v) const
Later handle all the volumes when this conversion is done.
void resizeArrays()
Using the computed array sizes, now allocate space for them.
void setMMenzKcat(const Eref &e, double v) const
static void zombify(Element *original, const Cinfo *zClass, Id solver)
static DestFinfo dummy("dummy","This Finfo is a dummy. If you are reading this you have used an invalid index", 0)
virtual void setNumPools(unsigned int num)=0
Specifies number of pools (species) handled by system.
static void zombify(Element *original, const Cinfo *zClass, Id solver)
void setVolScale(double vs)
void setReactantIndex(const vector< unsigned int > &mol)
unsigned int getMsgTargetAndFunctions(DataId srcDataId, const SrcFinfo *finfo, vector< ObjId > &tgt, vector< string > &func) const
static const Cinfo * find(const std::string &name)
static const Cinfo * zombieMMenzCinfo
void filterWildcards(vector< Id > &ret, const vector< ObjId > &elist)
const KinSparseMatrix & getStoichiometryMatrix() const
Updates the rates for cross-compartment reactions.
static const Cinfo * bufPoolCinfo
static const Cinfo * mmEnzCinfo
ZombiePoolInterface * dinterface_
Pointer for dsolve.
void myUnique(vector< Id > &v)
static void zombify(Element *original, const Cinfo *zClass, Id solver)
static bool set(const ObjId &dest, const string &field, A arg)
vector< Id > poolFuncVec_
unsigned int convertIdToFuncIndex(Id id) const
void installReaction(Id reacId, const vector< Id > &subs, const vector< Id > &prds)
static const Cinfo * enzCinfo
vector< Id > getOffSolverCompts() const
void installEnzyme(Id enzId, Id enzMolId, Id cplxId, const vector< Id > &subs, const vector< Id > &prds)
void allocateModelObject(Id id)
Identifies and allocates objects in the Stoich.
void installDummy(RateTerm **entry, Id enzId, const string &s)
void setFunctionExpr(const Eref &e, string expr)
void buildPoolLookup()
Functions to build the maps between Ids and internal indices.
static void zombify(Element *original, const Cinfo *zClass, Id ksolve, Id dsolve)
vector< Id > reacFuncVec_
const vector< Id > & getOffSolverPools() const
void scaleBufsAndRates(unsigned int index, double volScale)
Used to handle run-time size updates for spines.
virtual void setCompartment(Id compartment)
Assigns compartment.
void setReacKb(const Eref &e, double v) const
void buildRateTermLookup()
virtual void updateRateTerms(unsigned int index=~0U)=0
double getR1offset1(const Eref &e) const
bool doubleEq(double x, double y)
const std::string & name() const
vector< Id > incrementFuncVec_
void locateOffSolverReacs(Id myCompt, vector< Id > &elist)
void allocateModel(const vector< Id > &elist)
Calculate sizes of all arrays, and allocate them.
map< Id, unsigned int > funcLookup_
bool getAllowNegative() const
vector< RateTerm * > rates_
vector< pair< Id, Id > > offSolverEnzCompts_
static const Cinfo * zombieReacCinfo
unsigned int convertIdToPoolIndex(Id id) const
vector< unsigned int > getColIndex() const
const vector< Id > & offSolverPoolMap(Id compt) const
static const Cinfo * poolCinfo
KinSparseMatrix N_
N_ is the stoichiometry matrix. All pools * all reac terms.
virtual VoxelPoolsBase * pools(unsigned int i)=0
Return a pointer to the specified VoxelPool.
void setEnzK2(const Eref &e, double v) const
Set rate k2 (1/sec) for enzyme.
vector< Id > getProxyPools(Id i) const
void unZombifyPools()
unZombifies Pools. Helper for unZombifyModel.
static const Cinfo * zombieBufPoolCinfo
vector< vector< Id > > subComptVec_
void setTarget(unsigned int tgt)
const vector< unsigned int > & colIndex() const
unsigned int getNumFuncs() const
const FuncTerm * funcs(unsigned int i) const
virtual double getR1() const =0
Used by Zombie to return rate terms.
vector< pair< Id, Id > > offSolverReacCompts_
Id dsolve_
This contains the Id of the Diffusion solver. Optional.
bool isA(const string &ancestor) const
void scaleVolsBufsRates(double ratio, const Stoich *stoichPtr)
void setExpr(const string &s)
static unsigned int lookupDefaultTick(const string &className)
void setDsolve(Id v)
assigns diffusion solver: Dsovle or a Gillespie voxel stepper
static const Cinfo * functionCinfo
const Cinfo * cinfo() const
vector< int > getMatrixEntry() const
void setSize(unsigned int nrows, unsigned int ncolumns)
unsigned int getNumBufPools() const
Returns number of local buffered pools.
vector< unsigned int > funcTarget_
unsigned int getNumRates() const
void installDummyEnzyme(Id enzId, Id enzMolId)
This is used when the enzyme lacks sub or prd.
unsigned int getNumVarPools() const
Returns number of local pools that are updated by solver.
void setElist(const Eref &e, const vector< ObjId > &elist)
static Id findFuncMsgSrc(Id pa, const string &msg)
Returns Function, if any, acting as src of specified msg into pa.
static const Cinfo * initCinfo()
ZeroOrder * makeHalfReaction(double rate, const vector< Id > &reactants)
Utility function to make a half reac and return the rate term.
void convertRatesToStochasticForm()
const RateTerm * rates(unsigned int i) const
Utility function to return a rates_ entry.
void printRates() const
Another utility function, prints out all Kf, kf, Kb, kb.
double getEnzK3(const Eref &e) const
Get rate k3, aka kcat, for enzyme.
vector< unsigned int > getPoolIdMap() const
static const Cinfo * zombieFunctionCinfo
bool isFuncTarget(unsigned int poolIndex) const
Returns true if the specified pool is controlled by a func.
static const Cinfo * zombieEnzCinfo
void setKsolve(Id v)
assigns kinetic solver: Ksovle or GSSAsolve.
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
virtual void setStoich(Id stoich)=0
double getMMenzKcat(const Eref &e) const
unsigned int convertIdToReacIndex(Id id) const
void zombifyModel(const Eref &e, const vector< Id > &elist)
void updateRatesAfterRemesh()
static const Cinfo * reacCinfo
void setCompartment(Id v)
assigns compartment occupied by Stoich.
unsigned int getNumCoreRates() const
Number of rate terms for reactions purely on this compartment.
unsigned int getNeighbors(vector< Id > &ret, const Finfo *finfo) const
const vector< unsigned int > & rowStart() const
Id ksolve_
This contains the Id of the Kinetic solver.
vector< FuncTerm * > funcs_
The FuncTerms handle mathematical ops on mol levels.
unsigned int getNumAllPools() const
static A get(const ObjId &dest, const string &field)
const vector< RateTerm * > & getRateTerms() const
Returns a reference to the entire rates_ vector.
void setSpecies(unsigned int poolIndex, unsigned int s)
static const Cinfo * initCinfo()
double getR2(const Eref &e) const
vector< unsigned int > getRowStart() const
string getPath(const Eref &e) const
ZombiePoolInterface * kinterface_
Pointer for ksolve.
static void zombify(Element *orig, const Cinfo *zClass, Id ksolve, Id dsolve)
unsigned int getNumProxyPools() const
double getR1offset2(const Eref &e) const
void installMMenz(Id enzId, const vector< Id > &enzMolId, const vector< Id > &subs, const vector< Id > &prds)
void convWildcards(vector< Id > &ret, const vector< ObjId > &elist)
void print() const
Utility function, prints out N_, used for debugging.
unsigned int getReactants(vector< unsigned int > &molIndex) const
double getMMenzNumKm(const Eref &e) const
void setPath(const Eref &e, string path)
map< Id, unsigned int > poolLookup_
Id getPoolByIndex(unsigned int index) const
virtual void setDsolve(Id dsolve)=0
Assigns the diffusion solver. Used by the reac solvers.
virtual void resize(unsigned int newNumData)=0
void setFuncArgIndex(const vector< unsigned int > &mol)
const Finfo * findFinfo(const string &name) const
unsigned int numVoxels_
Number of voxels in reac system.
vector< Id > offSolverReacVec_
vector< Id > offSolverEnzVec_
static const Cinfo * zombiePoolCinfo
unsigned int getSpecies(unsigned int poolIndex) const