ida/
error.rs

1use failure::Fail;
2
3#[derive(Debug)]
4pub enum Recoverable {
5    /// IDA_RES_RECVR
6    Residual,
7    /// IDA_LSETUP_RECVR
8    LSetup,
9    /// IDA_LSOLVE_RECVR
10    LSolve,
11    /// IDA_CONSTR_RECVR
12    Constraint,
13    /// IDA_NLS_SETUP_RECVR
14    NLSSetup,
15}
16
17#[derive(Debug, Fail)]
18pub enum IdaError {
19    // ERROR_TEST_FAIL
20    #[fail(display = "Error Test Failed")]
21    TestFail,
22
23    // LSETUP_ERROR_NONRECVR
24    // IDA_ERR_FAIL
25    /// IDA_REP_RES_ERR:
26    #[fail(
27        display = "The user's residual function repeatedly returned a recoverable error flag, \
28                   but the solver was unable to recover"
29    )]
30    RepeatedResidualError {},
31
32    /// IDA_ILL_INPUT
33    #[fail(display = "One of the input arguments was illegal. See printed message")]
34    IllegalInput { msg: String },
35
36    /// IDA_LINIT_FAIL
37    #[fail(display = "The linear solver's init routine failed")]
38    LinearInitFail {},
39
40    /// IDA_BAD_EWT
41    #[fail(
42        display = "Some component of the error weight vector is zero (illegal), either for the \
43                   input value of y0 or a corrected value"
44    )]
45    BadErrorWeightVector {},
46
47    /// IDA_RES_FAIL
48    #[fail(display = "The user's residual routine returned a non-recoverable error flag")]
49    ResidualFail {},
50
51    /// IDA_FIRST_RES_FAIL
52    #[fail(
53        display = "The user's residual routine returned a recoverable error flag on the first \
54                   call, but IDACalcIC was unable to recover"
55    )]
56    FirstResidualFail {},
57
58    /// IDA_LSETUP_FAIL
59    #[fail(display = "The linear solver's setup routine had a non-recoverable error")]
60    LinearSetupFail {},
61
62    /// IDA_LSOLVE_FAIL
63    #[fail(display = "The linear solver's solve routine had a non-recoverable error")]
64    LinearSolveFail {},
65
66    /// IDA_NO_RECOVERY
67    #[fail(
68        display = "The user's residual routine, or the linear solver's setup or solve routine \
69                   had a recoverable error, but IDACalcIC was unable to recover"
70    )]
71    NoRecovery {},
72
73    #[fail(display = "Recoverable failure")]
74    RecoverableFail { rec_type: Recoverable },
75
76    /// IDA_CONSTR_FAIL
77    /// The inequality constraints were violated, and the solver was unable to recover.
78    #[fail(
79        display = "IDACalcIC was unable to find a solution satisfying the inequality constraints"
80    )]
81    ConstraintFail {},
82
83    /// IDA_LINESEARCH_FAIL
84    #[fail(
85        display = "The Linesearch algorithm failed to find a solution with a step larger than \
86                   steptol in weighted RMS norm"
87    )]
88    LinesearchFail {},
89
90    /// IDA_CONV_FAIL
91    #[fail(display = "IDACalcIC failed to get convergence of the Newton iterations")]
92    ConvergenceFail {},
93
94    ///MSG_BAD_K
95    #[fail(display = "Illegal value for k.")]
96    BadK {},
97
98    //MSG_NULL_DKY       "dky = NULL illegal."
99    ///MSG_BAD_T
100    #[fail(
101        display = "Illegal value for t: t = {} is not between tcur - hu = {} and tcur = {}.",
102        t, tdiff, tcurr
103    )]
104    BadTimeValue { t: f64, tdiff: f64, tcurr: f64 },
105
106    #[fail(
107        display = "At t = {}, the rootfinding routine failed in an unrecoverable manner.",
108        t
109    )]
110    RootFunctionFail { t: f64 },
111
112    ///MSG_BAD_TSTOP
113    #[fail(
114        display = "The value tstop = {} is behind current t = {} in the direction of integration.",
115        tstop, t
116    )]
117    BadStopTime { tstop: f64, t: f64 },
118
119    ///MSG_TOO_MUCH_ACC
120    #[fail(display = "At t = {} too much accuracy requested.", t)]
121    TooMuchAccuracy { t: f64 },
122
123    ///MSG_CLOSE_ROOTS
124    #[fail(display = "Root found at and very near {}.", t)]
125    CloseRoots { t: f64 },
126}