Skip to content

Commit 3514c2f

Browse files
authored
Early return if vapor pressure data set is empty (#124)
* early return if vapor pressure data set is empty * add missing import
1 parent 2e8de3c commit 3514c2f

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626

2727
### Fixed
2828
- Fixed incorrect indexing that lead to panics in the polar contribution of gc-PC-SAFT. [#104](https://github.com/feos-org/feos/pull/104)
29+
- `VaporPressure` now returns an empty array instead of crashing. [#124](https://github.com/feos-org/feos/pull/124)
2930

3031
## [0.3.0] - 2022-09-14
3132
- Major restructuring of the entire `feos` project. All individual models are reunited in the `feos` crate. `feos-core` and `feos-dft` still live as individual crates within the `feos` workspace.

src/estimator/vapor_pressure.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{DataSet, EstimatorError};
22
use feos_core::{Contributions, EosUnit, EquationOfState, PhaseEquilibrium, SolverOptions, State};
3-
use ndarray::Array1;
3+
use ndarray::{arr1, Array1};
44
use quantity::si::{SIArray1, SINumber, SIUnit};
55
use std::collections::HashMap;
66
use std::sync::Arc;
@@ -71,6 +71,10 @@ impl<E: EquationOfState> DataSet<E> for VaporPressure {
7171
}
7272

7373
fn predict(&self, eos: &Arc<E>) -> Result<SIArray1, EstimatorError> {
74+
if self.datapoints == 0 {
75+
return Ok(arr1(&[]) * SIUnit::reference_pressure());
76+
}
77+
7478
let critical_point =
7579
State::critical_point(eos, None, Some(self.max_temperature), self.solver_options)
7680
.or_else(|_| State::critical_point(eos, None, None, self.solver_options))?;

0 commit comments

Comments
 (0)