SBML_ODESOLVER_API int IntegratorInstance_simpleOneStep(integratorInstance_t *engine)
{
  /* just increase the time */
  engine->solver->t = engine->solver->tout;
  /* ... and call the default update function */
  return IntegratorInstance_updateData(engine);  
}
Beispiel #2
0
SBML_ODESOLVER_API int IntegratorInstance_idaOneStep(integratorInstance_t *engine)
{
    int i, flag;
    realtype *ydata = NULL;
    
    cvodeSolver_t *solver = engine->solver;
    cvodeData_t *data = engine->data;
/*     cvodeSettings_t *opt = engine->opt; */
/*     cvodeResults_t *results = engine->results; */
    odeModel_t *om = engine->om;
    
    /* !!!! calling CVODE !!!! */
    flag = -1; /* IDASolver(solver->cvode_mem, solver->tout, &(solver->t),
		  solver->y, solver->dy, IDA_NORMAL); */

    if ( flag != IDA_SUCCESS )
      {
        static const char *message[] =
	  {
	    /*  0 IDA_SUCCESS */
	    "Success",
	    /**/
	    /*  1 IDA_ROOT_RETURN */
	    /*   "CVode succeeded, and found one or more roots" */
	    /*  2 IDA_TSTOP_RETURN */
	    /*   "CVode succeeded and returned at tstop" */
	    /**/
	    /* -1 IDA_MEM_NULL -1 (old CVODE_NO_MEM) */
	    "The cvode_mem argument was NULL",
	    /* -2 IDA_ILL_INPUT */
	    "One of the inputs to CVode is illegal. This "
	    "includes the situation when a component of the "
	    "error weight vectors becomes < 0 during "
	    "internal time-stepping. The ILL_INPUT flag "
	    "will also be returned if the linear solver "
	    "routine CV--- (called by the user after "
	    "calling CVodeMalloc) failed to set one of the "
	    "linear solver-related fields in cvode_mem or "
	    "if the linear solver's init routine failed. In "
	    "any case, the user should see the printed "
	    "error message for more details.",
	    /* -3 IDA_NO_MALLOC */
	    "cvode_mem was not allocated",
	    /* -4 IDA_TOO_MUCH_WORK */
	    "The solver took %g internal steps but could not "
	    "compute variable values for time %g",
	    /* -5 IDA_TOO_MUCH_ACC */
	    "The solver could not satisfy the accuracy " 
	    "requested for some internal step.",
	    /* -6 IDA_ERR_FAILURE */
	    "Error test failures occurred too many times "
	    "during one internal time step or "
	    "occurred with |h| = hmin.",
	    /* -7 IDA_CONV_FAILURE */
	    "Convergence test failures occurred too many "
	    "times during one internal time step or occurred "
	    "with |h| = hmin.",
	    /* -8 IDA_LINIT_FAIL */
	    "CVode -- Initial Setup: "
	    "The linear solver's init routine failed.",
	    /* -9 IDA_LSETUP_FAIL */
	    "The linear solver's setup routine failed in an "
	    "unrecoverable manner.",
	    /* -10 IDA_LSOLVE_FAIL */
	    "The linear solver's solve routine failed in an "
	    "unrecoverable manner.",
	    /* -11 IDA_MEM_FAIL */
	    "A memory allocation failed. "
	    "(including an attempt to increase maxord)",
	    /* -12 IDA_RTFUNC_NULL */
	    "nrtfn > 0 but g = NULL.",
	    /* -13 IDA_NO_SLDET */
	    "CVodeGetNumStabLimOrderReds -- Illegal attempt "
	    "to call without enabling SLDET.",
	    /* -14 IDA_BAD_K */
	    "CVodeGetDky -- Illegal value for k.",
	    /* -15 IDA_BAD_T */
	    "CVodeGetDky -- Illegal value for t.",
	    /* -16 IDA_BAD_DKY */
	    "CVodeGetDky -- dky = NULL illegal.",
	    /* -17 IDA_PDATA_NULL */
	    "???",
	  };
	    
	SolverError_error(
			  ERROR_ERROR_TYPE,
			  flag,
			  (abs(flag) < (int)NUMBER_OF_ELEMENTS(message)) ? message[abs(flag)] : "???",
			  solver->tout);
	SolverError_error(
			  WARNING_ERROR_TYPE,
			  SOLVER_ERROR_INTEGRATION_NOT_SUCCESSFUL,
			  "Integration not successful. Results are not complete.");

	return 0 ; /* Error - stop integration*/
      }
    
    ydata = NV_DATA_S(solver->y);

    
    /* update cvodeData time dependent variables */    
    for ( i=0; i<om->neq; i++ )
      data->value[i] = ydata[i];

    /* update rest of data with internal default function */
    return IntegratorInstance_updateData(engine);

}