[Reactor] Fix segfault when requesting sensitivities at t = 0

This commit is contained in:
Ray Speth 2013-09-01 00:33:19 +00:00
parent 7447c5957d
commit cf0a418027
3 changed files with 10 additions and 0 deletions

View file

@ -146,6 +146,9 @@ public:
//! Return the sensitivity of the *k*-th solution component with
//! respect to the *p*-th sensitivity parameter.
double sensitivity(size_t k, size_t p) {
if (!m_init) {
initialize();
}
return m_integ->sensitivity(k, m_sensIndex[p])/m_integ->solution(k);
}

View file

@ -508,6 +508,10 @@ int CVodesIntegrator::nEvals() const
double CVodesIntegrator::sensitivity(size_t k, size_t p)
{
if (m_time == m_t0) {
// calls to CVodeGetSens are only allowed after a successful time step.
return 0.0;
}
if (!m_sens_ok && m_np) {
#if SUNDIALS_VERSION <= 23
int flag = CVodeGetSens(m_cvode_mem, m_time, m_yS);

View file

@ -256,6 +256,9 @@ void ReactorNet::getInitialConditions(doublereal t0,
size_t ReactorNet::globalComponentIndex(const string& species, size_t reactor)
{
if (!m_init) {
initialize();
}
size_t start = 0;
size_t n;
for (n = 0; n < reactor; n++) {