Peng Robinson EOS

Peng Robinson EOS - Сообщения

#1 Опубликовано: 27.05.2016 17:11:58
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Hi. This is my approach to Peng Robinson EOS, incomplete and not tested.
Alvaro.
PR_work.sm (102 КиБ) скачан 93 раз(а).
2 пользователям понравился этот пост
Radovan Omorjan 27.05.2016 17:54:00, Mike Kaganski 27.05.2016 21:29:00
#2 Опубликовано: 27.05.2016 21:45:24
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

Great!

I wanted to notice that this and other EOSs are available as CoolProp Wrapper extension. CoolProp library contains its own implementation of multiple substances properties (Propane is here), and their mixtures, but also provides access to REFPROP if installed.

Nevertheless, writing EOS implementations yourself is a great excercise. My notice isn't meant to discourage you; I myself used to implement IAPWS IF97 EOS formulations (IAPWS-IF97.sm (508 КиБ) скачан 80 раз(а).) some time ago.
С уважением, Михаил Каганский
#3 Опубликовано: 28.05.2016 00:33:08
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote



I wanted to notice that this and other EOSs are available as CoolProp Wrapper extension. CoolProp library contains its own implementation of multiple substances properties



Sure. Are for teach only, CoolProp can be used, with the same precautions of RefProp for real world problems. Check the las exercise, taken from Cengel (and EES software): CoolProp (and others) fails, and need to downgrade to some more simple model.

MassAndEnergyInCV.sm (206 КиБ) скачан 80 раз(а).

Best regards.

Alvaro.
#4 Опубликовано: 28.05.2016 01:47:35
Alexander O. Melnik

Alexander O. Melnik

127 сообщений из 494 понравились пользователям.

Группа: Moderator

Wrote

I myself used to implement IAPWS IF97 EOS formulations (IAPWS-IF97.sm (508 КиБ) скачан 80 раз(а).) some time ago.



Really like the organization on the sheet. I can learn from it just by looking at the title of the collapsed region and the equations that follow.

#5 Опубликовано: 28.05.2016 05:25:41
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Wrote

Wrote

I myself used to implement IAPWS IF97 EOS formulations (IAPWS-IF97.sm (508 КиБ) скачан 80 раз(а).) some time ago.



Really like the organization on the sheet. I can learn from it just by looking at the title of the collapsed region and the equations that follow.



All my respect for this extensive file.

