int main (int argc, char *argv[]){ int i, j; char *model; double time; double printstep; /* libSBML types */ SBMLDocument_t *d; SBMLReader_t *sr; Model_t *m; /* SOSlib types */ SBMLResults_t *results; timeCourse_t *tc; cvodeSettings_t *set; /* parsing command-line arguments */ if (argc < 4 ) { fprintf(stderr, "usage %s sbml-model-file simulation-time time-steps\n", argv[0]); exit(EXIT_FAILURE); } model = argv[1]; time = atof(argv[2]); printstep = atoi(argv[3]); /* parsing the SBML model with libSBML */ sr = SBMLReader_create(); d = SBMLReader_readSBML(sr, model); SBMLReader_free(sr); /* Setting SBML ODE Solver integration parameters */ set = CvodeSettings_create(); CvodeSettings_setTime(set, time, printstep); CvodeSettings_setErrors(set, 1e-9, 1e-4, 1000); /* calling the SBML ODE Solver which returns SBMLResults */ results = SBML_odeSolver(d, set); if ( SolverError_getNum(FATAL_ERROR_TYPE) ) { printf("Integration not sucessful!\n"); SolverError_dumpAndClearErrors(); return(EXIT_FAILURE); } /* now we have the results and can free the inputs */ CvodeSettings_free(set); SBMLDocument_free(d); /* print results */ printf("### RESULTS \n"); SBMLResults_dump(results); SolverError_dumpAndClearErrors(); /* now we can also free the result structure */ SBMLResults_free(results); return (EXIT_SUCCESS); }
int main (int argc, char *argv[]){ int i; char *model; /* libSBML types */ SBMLDocument_t *d; SBMLReader_t *sr; /* SOSlib types */ SBMLResults_t *results; cvodeSettings_t *set; double printstep; double endtime; /* parsing command-line arguments */ if (argc < 2 ) { fprintf(stderr, "usage %s sbml-model-file\n", argv[0]); exit(EXIT_FAILURE); } model = argv[1]; /* parsing the SBML model with libSBML */ sr = SBMLReader_create(); d = SBMLReader_readSBML(sr, model); SBMLReader_free(sr); /* Setting SBML ODE Solver integration parameters */ set = CvodeSettings_create(); /* setting endtime to 25 and printstep number to 6 */ printstep = 6; endtime = 25; CvodeSettings_setTime(set, endtime, printstep); /* writing predefined output times: IMPORTANT: can not exceed the set printstep number !! and first time must equal 0 !! */ CvodeSettings_setTimeStep(set, 1, 0.5); for ( i=2; i<=CvodeSettings_getPrintsteps(set); i++ ) CvodeSettings_setTimeStep(set, i, (i-1)*(i-1)); /* printing integration settings */ /* CvodeSettings_dump(set); */ /* calling the SBML ODE Solver, and retrieving SBMLResults */ results = SBML_odeSolver(d, set); CvodeSettings_free(set); SBMLDocument_free(d); if ( results == NULL ) { printf("Integration not sucessful!\n"); return (EXIT_FAILURE); } /* printing results only for species*/ SBMLResults_dumpSpecies(results); /* now we can also free the result structure */ SBMLResults_free(results); return (EXIT_SUCCESS); }