diff --git a/feos-core/CHANGELOG.md b/feos-core/CHANGELOG.md index 0c7542f8a..c5bb22e25 100644 --- a/feos-core/CHANGELOG.md +++ b/feos-core/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Added comparison for pressures of both phases in `PyPhaseDiagram.to_dict` to make the method work with `spinodal` constructor. [#224](https://github.com/feos-org/feos/pull/224) +- Enforce the total moles when providing `State::new` with molefracs that do not add up to 1. [#227](https://github.com/feos-org/feos/pull/227) ## [0.6.1] 2024-01-11 diff --git a/feos-core/src/state/mod.rs b/feos-core/src/state/mod.rs index ef8994564..e853b0d44 100644 --- a/feos-core/src/state/mod.rs +++ b/feos-core/src/state/mod.rs @@ -383,7 +383,7 @@ impl State { if let (None, None) = (volume, n) { n = Some(Moles::from_reduced(1.0)) } - let n_i = n.map(|n| &x_u * n); + let n_i = n.map(|n| &x_u * n / x_u.sum()); let v = volume.or_else(|| rho.and_then(|d| n.map(|n| n / d))); // check if new state can be created using default constructor