1use crate::parameter::ParameterError;
2use num_dual::linalg::LinAlgError;
3use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum EosError {
8 #[error("{0}")]
9 Error(String),
10 #[error("`{0}` did not converge within the maximum number of iterations.")]
11 NotConverged(String),
12 #[error("`{0}` encountered illegal values during the iteration.")]
13 IterationFailed(String),
14 #[error("Iteration resulted in trivial solution.")]
15 TrivialSolution,
16 #[error("Equation of state is initialized for {0} components while the input specifies {1} components.")]
17 IncompatibleComponents(usize, usize),
18 #[error("Invalid state in {0}: {1} = {2}.")]
19 InvalidState(String, String, f64),
20 #[error("Undetermined state: {0}.")]
21 UndeterminedState(String),
22 #[error("System is supercritical.")]
23 SuperCritical,
24 #[error("No phase split according to stability analysis.")]
25 NoPhaseSplit,
26 #[error("Wrong input units. Expected {0}, got {1}")]
27 WrongUnits(String, String),
28 #[error(transparent)]
29 ParameterError(#[from] ParameterError),
30 #[error(transparent)]
31 LinAlgError(#[from] LinAlgError),
32 #[cfg(feature = "rayon")]
33 #[error(transparent)]
34 RayonError(#[from] rayon::ThreadPoolBuildError),
35}
36
37pub type EosResult<T> = Result<T, EosError>;