Skip to content

Commit

Permalink
Add missing simulation status codes (#2560)
Browse files Browse the repository at this point in the history
Closes #2559.
  • Loading branch information
dweindl authored Oct 23, 2024
1 parent 638c3ee commit a20447a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 59 deletions.
6 changes: 6 additions & 0 deletions include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ constexpr int AMICI_CONSTR_FAIL= -15;
constexpr int AMICI_CVODES_CONSTR_FAIL= -15;
constexpr int AMICI_IDAS_CONSTR_FAIL= -11;
constexpr int AMICI_ILL_INPUT= -22;
constexpr int AMICI_BAD_T= -25;
constexpr int AMICI_BAD_DKY= -26;
constexpr int AMICI_FIRST_QRHSFUNC_ERR= -32;
constexpr int AMICI_SRHSFUNC_FAIL= -41;
constexpr int AMICI_FIRST_SRHSFUNC_ERR= -42;
constexpr int AMICI_REPTD_SRHSFUNC_ERR= -43;
constexpr int AMICI_UNREC_SRHSFUNC_ERR= -44;
constexpr int AMICI_ERROR= -99;
constexpr int AMICI_NO_STEADY_STATE= -81;
constexpr int AMICI_DAMPING_FACTOR_ERROR= -86;
Expand Down
6 changes: 6 additions & 0 deletions src/amici.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ std::map<int, std::string> simulation_status_to_str_map = {
{AMICI_LSETUP_FAIL, "AMICI_LSETUP_FAIL"},
{AMICI_FIRST_QRHSFUNC_ERR, "AMICI_FIRST_QRHSFUNC_ERR"},
{AMICI_WARNING, "AMICI_WARNING"},
{AMICI_BAD_T, "AMICI_BAD_T"},
{AMICI_BAD_DKY, "AMICI_BAD_DKY"},
{AMICI_FIRST_SRHSFUNC_ERR, "AMICI_FIRST_SRHSFUNC_ERR"},
{AMICI_SRHSFUNC_FAIL, "AMICI_SRHSFUNC_FAIL"},
{AMICI_REPTD_SRHSFUNC_ERR, "AMICI_REPTD_SRHSFUNC_ERR"},
{AMICI_UNREC_SRHSFUNC_ERR, "AMICI_UNREC_SRHSFUNC_ERR"},
};

std::unique_ptr<ReturnData> runAmiciSimulation(
Expand Down
83 changes: 24 additions & 59 deletions src/solver_cvodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,65 +34,30 @@ static_assert((int)InterpolationType::polynomial == CV_POLYNOMIAL, "");
static_assert((int)LinearMultistepMethod::adams == CV_ADAMS, "");
static_assert((int)LinearMultistepMethod::BDF == CV_BDF, "");

static_assert(AMICI_ROOT_RETURN == CV_ROOT_RETURN, "");

static_assert(
amici::AMICI_SUCCESS == CV_SUCCESS, "AMICI_SUCCESS != CV_SUCCESS"
);
static_assert(
amici::AMICI_DATA_RETURN == CV_TSTOP_RETURN,
"AMICI_DATA_RETURN != CV_TSTOP_RETURN"
);
static_assert(
amici::AMICI_ROOT_RETURN == CV_ROOT_RETURN,
"AMICI_ROOT_RETURN != CV_ROOT_RETURN"
);
static_assert(
amici::AMICI_ILL_INPUT == CV_ILL_INPUT, "AMICI_ILL_INPUT != CV_ILL_INPUT"
);
static_assert(amici::AMICI_NORMAL == CV_NORMAL, "AMICI_NORMAL != CV_NORMAL");
static_assert(
amici::AMICI_ONE_STEP == CV_ONE_STEP, "AMICI_ONE_STEP != CV_ONE_STEP"
);
static_assert(
amici::AMICI_TOO_MUCH_ACC == CV_TOO_MUCH_ACC,
"AMICI_TOO_MUCH_ACC != CV_TOO_MUCH_ACC"
);
static_assert(
amici::AMICI_TOO_MUCH_WORK == CV_TOO_MUCH_WORK,
"AMICI_TOO_MUCH_WORK != CV_TOO_MUCH_WORK"
);
static_assert(
amici::AMICI_ERR_FAILURE == CV_ERR_FAILURE,
"AMICI_ERR_FAILURE != CV_ERR_FAILURE"
);
static_assert(
amici::AMICI_CONV_FAILURE == CV_CONV_FAILURE,
"AMICI_CONV_FAILURE != CV_CONV_FAILURE"
);
static_assert(
amici::AMICI_LSETUP_FAIL == CV_LSETUP_FAIL,
"AMICI_LSETUP_FAIL != CV_LSETUP_FAIL"
);
static_assert(
amici::AMICI_CONSTR_FAIL == CV_CONSTR_FAIL,
"AMICI_CONSTR_FAIL != CV_CONSTR_FAIL"
);
static_assert(
amici::AMICI_RHSFUNC_FAIL == CV_RHSFUNC_FAIL,
"AMICI_RHSFUNC_FAIL != CV_RHSFUNC_FAIL"
);
static_assert(
amici::AMICI_FIRST_RHSFUNC_ERR == CV_FIRST_RHSFUNC_ERR,
"AMICI_FIRST_RHSFUNC_ERR != CV_FIRST_RHSFUNC_ERR"
);
static_assert(
amici::AMICI_FIRST_QRHSFUNC_ERR == CV_FIRST_QRHSFUNC_ERR,
"AMICI_FIRST_QRHSFUNC_ERR != CV_FIRST_QRHSFUNC_ERR"
);
static_assert(
amici::AMICI_WARNING == CV_WARNING, "AMICI_WARNING != CV_WARNING"
);
#define STATIC_ASSERT_EQUAL(amici_constant, cv_constant) \
static_assert(amici_constant == cv_constant, #amici_constant " != " #cv_constant)

STATIC_ASSERT_EQUAL(amici::AMICI_SUCCESS, CV_SUCCESS);
STATIC_ASSERT_EQUAL(amici::AMICI_ROOT_RETURN, CV_ROOT_RETURN);
STATIC_ASSERT_EQUAL(amici::AMICI_DATA_RETURN, CV_TSTOP_RETURN);
STATIC_ASSERT_EQUAL(amici::AMICI_ILL_INPUT, CV_ILL_INPUT);
STATIC_ASSERT_EQUAL(amici::AMICI_NORMAL, CV_NORMAL);
STATIC_ASSERT_EQUAL(amici::AMICI_ONE_STEP, CV_ONE_STEP);
STATIC_ASSERT_EQUAL(amici::AMICI_TOO_MUCH_ACC, CV_TOO_MUCH_ACC);
STATIC_ASSERT_EQUAL(amici::AMICI_TOO_MUCH_WORK, CV_TOO_MUCH_WORK);
STATIC_ASSERT_EQUAL(amici::AMICI_ERR_FAILURE, CV_ERR_FAILURE);
STATIC_ASSERT_EQUAL(amici::AMICI_CONV_FAILURE, CV_CONV_FAILURE);
STATIC_ASSERT_EQUAL(amici::AMICI_LSETUP_FAIL, CV_LSETUP_FAIL);
STATIC_ASSERT_EQUAL(amici::AMICI_CONSTR_FAIL, CV_CONSTR_FAIL);
STATIC_ASSERT_EQUAL(amici::AMICI_RHSFUNC_FAIL, CV_RHSFUNC_FAIL);
STATIC_ASSERT_EQUAL(amici::AMICI_FIRST_RHSFUNC_ERR, CV_FIRST_RHSFUNC_ERR);
STATIC_ASSERT_EQUAL(amici::AMICI_FIRST_QRHSFUNC_ERR, CV_FIRST_QRHSFUNC_ERR);
STATIC_ASSERT_EQUAL(amici::AMICI_BAD_T, CV_BAD_T);
STATIC_ASSERT_EQUAL(amici::AMICI_BAD_DKY, CV_BAD_DKY);
STATIC_ASSERT_EQUAL(amici::AMICI_SRHSFUNC_FAIL, CV_SRHSFUNC_FAIL);
STATIC_ASSERT_EQUAL(amici::AMICI_FIRST_SRHSFUNC_ERR, CV_FIRST_SRHSFUNC_ERR);
STATIC_ASSERT_EQUAL(amici::AMICI_REPTD_SRHSFUNC_ERR, CV_REPTD_SRHSFUNC_ERR);
STATIC_ASSERT_EQUAL(amici::AMICI_UNREC_SRHSFUNC_ERR, CV_UNREC_SRHSFUNC_ERR);

/*
* The following static members are callback function to CVODES.
Expand Down

0 comments on commit a20447a

Please sign in to comment.