/** Create cvodeData.
    Use the odeModel structure to initialize and
    fill the data structure cvodeData_t *, that can then
    be passed to CVODE for integration */
SBML_ODESOLVER_API cvodeData_t *CvodeData_create(odeModel_t *om)
{
  int neq, nconst, nass, nvalues, nevents;
  cvodeData_t *data;

  neq    = om->neq;
  nconst = om->nconst;
  nass   = om->nass;
  nevents = Model_getNumEvents(om->simple);
  nvalues = neq + nconst + nass;

  /* allocate memory for current integration data storage */
  data = CvodeData_allocate(nvalues, nevents, neq);
  RETURN_ON_FATALS_WITH(NULL);

  data->nvalues = nvalues;

  /* set pointer to input model */
  data->model = om ;

  /* set integration run counter to 0,
     used for multiple reruns of integration  */
  data->run = 0;

    /* initialize values */
  CvodeData_initializeValues(data);
  
  return data;
}
示例#2
0
/** Creates cvodeData from an odeModel and initial values from the
    original SBML model.

    This function is internally used by integratorInstance creation.
    
    It is available as an API function, so users can create this
    structure from an odeModel to evaluate formulae in odeModel
    independent of integratorInstance.
*/
SBML_ODESOLVER_API cvodeData_t *CvodeData_create(odeModel_t *om)
{
  int nvalues;
  cvodeData_t *data;

  nvalues = om->neq + om->nconst + om->nass;

  /* allocate memory for current integration data storage */
  data = CvodeData_allocate(nvalues, om->nevents, om->neq);
  if ( data == NULL ) return NULL;

  data->allRulesUpdated = 0;
  
  /* set pointer to input model */
  data->model = om ;

  return data;
}