By the way, in SM build 5990 the viscosity calculations under Временные расчёты will throw an error(Units don't match) although units are correct (put them manually and the result is Ok). This error is not present in the previous SM build.

Regards,
Radovan

IAPWS-IF97.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 пользователям понравился этот пост
Mike Kaganski 28.05.2016 06:00:00
#6 Опубликовано: 28.05.2016 06:05:48
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

Radovan, thank you.
Actually, it wasn't touched for very long time, and wasn't completed. I only attached it in case if someone finds it useful demo. Of course, it could have bit-rotten. But I won't update it, because I don't use it anymore.

Razonar, I hope that you, of course, expressed your appreciation to those who give us their knowledge, time and energy for free, by filing a bug report about those problems you found at library issues tracker?
Actually, I haven't yet looked into your calculations deeply, but I feel it strange that you look for pressure of Tetrafluoroethane with T=-20°C and enthalpy=234.55 kJ/kg, the same as at +20°C and P=800 kPa. You marked it "FAILS", and provided manual value of 150.8 kPa, but it cannot be that: how can a liquid at lower temperature AND pressure have the same energy as at higher temperature and pressure? Actually, interpolation says it should be about 140 MPa, far higher than upper limit of EOS (70 MPa).
С уважением, Михаил Каганский
#7 Опубликовано: 28.05.2016 13:39:19
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote


Razonar, I hope that you, of course, expressed your appreciation to those who give us their knowledge, time and energy for free, by filing a bug report about those problems you found at library issues tracker?
Actually, I haven't yet looked into your calculations deeply, but I feel it strange that you look for pressure of Tetrafluoroethane with T=-20°C and enthalpy=234.55 kJ/kg, the same as at +20°C and P=800 kPa. You marked it "FAILS", and provided manual value of 150.8 kPa, but it cannot be that: how can a liquid at lower temperature AND pressure have the same energy as at higher temperature and pressure? Actually, interpolation says it should be about 140 MPa, far higher than upper limit of EOS (70 MPa).




Yes, I say thanks last week in the post of CoolProps. It's a big effort, and they share they knowdalge and expertise, which is very preciate.
About the fail, which fail is air. And isn't a bug in CoolProps or the wrapper, it's a failure of the model in general: can't derive a dependence between Cp and T, P at the same time. For this reason, which is used is a more simple model for the Cp with a dependence only for the temperature. So, there are no need for poste any issue with CoolProp, because there are not one. Eventually, ask for a new utility: provide ideal gas equations too.
Attached, a capture screen from EES showing u evaluated only as funcion of T.
EES.gif

#8 Опубликовано: 28.05.2016 20:58:45
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

Wrote

About the fail, which fail is air. And isn't a bug in CoolProps or the wrapper, it's a failure of the model in general: can't derive a dependence between Cp and T, P at the same time. For this reason, which is used is a more simple model for the Cp with a dependence only for the temperature.



Actually, I couldn't see this in the sheet you've attached earlier: there seem to be a number of problems in the Air section, including using T[1 and P[1 (extracting elements) where T and P are set to be scalar, and it seems T.air and P.air should be used.

Could you please clean up, refine and annotate your example so that your point would be clear, so that I could try to come up with a workaround? Just out of curiosity.

EDIT: If my presumptions are right, then there's no fundamental model shortage in your Air sample, only not-yet-implemented input pair:

scrH44.png

MassAndEnergyInCV-air.sm (25 КиБ) скачан 36 раз(а).

What is wrong here is trying to use two different models in one solution. You use more precise real-gas model for some system properties, and at the same time want to use simpler ideal-gas model for other properties of the same process. This approach is fundamentally wrong, and cannot give you sensible results.

But now I don't understand this:

Wrote

Sure. Are for teach only, CoolProp can be used, with the same precautions of RefProp for real world problems. Check the las exercise, taken from Cengel (and EES software): CoolProp (and others) fails, and need to downgrade to some more simple model.



This was the response to me informing you that there is an implementation of EOS you shared in the first message. You implemented not a simpler model, so I cannot see an interconnection between my message and your objection. Yes, CoolProp cannot be used for any possible task in life, and it prepares poor coffee, too, but it is suitable for the task that you implemented in the first place.
С уважением, Михаил Каганский
#9 Опубликовано: 29.05.2016 00:24:37
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote



Actually, I couldn't see this in the sheet you've attached earlier: there seem to be a number of problems in the Air section, including using T[1 and P[1 (extracting elements) where T and P are set to be scalar, and it seems T.air and P.air should be used.

Could you please clean up, refine and annotate your example so that your point would be clear, so that I could try to come with a workaround? Just out of curiosity.



T, P are vectors. CoolProp can't work in that region for air, but isn't alone, there are others (like EES, for example).

Refprop can handle this problem, but with Cp(T) (or Cv for u) I guess.

Attached the workaround: use IG equations (Constant K = P1 V1 / T1 = P2 V2 / T2 ) which give very close solutions.

So, attached, the "clean" implementation.

Best regards.

Alvaro.

air.gif

Air in piston-cylinder fitted with stops.sm (34 КиБ) скачан 43 раз(а).

AIR3.gif

air2.gif
#10 Опубликовано: 29.05.2016 00:38:20
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

Wrote

T, P are vectors.



They are not in your MassAndEnergyInCV.sm (206 КиБ) скачан 80 раз(а).
There you re-define them to be scalars right above the Air calculations, and then define other vectors: T.air and P.air.

Wrote

CoolProp can't work in that region for air



Well, this is already fixed in CoolProp version 6.0.0, but the wrapper isn't yet updated, because in 6.0.0, they broke their get_parameter_information_string.
So, there WAS something to submit to them as an issue.

scrH45.png

scrH46.png
С уважением, Михаил Каганский
#11 Опубликовано: 29.05.2016 01:13:16
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

I'm not in EOS anymore. At the time I was, doing Engineering, the bible was
"Liquid Air, Encyclopedia of gases" I can see some non convenient items in
the "Utilities PR". Essentaially, it is a missconcept attempting to instruct
Smath to be algo style "Unary A(f,x)". Smath is already coded algo style.
That's what makes it a powerful calculator/solver... just like this

Forum Algo style.gif


That's too simple. Revisit the attached example, several instances algo style.
Can't be simpler in concept, works logical simple from native coding, easy to
design ... works as designed, easy to debug.

Model Chemist Genfit.sm (56 КиБ) скачан 33 раз(а).
#12 Опубликовано: 29.05.2016 01:17:21
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote



What is wrong here is trying to use two different models in one solution. You use more precise real-gas model for some system properties, and at the same time want to use simpler ideal-gas model for other properties of the same process. This approach is fundamentally wrong, and cannot give you sensible results.



Oh! My bug. Please, add that as an issue in the svn server.

Regards.

Alvaro.
#13 Опубликовано: 29.05.2016 01:28:03
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

Wrote

T, P are vectors.



They are not in your MassAndEnergyInCV.sm (206 КиБ) скачан 80 раз(а).
There you re-define them to be scalars right above the Air calculations, and then define other vectors: T.air and P.air.



So ... T, P are vectors. T.air, P.air too. Assign's at the left margin like T=0, h=0 as null scalars are usual practice in math cad programs for ensure that redefinitions, like T[2 = xx, don't carry up old values.

Alvaro.
#14 Опубликовано: 29.05.2016 01:28:06
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

Wrote

So ... T, P are vectors. T.air, P.air too. Assign's at the left margin like T=0, h=0 as null scalars are usual practice in math cad programs for ensure that redefinitions, like T[2 = xx, don't carry up old values.



No.

When you assign T:=0, in SMath you actually do set T to be scalar 0.
If you then try to use el() on it, like in t:=el(T,1), then you will get an error that argument is not proper.

scrH47.png

It doesn't matter that in some other program it may be another way.
С уважением, Михаил Каганский
#15 Опубликовано: 29.05.2016 01:35:59
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Sure?

RehusingVectors.gif

Alvaro
#16 Опубликовано: 29.05.2016 01:39:22
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

You used it in assignment, while I explicitly noted that it gives error when used to get value of an element.

Please re-examine again your file, before further doubting my words.
You assigned P and T to be 0, didn't fill them to be vectors again, and used their non-existing elements in Prop() functions. That gave errors.

If you would assign them values like you shown in your previous post, then it would be a different story.
С уважением, Михаил Каганский
#17 Опубликовано: 29.05.2016 01:43:25
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

You used it in assignment, while I explicitly noted that it gives error when used to get value of an element.



And that is about of what of my bugs?

Alvaro.
#18 Опубликовано: 29.05.2016 01:51:22
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

Wrote

And that is about of what of my bugs?



scrH48.png

Red are places where "elements" of scalars were used (last red is where T is still simply 0, no element, but surely not what was intended).
Greens are where you try to "convert" them to matrices.
С уважением, Михаил Каганский
#19 Опубликовано: 29.05.2016 01:59:00
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote


Please re-examine again your file, before further doubting my words.
You assigned P and T to be 0, didn't fill them to be vectors again, and used their non-existing elements in Prop() functions. That gave errors.

If you would assign them values like you shown in your previous post, then it would be a different story.



I chek the attach: Just usual develop strategies for isolate real cause of issues.

Best regards.

Alvaro.

air0.gif
#20 Опубликовано: 29.05.2016 02:19:11
Mike Kaganski

Mike Kaganski

184 сообщений из 434 понравились пользователям.

Группа: User

But this is in some of your new files. Please re-download what you've posted here. See my previous screenshot for what is actually in it.

In the last screenshot, where you do re-define T and P as vectors after defining T.air and P.air, the T:=0 and P:=0 are redundant.
С уважением, Михаил Каганский
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений