[Reactor] Fix segfault when requesting sensitivities at t = 0
This commit is contained in:
parent
7447c5957d
commit
cf0a418027
3 changed files with 10 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue