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

Asymmetric BIPs #1967

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Asymmetric BIPs #1967

wants to merge 1 commit into from

Conversation

alex-s-v
Copy link
Contributor

Description of the Change

Some new mixing rules require the matrix of binary interaction parameters (BIPs) to be asymmetric, so I have done my best to add such functionality. Methods set_binary_interaction_double were overwritten to accept an additional (optional) parameter which specifies whether to set Kij symmetrically or not (symmetrically by default).

Benefits

Now you can specify the matrix of BIPs asymmetrically.

Possible Drawbacks

Adds new ways to inexperienced users to ruin their calculations =D

Verification Process

The following python script shows the use and effect of the introduced changes.

import CoolProp.CoolProp as CP

AS = CP.AbstractState("PR", "benzene&toluene")
AS.set_binary_interaction_double(0, 1, "kij", 0.05)  # symmetrically
k01 = AS.get_binary_interaction_double(0, 1, "kij")
k10 = AS.get_binary_interaction_double(1, 0, "kij")
print(f"k01 = {k01}; k10 = {k10}")
# Output: k01 = 0.05; k10 = 0.05
AS.set_mole_fractions([0.3, 0.7])
AS.update(CP.PQ_INPUTS, 101325, 0)
ys = AS.mole_fractions_vapor()
print(ys)
# Output: [0.5042805536100579, 0.49571944638994214]

AS.set_binary_interaction_double(0, 1, "kij", 0.1, False)  # asymmetrically
k01 = AS.get_binary_interaction_double(0, 1, "kij")
k10 = AS.get_binary_interaction_double(1, 0, "kij")
print(f"k01 = {k01}; k10 = {k10}")
# Output: k01 = 0.1; k10 = 0.05
AS.update(CP.PQ_INPUTS, 101325, 0)
ys = AS.mole_fractions_vapor()
print(ys)
# Output: [0.5050982763042872, 0.49490172369571284]

Applicable Issues

My own old issue #1890

@ibell
Copy link
Contributor

ibell commented Sep 25, 2020

I have a new idea: what if rather than adding a new argument, you could add :asymmetric (or something similar) to the key, so the API could be identical, but the same effect could be realized? Boolean arguments are always challenging to document because I see a True in the code, and it is not clear what is going on there. My proposal should propagate to the linked states for VLE, for instance, and I'm not sure that would necessarily work with what you have implemented.

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.

None yet

2 participants