Retrieve the Properties of Ammonia from CoolProp in Matlab

113 views
Skip to first unread message

Ying Zhang

unread,
Apr 28, 2023, 3:27:40 PM4/28/23
to coolprop-users
Hello,

I tried to generate  fluid property tables from CoolProp database for Ammonia using the following syntax in Matlab


However, the min. pressure can't be set under 0.32 bar, otherwise I became following error:
e.g.: for pRange=[0.3 Mpa, 95Mpa]
CreatAmmoniaProperties
Error using twoPhaseFluidTables>coolpropFluidProperties (line 899)
CoolProp failed to return fluid properties at P = 0.3 MPa, U =
243.085 kJ/kg.

Error in twoPhaseFluidTables>@(p,u)coolpropFluidProperties(p,u,substance,coolpropFun) (line 789)
fluidProperties = @(p, u) coolpropFluidProperties(p, u, substance, coolpropFun);

Error in twoPhaseFluidTables (line 233)
                = fluidProperties(p(j), u_liq(i,j));

Error in CreatAmmoniaProperties (line 2)
AmmoniaTables = twoPhaseFluidTables([10,3050],[0.3,95],50,50,120,...

Caused by:
    Error using CoolProp/CoolProp.__Props_err2 (line 351)
    Python Error: ValueError: unable to solve 1phase PY flash with Tmin=263.935, Tmax=1087.5 due to error: HSU_P_flash_singlephase_Brent could not find a solution because Umolar [4139.86 J/mol] is below the minimum value of 25121.9561167 J/mol : PropsSI("D","P",300000,"U",243085.0403,"Ammonia")
 
According to my knowledge, the min pressure of ammonia could be under 1 bar, could anyone help me to find why the error occurs? Or is the pressure<3.5 bar is not covered in CoolPro? 

Thanks to all.
>> 

Ian Bell

unread,
May 1, 2023, 7:29:14 AM5/1/23
to coolpro...@googlegroups.com
Sounds like you need to revise the limits you used for building the table

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coolprop-users/3a9fee2d-1925-40b3-8009-298ee7450f15n%40googlegroups.com.

Ying Zhang

unread,
May 3, 2023, 11:55:20 AM5/3/23
to coolprop-users
Hello ian,

could you please tell me where I could revise the pressure limit for Ammonia in the source code? Thank you so much.

Best regards
Ying

Ian Bell

unread,
May 3, 2023, 2:51:23 PM5/3/23
to coolpro...@googlegroups.com
I think the problem is your u range

Ying Zhang

unread,
May 4, 2023, 1:31:22 PM5/4/23
to coolprop-users
Hello ian,

thank you for your response. Could you please tell us what are the limits of uRange and pRange for Ammonia of CoolProp.PropsSI? In our case, we would need the ammonia properties with temperature from -40C to 750 C and pressure range from 0.8bar to 20 bar. Is it possible to create the fluid property using CoolProp?

Best regards
Ying

Ian Bell

unread,
May 4, 2023, 5:36:22 PM5/4/23
to coolpro...@googlegroups.com
Try to do calculations covering this entire range in MATLAB, natively, and report which, if any, fail. Start with a T,p, calculate u, and then put u,p inputs in and see if you get the same T

Ying Zhang

unread,
May 5, 2023, 3:54:10 PM5/5/23
to coolprop-users
Hello iah,

I have run the function PropSI for 1. p=1 bar, T=240 K and 2. p=1bar, T=943 K, Substance=Ammonia, Both functions worked as following:
PropSI1Bar.PNG
Reverse:
PropSI1BarReverse.PNG

That means PropSI could calculate the operation modes which we need. 

However, to generate two phase fluid tables in MATLAB for simscape two phase block, the minimum specific internal energy must be less than the lowest saturated liquid specific internal energy of ammonia at 1 bar, which is 193.0891 kJ/kg:
UminAmmonia1Bar.PNG
If I run the PropSI function for p=1bar, U=193 kJ/kg, then I got the following error:
PropSIError.PNG
Furthermore, I have tried to calculate u with given T= 198 K and P=1 Bar and then set the same U and P as input to calculate T, it failed: 
reverseCalculation.PNG
Could you please help me to debug? Thank you so much!

Best regards
Ying

Nikolaj Maack Bielefeld

unread,
May 6, 2023, 10:02:48 AM5/6/23
to coolprop-users
Hi Ying,

You seem to be outside the range of CoolProp.
However, you can achieve this with REFPROP:

Screenshot 2023-05-06 160020.png

Reply all
Reply to author
Forward
0 new messages