feos-org / feos

FeOs - A Framework for Equations of State and Classical Density Functional Theory
Other
116 stars 23 forks source link

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

Closed prehner closed 7 months ago

prehner commented 7 months ago
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.