CalebBell / thermo

Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)
MIT License
594 stars 114 forks source link

calculate attribute doesnt work for Mixture in the 0.2.* package thermo.chemical #100

Closed ghost closed 2 years ago

ghost commented 2 years ago

I was recently coding using Mixture object in thermo.chemical package. It kept giving me an error saying 'Mixture' object didnt have attribute 'calculate' When i changed the thermo version to 0.1.40, it worked.

Please fix the bus/issue.

Ps. I am using github for the first time, so please forgive me for the way of creating an issue, if wrong or let me know if you want any further information about my error.

longemen3000 commented 2 years ago

Hi, can you specify:

ghost commented 2 years ago

I am attaching the code herewith in a txt file beau.txt . the results are as below in case of 0.2.13 package showing the error and the line no. of the code as well. And the desired result that i get when i use the 0.1.40 package respectively

File D:\Study\TFM-ASA\UCLouvain - Ecole Polytechnique de Louvain\LMECA2220 - Internal Combustion Engines\Assignment 1\modified Beau.py:77 in myfunc mix_prop.calculate(T=Tin) #calculation for the inlet mixture

AttributeError: 'Mixture' object has no attribute 'calculate'

[0.4715547482248196, array([ 100000. , 2289231.45917724, 9035520.63100822, 505693.50927759]), array([ 300. , 686.76943775, 2710.6511755 , 1517.07772174])]

ghost commented 2 years ago

Interestingly, the code worked [i got 100% grade automatically based on test cases]on the platform where i was supposed to submit it as an assignment, which may mean that platform was running the old thermo package but it kept showing me this error on my pc which led me to think that version of python may be causing the issue. I tried with all python versions upto 3.6 but the same error which led me to deduce maybe package has some bug. I dont want to downgrade the thermo package as I would better use 0.2.* so please help me solve this issue.

ghost commented 2 years ago

in the documentation for Legacy Mixtures, i could not find the calculate attribute. Has the calculate attribute been changed when thermo was upgraded from 0.1 to 0.2?

CalebBell commented 2 years ago

Hi,

I recommend people convert to the new interfaces, which are more consistent and eventually I aim to never change. The library is old but still has a long way to mature.

If you want to keep using the Mixture API, I believe the flash_caloric call is what you want, but I see in your code you are providing only T. You will need to change it to provide P as well. The thermodynamic consistency between liquid and vapor and in the supercritical region could be a lot better than it is with the Mixture API though, which is why I recommend using the new calls.

You are of course free to keep using old versions!

I hope this helps.

Sincerely, Caleb

ghost commented 2 years ago

Thank you for the clarification Caleb, I will definitely keep this in mind when i use the package again. I am happy to see that you have improved the library in the 0.2 version and its actually better to use the flash_caloric call indeed!

Best, Kunal