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

Conversation

prehner
Copy link
Contributor

@prehner prehner commented Feb 27, 2024

State(eos, 300*KELVIN, molefracs=np.array([1.5,3.5]), total_moles=10*MOL, pressure=BAR).moles

would previously evaluate to

[15, 35] MOL

with this change the output is

[3, 7] MOL

which conforms with the total moles provided by the call to State::new. In any case, this is only an issue, if the molefracs do not add up to 1. A different approach would be to return an Error if this condition is not met, however, I'm not much in favor of adding an == 1.0 check due to the implications on floating point arithmetic.

@prehner prehner requested a review from g-bauer February 27, 2024 13:13
@prehner prehner merged commit 742606e into main Feb 27, 2024
14 checks passed
@prehner prehner deleted the state_new_fix branch February 27, 2024 16:21
@prehner prehner added this to the v0.7.0 milestone Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants