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

PropsSImulti in Python #848

Closed
VAL333 opened this issue Oct 22, 2015 · 17 comments
Closed

PropsSImulti in Python #848

VAL333 opened this issue Oct 22, 2015 · 17 comments
Milestone

Comments

@VAL333
Copy link

VAL333 commented Oct 22, 2015

Hi @jowr,

The PropsSImulti seems increadibly useful and I would really need it for my project. However, I cannot use it in python and I believe the reason is that there is no wrapper to use it in python. Would it be possible (and relatively quick) to implement the wrapper so that PropsSImulti can be used in python?

Thank you very much.

@jowr
Copy link
Member

jowr commented Oct 22, 2015

Could you please specify which functionality your are missing? Is it the composition vector? I think that is the only part that is missing from this example:

import numpy as np
import CoolProp.CoolProp as CP
fluid = "HEOS::Water"
out_lst = ["H","S"]
in1_lst = np.array([150,220])+273.15
in2_lst = np.array([0.1,0.5])*1e5
CP.PropsSI(out_lst,"T",in1_lst,"P",in2_lst,fluid)

@VAL333
Copy link
Author

VAL333 commented Oct 22, 2015

Yes jowr, that is correct. The example given above doesn't specify the mole or mass fraction of each fluid. Also, can you use this functionality with gases?

@jowr
Copy link
Member

jowr commented Oct 22, 2015

Yes, the mole fraction does not work, but I think that @ibell might be able to quickly wrap PropSImulti for you.

What do you mean by gasses? Water for sure is in the gaseous state at 150 degrees Celsius at 0.1 bar.

@VAL333
Copy link
Author

VAL333 commented Oct 22, 2015

Oh, yes I didn't pay attention to the pressure and temperature in this example. That answer's my question about gases.

@ibell
Copy link
Contributor

ibell commented Oct 22, 2015

Also, you can use mixtures directly in the high-level interface already, by doing things like the following examples:
http://www.coolprop.org/coolprop/HighLevelAPI.html#calling-refprop
http://www.coolprop.org/coolprop/HighLevelAPI.html#c-sample-code

I acknowledge we could make the documentation clearer about how you use mixtures in CoolProp in the high-level interface.

@ibell
Copy link
Contributor

ibell commented Oct 22, 2015

Those examples obviously do not allow you to pass the compositions as a vector, rather the compositions (molar!) are encoded as a string. But if you really want speed, you want to be using the low-level interface: http://www.coolprop.org/coolprop/LowLevelAPI.html. That gives you power and speed, and access to some things you can't access in the high-level interface.

@VAL333
Copy link
Author

VAL333 commented Oct 22, 2015

Thank you ibell for the information. the high-level interface is much easier to understand and it works fine for my need. However, I can't get the mixture I want (Helium "He" and Xenon "Xe"). I know they work separately and I know Helium can work with other gases, but Xenon seems to not work in mixtures. Is this correct? There must be a chemistry reason why Xenon's properties are difficult to get in mixtures.

@ibell
Copy link
Contributor

ibell commented Oct 22, 2015

What error do you get? Probably we don't have interaction parameters for
this mixture, which is why Helium & Xenon don't work. In a few months we
should have interaction parameters for about another 700 binary pairs.

On Thu, Oct 22, 2015 at 4:59 PM, VAL333 notifications@github.com wrote:

Thank you ibell for the information. the high-level interface is much
easier to understand and it works fine for my need. However, I can't get
the mixture I want (Helium "He" and Xenon "Xe"). I know they work
separately and I know Helium can work with other gases, but Xenon seems to
not work in mixtures. Is this correct? There must be a chemistry reason why
Xenon's properties are difficult to get in mixtures.


Reply to this email directly or view it on GitHub
#848 (comment).

@VAL333
Copy link
Author

VAL333 commented Oct 22, 2015

I figured that was the issue. That is great that you "should have interaction parameters for about another 700 binary pairs"! CoolProp is surpassing RefProp! Here is the error I get:

ValueError: Initialize failed for backend: "?", fluid: "Xe&He" fractions "[ 0.2000000000, 0.8000000000 ]"; error: Could not match the binary pair [7440-59-7,7440-63-3] - for now this is an error. : PropsSI("D","T",300,"P",101325,"Xe[0.2]&He[0.8]")

@ibell
Copy link
Contributor

ibell commented Oct 22, 2015

Right, that means no interaction parameters for this mixture. I can guess that the interaction parameters should be very nearly 1, so if you were feeling adventureous, you could tell CoolProp to use a simple estimation scheme:

import CoolProp
CAS_He = CoolProp.CoolProp.get_fluid_param_string('Helium','CAS')
CAS_Xe = CoolProp.CoolProp.get_fluid_param_string('Xe','CAS')
CoolProp.CoolProp.apply_simple_mixing_rule(CAS_He, CAS_Xe, 'linear')
CoolProp.CoolProp.PropsSI('Dmass','T',300,'P',101325,'Helium[0.5]&Xenon[0.5]')

Use with caution!! For other mixtures this can give you entirely(!) wrong predictions

@VAL333
Copy link
Author

VAL333 commented Oct 22, 2015

Thank you!

@ibell
Copy link
Contributor

ibell commented Oct 22, 2015

By the way, do you still want the vector PropsSI function? Or would better docs be enough?

@VAL333
Copy link
Author

VAL333 commented Oct 22, 2015

Better docs would be enough:)

By the way, I cannot seam to access the apply_simple_mixing_rule. I get the error: AttributeError: 'module' object has no attribute 'apply_simple_mixing_rule'. But it's weird because if I use tab completion it does find the function...

@ibell
Copy link
Contributor

ibell commented Oct 22, 2015

Perhaps you have somehow an older version of CoolProp hiding on your
computer? I recommend you pip uninstall coolprop a few times, then run the
second command from here:

http://www.coolprop.dreamhosters.com/binaries/sphinx/coolprop/wrappers/Python/index.html#automatic-installation

You need the nightly version, the 5.1.1 release doesn't have the
apply_simple_mixing_rule function. It's high time for a new release of
CoolProp, but it takes a few hours and I just haven't gotten around to it.

On Thu, Oct 22, 2015 at 5:33 PM, VAL333 notifications@github.com wrote:

Better docs would be enough:)

By the way, I cannot seam to access the apply_simple_mixing_rule. I get
the error: AttributeError: 'module' object has no attribute
'apply_simple_mixing_rule'. But it's weird because if I use tab completion
it does find the function...


Reply to this email directly or view it on GitHub
#848 (comment).

@VAL333
Copy link
Author

VAL333 commented Oct 22, 2015

So, I still have the same error. When I print the CoolProp version, it says 5.1.0. Is that what it should say?

@ibell
Copy link
Contributor

ibell commented Oct 23, 2015

No, it should say 5.1.2dev. I have no idea how you have 5.1.0. Something funny is going on here...

Did you call "pip uninstall CoolProp" a few times at the command line? And then do the install I linked? Can you please provide the full log from the console?

@ibell
Copy link
Contributor

ibell commented Nov 1, 2015

Hopefully this is enough information. Let me know if not.

@ibell ibell closed this as completed Nov 1, 2015
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

No branches or pull requests

3 participants