Skip to content

Commit

Permalink
Enforce total_moles when providing molefracs that do not add up to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
prehner committed Feb 27, 2024
1 parent 150568d commit 05570c6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 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 All @@ -392,6 +392,7 @@ impl<E: Residual> State<E> {
}

// Check if new state can be created using density iteration
println!("{:?} {:?} {:?}", pressure, temperature, n_i);
if let (Some(p), Some(t), Some(n_i)) = (pressure, temperature, &n_i) {
return Ok(Ok(State::new_npt(eos, t, p, n_i, density_initialization)?));
}
Expand Down

0 comments on commit 05570c6

Please sign in to comment.