Skip to content

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

Merged
prehner merged 3 commits into
mainfrom
state_new_fix
Feb 27, 2024
Merged

prehner merged 3 commits into
mainfrom
state_new_fix

Conversation

@prehner

@prehner prehner commented Feb 27, 2024 •

Copy link
Copy Markdown
Contributor
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
@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