SBML_ODESOLVER_API int IntegratorInstance_set(integratorInstance_t *engine, cvodeSettings_t *opt) { CvodeData_initialize(engine->data, opt, engine->om); RETURN_ON_FATALS_WITH(0); return IntegratorInstance_initializeSolver(engine, engine->data, opt, engine->om); }
SBML_ODESOLVER_API integratorInstance_t *IntegratorInstance_create(odeModel_t *om, cvodeSettings_t *opt) { cvodeData_t *data; integratorInstance_t *engine; data = CvodeData_create(om); RETURN_ON_FATALS_WITH(NULL); CvodeData_initialize(data, opt, om); RETURN_ON_FATALS_WITH(NULL); return IntegratorInstance_allocate(data, opt, om); }
void interactive() { char *sbmlFilename; char *select; int quit; SBMLDocument_t *d = NULL; Model_t *m = NULL; odeModel_t *om = NULL; cvodeData_t * data = NULL; integratorInstance_t *ii = NULL; cvodeSettings_t *set = NULL; printf("\n\nWelcome to the simple SBML ODE solver.\n"); printf("You have entered the interactive mode.\n"); printf("All other commandline options have been ignored.\n"); printf("Have fun!\n\n"); initializeOptions(); /* reset steady state */ Opt.SteadyState = 0; /* activate printing of results to XMGrace */ Opt.Xmgrace = 1; /* activate printing integrator messages */ Opt.PrintMessage = 1; /* deactivate on the fly printing of results */ Opt.PrintOnTheFly = 0; sbmlFilename = concat(Opt.ModelPath, Opt.ModelFile); if ( (d = parseModelWithArguments(sbmlFilename)) == 0 ) { Warn(stderr, "%s:%d interactive(): Can't parse Model >%s<", __FILE__, __LINE__, sbmlFilename); d = loadFile(); } /* load models and default settings */ m = SBMLDocument_getModel(d); om = ODEModel_create(m); set = CvodeSettings_create(); SolverError_dumpAndClearErrors(); quit = 0; data = NULL; while ( quit == 0 ) { printf("\n"); printf("Press (h) for instructions or (q) to quit.\n"); printf("> "); select = get_line( stdin ); select = util_trim(select); printf("\n"); if( strcmp(select,"l") == 0 ) { /* free all existing structures */ if ( om != NULL ) ODEModel_free(data->model); if ( d != NULL ) SBMLDocument_free(d); if ( ii != NULL ) IntegratorInstance_free(ii); /* load a new file */ d = loadFile(); /* load new models */ m = SBMLDocument_getModel(d); om = ODEModel_create(m); SolverError_dumpAndClearErrors(); } if(strcmp(select,"h")==0) printMenu(); if(strcmp(select,"s")==0) printModel(m, stdout); if(strcmp(select,"c")==0) printSpecies(m, stdout); if(strcmp(select,"r")==0) printReactions(m, stdout); if(strcmp(select,"o")==0) printODEs(om, stdout); /* integrate interface functions, asks for time and printsteps */ if(strcmp(select,"i")==0){ ii = callIntegrator(om, set); SolverError_dumpAndClearErrors(); } if(strcmp(select,"x")==0){ if ( Opt.Xmgrace == 1 ) { Opt.Xmgrace = 0; printf(" Printing results to stdout\n"); } else if ( Opt.Xmgrace == 0 ) { Opt.Xmgrace = 1; printf(" Printing results to XMGrace\n"); } } if(strcmp(select,"st")==0) printConcentrationTimeCourse(ii->data, stdout); if(strcmp(select,"jt")==0) printJacobianTimeCourse(ii->data, stdout); if(strcmp(select,"ot")==0) printOdeTimeCourse(ii->data, stdout); if(strcmp(select,"rt")==0) printReactionTimeCourse(ii->data, m, stdout); if(strcmp(select,"xp")==0) printPhase(ii->data); if(strcmp(select,"set")==0) setValues(m); if(strcmp(select,"ss")==0){ if ( Opt.SteadyState == 1 ) { Opt.SteadyState = 0; printf(" Not checking for steady states during integration.\n"); } else if ( Opt.SteadyState == 0 ) { Opt.SteadyState = 1; printf(" Checking for steady states during integration.\n"); } } if(strcmp(select,"uj")==0){ if ( Opt.Jacobian == 1 ) { Opt.Jacobian = 0; printf(" Using CVODE's internal approximation\n"); printf(" of the jacobian matrix for integration\n"); } else if ( Opt.Jacobian == 0 ) { Opt.Jacobian = 1; printf(" Using automatically generated\n"); printf(" jacobian matrix for integration\n"); } } if(strcmp(select,"gf")==0) setFormat(); if(strcmp(select,"rg")==0) { drawModel(m, sbmlFilename, Opt.GvFormat); SolverError_dumpAndClearErrors(); } if(strcmp(select,"jg")==0){ if ( ii == NULL ) { data = CvodeData_create(om); CvodeData_initialize(data, set, om, 0); drawJacoby(data, sbmlFilename, Opt.GvFormat); SolverError_dumpAndClearErrors(); CvodeData_free(data); } else { drawJacoby(ii->data, sbmlFilename, Opt.GvFormat); SolverError_dumpAndClearErrors(); } } if(strcmp(select,"j")==0) { if ( om->jacob == NULL ) ODEModel_constructJacobian(om); printJacobian(om, stdout); } if(strcmp(select,"q")==0) quit = 1; } if ( ii != NULL ) IntegratorInstance_free(ii); if ( om != NULL ) ODEModel_free(om); SBMLDocument_free(d); SolverError_dumpAndClearErrors(); printf("\n\nGood Bye. Thx for using.\n\n"); }