Esempio n. 1
0
CEvaluationNode * CMathExpression::createNodeFromValue(const C_FLOAT64 * pDataValue)
{
  CEvaluationNode * pNode = NULL;
  CMathObject * pMathObject = NULL;

  if (pDataValue != NULL)
    {
      pMathObject = pMathContainer->getMathObject(pDataValue);

      if (pMathObject != NULL)
        {
          pNode = new CEvaluationNodeObject((C_FLOAT64 *) pMathObject->getValuePointer());
        }
      else
        {
          // We must have a constant value like the conversion factor from the model.
          pNode = new CEvaluationNodeNumber(*pDataValue);
        }
    }
  else
    {
      // We have an invalid value, i.e. NaN
      pNode = new CEvaluationNodeConstant(CEvaluationNode::S_NAN, "NAN");
    }

  return pNode;
}
Esempio n. 2
0
void CMathReaction::initialize(const CReaction * pReaction, CMathContainer & container)
{
  mpReaction = pReaction;

  // Sanity Check
  if (mpReaction == NULL) return;

  mpParticleFlux = container.getMathObject(mpReaction->getParticleFluxReference());
  mpFlux = container.getMathObject(mpReaction->getFluxReference());
  mpPropensity = container.getMathObject(mpReaction->getPropensityReference());

  mObjectBalance.clear();
  mChangedSpecies.clear();
  mNumberBalance.resize(mpReaction->getChemEq().getBalances().size());
  SpeciesBalance * pStepUpdate = mNumberBalance.array();
  CDataVector < CChemEqElement >::const_iterator it = mpReaction->getChemEq().getBalances().begin();
  CDataVector < CChemEqElement >::const_iterator end = mpReaction->getChemEq().getBalances().end();

  for (; it != end; ++it)
    {
      const CMetab * pMetab = it->getMetabolite();

      if (pMetab != NULL)
        {
          CMathObject * pParticleNumber = container.getMathObject(pMetab->getValueReference());

          if (pParticleNumber->getSimulationType() == CMath::SimulationType::Independent ||
              pParticleNumber->getSimulationType() == CMath::SimulationType::Dependent)
            {
              mChangedSpecies.insert(pParticleNumber);
              mObjectBalance.insert(std::pair < const CMathObject *, C_FLOAT64 >(pParticleNumber, it->getMultiplicity()));
              pStepUpdate->first = (C_FLOAT64 *) pParticleNumber->getValuePointer();
              pStepUpdate->second = it->getMultiplicity();

              ++pStepUpdate;
            }
        }
    }

  mNumberBalance.resize(mChangedSpecies.size(), true);
}