1235 |
Make the call to the actual integrator we've selected, for the range of |
Make the call to the actual integrator we've selected, for the range of |
1236 |
time values specified. The sys contains all the specifics. |
time values specified. The sys contains all the specifics. |
1237 |
|
|
1238 |
Return 1 on success |
Return 0 on success |
1239 |
*/ |
*/ |
1240 |
int integrator_solve(IntegratorSystem *sys, long i0, long i1){ |
int integrator_solve(IntegratorSystem *sys, long i0, long i1){ |
1241 |
|
|
1250 |
/* check for at least 2 steps and dimensionality of x vs steps here */ |
/* check for at least 2 steps and dimensionality of x vs steps here */ |
1251 |
|
|
1252 |
if (i0<0 || i1 <0) { |
if (i0<0 || i1 <0) { |
1253 |
/* dude, there's no way we're writing interactive stuff here... */ |
/* removed completely inappropriate interactive code here */ |
1254 |
ERROR_REPORTER_HERE(ASC_PROG_ERROR,"Console input of integration limits has been disabled!"); |
ERROR_REPORTER_HERE(ASC_PROG_ERROR,"Console input of integration limits has been disabled!"); |
1255 |
return 0; |
return -1; |
1256 |
} else { |
} else { |
1257 |
start_index=i0; |
start_index=i0; |
1258 |
finish_index =i1; |
finish_index =i1; |
1260 |
ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"Start point (=%lu) must be an index in the range [0,%li]." |
ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"Start point (=%lu) must be an index in the range [0,%li]." |
1261 |
,start_index,nstep |
,start_index,nstep |
1262 |
); |
); |
1263 |
return 0; |
return -2; |
1264 |
} |
} |
1265 |
if (finish_index > (unsigned long)nstep) { |
if (finish_index > (unsigned long)nstep) { |
1266 |
ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"End point (=%lu) must be an index in the range [0,%li]." |
ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"End point (=%lu) must be an index in the range [0,%li]." |
1267 |
,finish_index,nstep |
,finish_index,nstep |
1268 |
); |
); |
1269 |
return 0; |
return -3; |
1270 |
} |
} |
1271 |
} |
} |
1272 |
|
|
1274 |
ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"End point comes before start point! (start=%lu, end=%lu)" |
ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"End point comes before start point! (start=%lu, end=%lu)" |
1275 |
,start_index,finish_index |
,start_index,finish_index |
1276 |
); |
); |
1277 |
return 0; |
return -4; |
1278 |
} |
} |
1279 |
|
|
1280 |
CONSOLE_DEBUG("RUNNING INTEGRATION..."); |
CONSOLE_DEBUG("RUNNING INTEGRATION..."); |
1625 |
|
|
1626 |
/** |
/** |
1627 |
Decode status codes from the integrator, and output them via FPRINTF. |
Decode status codes from the integrator, and output them via FPRINTF. |
1628 |
|
|
1629 |
|
@return 0 on status ok (converged), <0 on unrecognised state, >0 on recognised error state. |
1630 |
*/ |
*/ |
1631 |
int integrator_checkstatus(slv_status_t status) { |
int integrator_checkstatus(slv_status_t status) { |
1632 |
if (status.converged) { |
if(status.converged){ |
1633 |
return 1; |
return 0; |
1634 |
} |
} |
1635 |
if (status.diverged) { |
|
1636 |
FPRINTF(stderr, "The derivative system did not converge. Integration will terminate."); |
if(status.diverged){ |
1637 |
return 0; |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"The derivative system did not converge." |
1638 |
} |
" Integration will terminate."); return 1; |
1639 |
if (status.inconsistent) { |
}else if(status.inconsistent){ |
1640 |
FPRINTF(stderr, "A numerically inconsistent state was discovered while " |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"A numerically inconsistent state was discovered while" |
1641 |
"calculating derivatives. Integration will terminate."); |
" calculating derivatives. Integration will terminate."); return 1; |
1642 |
return 0; |
}else if(status.time_limit_exceeded){ |
1643 |
} |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"The time limit was exceeded while calculating" |
1644 |
if (status.time_limit_exceeded) { |
" derivatives. Integration will terminate."); return 1; |
1645 |
FPRINTF(stderr, "The time limit was exceeded while calculating " |
}else if(status.iteration_limit_exceeded){ |
1646 |
"derivatives. Integration will terminate."); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"The iteration limit was exceeded while calculating" |
1647 |
return 0; |
" derivatives. Integration will terminate."); return 1; |
1648 |
} |
}else if(status.panic){ |
1649 |
if (status.iteration_limit_exceeded) { |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"Integration cancelled by user."); return 1; |
1650 |
FPRINTF(stderr, "The iteration limit was exceeded while calculating " |
} |
1651 |
"derivatives. Integration will terminate."); |
|
1652 |
return 0; |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"Unrecognised solver state (non converged)"); |
1653 |
} |
return -1; |
|
if (status.panic) { |
|
|
FPRINTF(stderr, "The user patience limit was exceeded while " |
|
|
"calculating derivatives. Integration will terminate."); |
|
|
return 0; |
|
|
} |
|
|
return 0; |
|
1654 |
} |
} |