Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
basically we have a
Solvers.log
that works likeNaNMath.log
for Base Floats and Ints, but allows using other number types.we also fail earlier. in
eos
if a negative volume or temperature is passed, it will returnNaN
inmediately.For some bizarre reason i couldnt reproduce the failings on
system = BACKSAFT(["decane"])
, but with some investigation, i found that our initial conditions were not good enough. the new algorithm uses some sort of corresponding states theory to transform a(V0,P0,T,B(T))
into(a,b (van der Vals)
. with a and b we actually calculate aTc
andPc
, and those are used to calculatev_liquid
andv_vapor
according to 0.1007/s10910-007-9272-4 The van der Waals equation: Analytical and approximate solutionsThanks to those Pc and Tc, we can also "know" in what temperature regime we are. so we can give different results for near critical T, moderate T and very low T. all those at almost the same cost at the initial
x0_sat_pure
(1 virial coefficient and 1 liquid volume at P = Pvirial(-2B).We could use any Cubic EoS for this, but VdW is chosen because with
a
we could obtainTc
(it doesnt depend of more parameters, we could also use RK for this) and there is paper for aproximate solutions at saturation conditions (here we could use another EoS initial points. for example, PropaneRef providesv_liquid
andv_vapor
for a givenTr
.On the practical side, this improves greatly
sat_pure
at absolute low temperatures (triple point and below) and improves a bit near the critical point. also improves the results way over the critical point by failing earlier and skipping the first saturation calculationFor example, with the new initial points this converges:
at the moment, i deactivated the SPUNG tests, as i plan to fix that later