diff --git a/src/rdata.cpp b/src/rdata.cpp index 18973e7b79..eee763a860 100644 --- a/src/rdata.cpp +++ b/src/rdata.cpp @@ -113,16 +113,16 @@ void ReturnData::invalidate(const realtype t) { for (int it = it_start; it < nt; it++){ for (int ix = 0; ix < nx; ix++) - x.at(ix * nt + it) = getNaN(); + x.at(ix + nx * it) = getNaN(); for (int iy = 0; iy < ny; iy++) - y.at(iy * nt + it) = getNaN(); + y.at(iy + ny * it) = getNaN(); } if (sx.size()) { for (int it = it_start; it < nt; it++){ for (int ip = 0; ip < nplist; ip++) { for (int ix = 0; ix < nx; ix++) - sx.at((ip*nx + ix) * nt + it) = getNaN(); + sx.at(ix + nx*(ip + it*nplist)) = getNaN(); } } } @@ -130,7 +130,7 @@ void ReturnData::invalidate(const realtype t) { for (int it = it_start; it < nt; it++){ for (int ip = 0; ip < nplist; ip++) { for (int iy = 0; iy < ny; iy++) - sy.at((ip*ny + iy) * nt + it) = getNaN(); + sy.at(iy + ny*(ip + it*nplist)) = getNaN(); } } } @@ -200,23 +200,20 @@ void ReturnData::applyChainRuleFactorToSimulationResults(const Model *model) { for (int ip = 0; ip < nplist; ++ip) for (int ix = 0; ix < nxtrue; ++ix) for (int it = 0; it < nt; ++it) - sx.at((ip * nxtrue + ix) * nt + it) = - x.at((nxtrue + ip * nxtrue + ix) * nt + - it); + sx.at(ix + nxtrue*(ip + it*nplist)) = + x.at(it * nx + nxtrue + ip * nxtrue + ix); for (int ip = 0; ip < nplist; ++ip) for (int iy = 0; iy < nytrue; ++iy) for (int it = 0; it < nt; ++it) - sy.at((ip * nytrue + iy) * nt + it) = - y.at((nytrue + ip * nytrue + iy) * nt + - it); + sy.at(iy + nytrue*(ip + it*nplist)) = + y.at(it * ny + nytrue + ip * nytrue + iy); for (int ip = 0; ip < nplist; ++ip) for (int iz = 0; iz < nztrue; ++iz) for (int it = 0; it < nt; ++it) - sz.at((ip * nztrue + iz) * nt + it) = - z.at((nztrue + ip * nztrue + iz) * nt + - it); + sz.at(iz + nztrue*(ip + it*nplist)) = + z.at(it * nz + nztrue + ip * nztrue + iz); } } diff --git a/src/solver.cpp b/src/solver.cpp index ff7f689588..3f46430b29 100644 --- a/src/solver.cpp +++ b/src/solver.cpp @@ -71,9 +71,10 @@ void Solver::setupAMI(ForwardProblem *fwd, Model *model) { model->fsdx0(); - if (sensi_meth == AMICI_SENSI_FSA) { + auto plist = model->getParameterList(); + + if (sensi_meth == AMICI_SENSI_FSA && plist.size() > 0) { /* Set sensitivity analysis optional inputs */ - auto plist = model->getParameterList(); auto par = model->getUnscaledParameters(); /* Activate sensitivity calculations */ diff --git a/tests/cpputest/expectedResults.h5 b/tests/cpputest/expectedResults.h5 index 3407e76f41..113769d3d8 100644 Binary files a/tests/cpputest/expectedResults.h5 and b/tests/cpputest/expectedResults.h5 differ diff --git a/tests/cpputest/testfunctions.cpp b/tests/cpputest/testfunctions.cpp index fa59183d2e..d3d60b2096 100644 --- a/tests/cpputest/testfunctions.cpp +++ b/tests/cpputest/testfunctions.cpp @@ -42,8 +42,7 @@ void simulateVerifyWrite(const std::string hdffileOptions, const std::string hdf // simulate & verify auto rdata = runAmiciSimulation(*solver, edata.get(), *model); std::string resultPath = path + "/results"; - verifyReturnData(hdffileResults.c_str(), resultPath.c_str(), rdata.get(), model.get(), atol, rtol); - + // write // delete destination group H5::H5File in(hdffileOptions, H5F_ACC_RDONLY); @@ -61,6 +60,7 @@ void simulateVerifyWrite(const std::string hdffileOptions, const std::string hdf hdf5::writeReturnData(*rdata, out, writePath); // verify + verifyReturnData(hdffileResults.c_str(), resultPath.c_str(), rdata.get(), model.get(), atol, rtol); verifyReturnData(hdffilewrite, writePath, rdata.get(), model.get(), atol, rtol); //remove(hdffilewrite.c_str()); }