Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce total_moles when providing molefracs that do not add up to 1 #227

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions feos-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion feos-core/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl<E: Residual> State<E> {
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
Expand Down
Loading