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.
Description of the Change
Providing inputs to CoolProp of D and U (or any of HSU) is usually stable, but sometimes can cause annoying issues. This is noted in issues #1965 and #2157 (as well as some of my personal projects). This PR attempts to solve these issues once and for all as an extension to the work done in PR #2173. This is done in 3 main changes:
Benefits
We should now always get a solution for D_HSU inputs.
Possible Drawbacks
It is possible that one of our fallbacks does not provide the user with a phase, instead setting it to iphase_unknown.
The fallback solver can be slow because of needing a ton of Brent iterations, after already doing thousands of other iterations trying to find the saturation curve (which is now allowed to go to many of thousands of evaluations). However, a slow solution is almost always better than no solution.
Verification Process
I ran large sweeps of inputs to ensure that no errors were observed. I also integrated the results with another code and it seems to behave acceptably. I made custom test codes for issues #1965 and #2157. See the attached C++ code.
coolPropTester.zip
Applicable Issues
Closes #1965
Closes #2157